This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#51 2012-01-07 14:17:10

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: Virtual Space (Online Multiplayer)

The release day is unknown, because of all the preparing and planning I have to do. I'm also coding the server so I don't have to reset it after each update (this is only for this server, not for Chat.PY).

To help with the planning, it would be nice if you could make a list of what you want in the game. My current plans:

- Player Spaceships
- Upgrade-able ships and weapons
- Planets where you can upgrade
- PvP ( Player vs Player )
- PvAI ( Player vs AIs )
- Multiple "universes"
- Max players per universe is 12
- Multiple Solar-Systems
- Max Ships/Objects per Solar-System is 18
- Weapon will be a basic laser

Now most of the limits are due to Scratch's limited speeds, so some of the limits may even be lowered. The release of this may even come after Scratch 2.0 or after Remote Sensors is added to the current Flash Player ( that way you can connect through your browser! ) because of how slow Scratch is. I'll need to do some testing though.

Offline

 

#52 2012-01-07 15:03:09

NeilWest
Scratcher
Registered: 2010-01-06
Posts: 1000+

Re: Virtual Space (Online Multiplayer)

- A space-station hub.
- Mini-games (Repearing, controlling etc. etc.) to help advance the game.
- Tycoon-eque customization. (£1000 to upgrade cannons etc. etc.)
- Power-ups to temporarily upgrade spaceship parts.
- Difficulty
- Personality (When making decisions, people will judge you by your decisions and your decisions effect the game's plot).
- Slow Motion at fatal kills.
- Persistant Data (If this is after Scratch 2.0)

Well? I tried not to be too vague when suggesting ideas.

Offline

 

#53 2012-01-07 15:33:06

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: Virtual Space (Online Multiplayer)

NeilWest wrote:

- A space-station hub.
- Mini-games (Repearing, controlling etc. etc.) to help advance the game.
- Tycoon-eque customization. (£1000 to upgrade cannons etc. etc.)
- Power-ups to temporarily upgrade spaceship parts.
- Difficulty
- Personality (When making decisions, people will judge you by your decisions and your decisions effect the game's plot).
- Slow Motion at fatal kills.
- Persistant Data (If this is after Scratch 2.0)

Well? I tried not to be too vague when suggesting ideas.

Most of those are mainly for a single-player game. So I won't be able to do some of them cause they are kind of complicated for multiplayer games.

Offline

 

#54 2012-01-07 16:10:20

FreshStudios
Scratcher
Registered: 2011-04-11
Posts: 500+

Re: Virtual Space (Online Multiplayer)

Before adding all that stuff, just make a plain simple game with multiplayer  smile

oh, and chat!!


http://i43.tinypic.com/24ymnbn.png

Offline

 

#55 2012-01-07 16:44:35

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: Virtual Space (Online Multiplayer)

FreshStudios wrote:

Before adding all that stuff, just make a plain simple game with multiplayer  smile

oh, and chat!!

Yeah, currently I'm trying to implement pquiza's Python module ( http://scratch.mit.edu/forums/viewtopic.php?id=84927 ) into the mirror, but for some reason the mirror isn't sending messages to or from the server. If you want, you can look at my mirror and server.

Mirror:

Code:

from scratch import *
import threading
import socket
import json

SHOST = raw_input('Host IP: ')
SPORT = int( raw_input('Host Port: ') )

if not SHOST:
    print('You must enter a host.')
    exit(1)

if not SPORT:
    print('You must enter a port.')
    exit(1)

class Client(threading.Thread):
    
    def __init__(self):
        threading.Thread.__init__(self)
        try:
            self.s = Scratch()
        except ScratchConnectionError, e:
            print(e)
            exit(1)

    def run(self):
        s = self.s
        while True:
            try:
                message = s.receive(0)
            except s.ScratchConnectionError, e:
                print(e)
                exit(1)
            print 'Scratch:',message
            server.send( json.dumps(message) )
    
    def send(self, message):
        s = self.s
        message = s.parse_message(message)
        
        print message
        if len( message['broadcast'] ) == 1:
            s.broadcast( message['broadcast'][0] )
        elif len( message['sensor-update'] ) == 1:
            s.sensorupdate( message['sensor-update'] )
    
class Server(threading.Thread):
    
    def __init__(self, ip, port):
        threading.Thread.__init__(self)
        self.s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        
        self.s.connect((ip, port))
    
    def run(self):
        s = self.s
        while True:
            try:
                message = s.recv(1024)
            except:
                exit(1)
            print 'Server:',message
            scratch.send(message)
    
    def send(self, message):
        self.s.send(message)

server = Server(SHOST, SPORT) # Start up the class for Server
server.start() # This starts the 'run' function on the class as well.

scratch = Client() # Start up the class for Scratch
scratch.start() # This starts the 'run' function.

Server:

Code:

#!/usr/bin/env python 

""" 
An echo server that uses threads to handle multiple clients at a time. 
Entering any line of input at the terminal will exit the server. 
""" 

import select 
import socket 
import sys 
import threading 
import json

class Server: 
    def __init__(self): 
        self.host = '' 
        self.port = int( raw_input("Port: ") )
        self.backlog = 5 
        self.size = 1024 
        self.server = None 
        self.threads = [] 
        self.plugins = ['test']
        for plugin in self.plugins:
            exec( 'import '+plugin )

    def open_socket(self): 
        try: 
            self.server = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 
            self.server.bind((self.host,self.port)) 
            self.server.listen(5) 
        except socket.error, (value,message): 
            if self.server: 
                self.server.close() 
            print "Could not open socket: " + message 
            sys.exit(1) 

    def run(self):
        self.open_socket() # Open a socket so people can connect.
        running = 1
        id = 0 # To define each client.
        while running:
            id += 1 # Increase so no client has the same ID.
            c = Client(self.server.accept()) # Waits for a client then accepts it.
            print c.address[0], 'has connected.'
            c.start() # Starts it.
            self.threads.append(c) # Adds it to a list so the variable c and be used for the next client.

        # Disconnect all clients.
        self.server.close() # Disconnect socket.
        for c in self.threads: # For each thread
            c.join() # End that thread.

class Client(threading.Thread): 
    def __init__(self,(client,address)): 
        threading.Thread.__init__(self) 
        self.client = client 
        self.address = address 
        self.size = 1024 
        self.plugins = {}

    def run(self): 
        running = 1 
        while running: 
            try:
                data = self.client.recv(self.size) # Wait and receive data from client
                data = self.parse(data) # Parse it
            except:
                data = ''
            
            print data
            if data:
                for broadcast in data['broadcast']: # For every broadcast, do_broadcast('broadcast')
                    self.do_broadcast( broadcast )
            
                for sensor in data['sensor-update']: # For every sensor-update, do_sensor('sensor', 'value')
                    self.do_sensor( sensor, data['sensor-update'][sensor] )
            else:
                print self.address[0], 'has disconnected.'
                self.client.close()
                running = 0
    
    def parse(self, data): # Parse data
        data = json.loads( data )
    
    def load_plugin(self, plugin): # Load plugin into server plugins
        if plugin not in s.plugins:
            s.plugins.append( plugin )
            try:
                reload( plugin )
            except NameError:
                exec( 'import '+plugin )
        
    
    def unload_plugin(self, plugin): # Unload plugin from server plugins
        if plugin in s.plugins:
            s.plugins.remove( plugin )
            #exec( 'del '+plugin )
    
    def use_plugin(self, plugin): # Add plugin to client
        if plugin in s.plugins: # If it exists
            s.plugins.append( plugin ) # Add it
            exec( '''
            self.plugins[plugin] = '''+plugin+'''.Plugin(self) # Create the class
            '''
            )
            return 'Added plugin.'
        else: # Else, do nothing
            return 'No such plugin.'
    
    def not_plugin(self, plugin):
        if plugin in self.plugins:
            self.plugins.remove( plugin )
            return 'Plugin removed.'
        else:
            return 'No such plugin.'
    
    def do_broadcast(self, broadcast):
        if broadcast: 
            if broadcast[0] == '<':
                self.use_plugin( broadcast[1:-1] )
            elif broadcast[0] == '>':
                self.not_plugin( broadcast[1:-1] )
            elif broadcast[0] == '|':
                self.send_broadcast( broadcast[1:-1] )
            elif broadcast[0] == ':':
                for plugin in self.plugins:
                    try:
                        self.plugins[plugin].broadcast( broadcast[1:-1] )
                    except:
                        pass
        else: 
            self.client.close()
            return False
        return True
    
    def do_sensor(self, name, value):
        return True

    def send_broadcast(self, value):
        broadcast = sendScratchCommand( 'broadcast "'+value+'"' )
        self.client.send( broadcast )
    
    def send_sensor(self, name, value):
        sensor = sendScratchCommand( 'sensor-update "'+name+'" "'+value+'"' )
        self.client.send( sensor )
        
    def sendScratchCommand(cmd): # I was never sure what this did, but it's required.
        n = len(cmd)
        a = array('c')
        a.append(chr((n >> 24) & 0xFF))
        a.append(chr((n >> 16) & 0xFF))
        a.append(chr((n >>  8) & 0xFF))
        a.append(chr(n & 0xFF))
        return (a.tostring() + cmd)

if __name__ == "__main__": 
    s = Server() 
    s.run()

The 'test' plugin:

Code:

# Test Plugin

class Plugin(object):
    
    def __init__(self, owner):
        self.owner = owner
    
    def broadcast(self, message):
        owner = self.owner
        if message == 'test':
            owner.send_broadcast( "test" )
    
    def sensor(self, name, value):
        pass

I'm trying to broadcast '|test' ( the | tells the server to "reflect" or "echo" the message back, so sending '|test' should reply 'test' ). But for some reason, when I send it, the server receives None and then replies with nothing, which crashes the mirror (because it expects a Scratch "encoded" message, which the server sends).

Last edited by Magnie (2012-01-07 16:48:21)

Offline

 

#56 2012-01-08 04:32:40

WindowsExplorer
Scratcher
Registered: 2011-02-25
Posts: 1000+

Re: Virtual Space (Online Multiplayer)

Ground games FTW!!!


http://i.imgur.com/H6LLdnK.pnghttp://i.imgur.com/VYuD7BY.png

Offline

 

#57 2012-01-08 14:20:13

iAnim8
Scratcher
Registered: 2011-12-02
Posts: 1

Re: Virtual Space (Online Multiplayer)

I didn't even know you could link other things with scratch!?

Offline

 

#58 2012-01-08 15:54:11

ImagineIt
Scratcher
Registered: 2011-02-28
Posts: 1000+

Re: Virtual Space (Online Multiplayer)

Space. I can't wait to join when it's up! Can you please tell me when it's done? I wish I knew how to make an MMO. What language? Maybe I would like to learn.

Last edited by ImagineIt (2012-01-08 16:37:29)

Offline

 

#59 2012-01-09 09:31:09

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: Virtual Space (Online Multiplayer)

ImagineIt wrote:

Space. I can't wait to join when it's up! Can you please tell me when it's done? I wish I knew how to make an MMO. What language? Maybe I would like to learn.

The server-language is going to be Python. Currently, the mirror is also in Python, but hopefully, I will be able to get MathWizz to create a Java one too so that you can just open the mirror in your browser.

Offline

 

#60 2012-01-09 09:36:00

ZeroLuck
Scratcher
Registered: 2010-02-23
Posts: 500+

Re: Virtual Space (Online Multiplayer)

Magnie wrote:

The server-language is going to be Python. Currently, the mirror is also in Python, but hopefully, I will be able to get MathWizz to create a Java one too so that you can just open the mirror in your browser.

If you want I can create a Java mirror for you...


http://3.bp.blogspot.com/-oL2Atzp0Byw/T465vIQ36dI/AAAAAAAAADo/1vqL4PvhkM0/s1600/scratchdachwiki.png

Offline

 

#61 2012-01-09 09:45:30

MathWizz
Scratcher
Registered: 2009-08-31
Posts: 1000+

Re: Virtual Space (Online Multiplayer)

Magnie wrote:

ImagineIt wrote:

Space. I can't wait to join when it's up! Can you please tell me when it's done? I wish I knew how to make an MMO. What language? Maybe I would like to learn.

The server-language is going to be Python. Currently, the mirror is also in Python, but hopefully, I will be able to get MathWizz to create a Java one too so that you can just open the mirror in your browser.

Don't you already have a mirror?


http://block.site90.net/scratch.mit/text.php?size=30&amp;text=%20A%20signature!&amp;color=333333

Offline

 

#62 2012-01-09 10:03:16

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: Virtual Space (Online Multiplayer)

MathWizz wrote:

Magnie wrote:

ImagineIt wrote:

Space. I can't wait to join when it's up! Can you please tell me when it's done? I wish I knew how to make an MMO. What language? Maybe I would like to learn.

The server-language is going to be Python. Currently, the mirror is also in Python, but hopefully, I will be able to get MathWizz to create a Java one too so that you can just open the mirror in your browser.

Don't you already have a mirror?

I'm creating a new one that uses pquiza's Python module ( http://scratch.mit.edu/forums/viewtopic.php?id=84927 ), though I am thinking of changing it so that the parser is on the server instead.

Zero: Maybe.

Last edited by Magnie (2012-01-09 10:03:53)

Offline

 

#63 2012-01-09 12:27:25

P110
Scratcher
Registered: 2011-04-12
Posts: 500+

Re: Virtual Space (Online Multiplayer)

Magnie wrote:

I need skilled Python and Scratch programmers that know how to connect Python and Scratch together.

(STATUS:Skilled scratch skilled python next week (estimate)
Hey there,

I'm good with scratch so I can lend a hand if you want, however could you please tell me haw to make a game multiplayer, I already have a game and it would be awesome if I could make it multiplayer.

I've been on scratch for about 2 years, read most of the furum know how to add a project to a website without adding to scratch and more, if you want to take a look at my game visit it's special website it's still under construction as we are waiting on the idea team to give us more ideas for buildings.

I can make pretty much anything on scratch so don't hesitate to ask, also I love space so I would love to help!

website: http://www.monkeybanana.co.uk

I am also quite good with a bit of Html if it's relevant but not a clue even what python is  I will read up on it and learn it and I probably will be able to do pretty much anything on that next week so I will add another relpy saying if I am.

PLEASE LET ME HELP!

P110 at your service!

Thanks

P110
---------------------------------------------------
Head of the Monkey Banana team


Me live on 2.0 now  sad

Offline

 

#64 2012-01-09 12:33:38

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: Virtual Space (Online Multiplayer)

P110 wrote:

Magnie wrote:

I need skilled Python and Scratch programmers that know how to connect Python and Scratch together.

(STATUS:Skilled scratch skilled python next week (estimate)
Hey there,

I'm good with scratch so I can lend a hand if you want, however could you please tell me haw to make a game multiplayer, I already have a game and it would be awesome if I could make it multiplayer.

I've been on scratch for about 2 years, read most of the furum know how to add a project to a website without adding to scratch and more, if you want to take a look at my game visit it's special website it's still under construction as we are waiting on the idea team to give us more ideas for buildings.

I can make pretty much anything on scratch so don't hesitate to ask, also I love space so I would love to help!

website: http://www.monkeybanana.co.uk

I am also quite good with a bit of Html if it's relevant but not a clue even what python is  I will read up on it and learn it and I probably will be able to do pretty much anything on that next week so I will add another relpy saying if I am.

PLEASE LET ME HELP!

P110 at your service!

Thanks

P110
---------------------------------------------------
Head of the Monkey Banana team

Thank you for offering. Currently, I need to get an actual start on the project before real work will be done. The most anyone can do right now is making graphics ( preferably space-ships ) and give suggestions/ideas.

Offline

 

#65 2012-01-09 13:26:16

gabrielgabriel
Scratcher
Registered: 2009-04-12
Posts: 52

Re: Virtual Space (Online Multiplayer)

Magnie wrote:

This is the discussion of the Virtual World I am going to make.

Type of virtual world: Space or Ground?
Votes:
Space 7
Ground 5

Awesome. Ground.

Offline

 

#66 2012-01-09 15:59:30

ScratchDude101
Scratcher
Registered: 2009-01-30
Posts: 100+

Re: Virtual Space (Online Multiplayer)

Ground, Stellar Dawn is coming out soon so we don't need another Space game.


Why did I even name myself "ScratchDude101?" I'm Cronos Dage.
http://cl.ly/EDZM/Screenshot%202012-02-14%20at%206.17.40%20pm.png

Offline

 

#67 2012-01-09 17:23:49

CatPerson
Scratcher
Registered: 2011-12-17
Posts: 1000+

Re: Virtual Space (Online Multiplayer)

Space!
     Love,
         CatPerson  /\_/\
                         I ' . ' I  Cat *ding* Ima kittyKat!


http://nyopoliticker.files.wordpress.com/2012/02/in_dog_we_trust_rusty.jpghttps://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcSrxH2RAmte9adghivuoOhgklIlUcZUFuCAA0wFufFq-NWyZWg5http://www.buttonsonline.com/2012/obama/BO-rallysign-104.gif

Offline

 

#68 2012-01-10 18:29:26

bobbybee
Scratcher
Registered: 2009-10-18
Posts: 1000+

Re: Virtual Space (Online Multiplayer)

Space!


I support the Free Software Foundation. Protect our digital rights!

Offline

 

#69 2012-01-10 19:23:38

ImagineIt
Scratcher
Registered: 2011-02-28
Posts: 1000+

Re: Virtual Space (Online Multiplayer)

How about every player has a planet for them self to live on?

Offline

 

#70 2012-01-10 19:24:38

ImagineIt
Scratcher
Registered: 2011-02-28
Posts: 1000+

Re: Virtual Space (Online Multiplayer)

Guys, it's already space.

Offline

 

#71 2012-01-10 19:27:49

ImagineIt
Scratcher
Registered: 2011-02-28
Posts: 1000+

Re: Virtual Space (Online Multiplayer)

Oh, and what about galaxies too?

Offline

 

#72 2012-01-10 20:11:27

PythonDreamer
New Scratcher
Registered: 2012-01-08
Posts: 64

Re: Virtual Space (Online Multiplayer)

Space! Btw, I wish I could help but I don't know anything about Python. And my username's PYTHONdreamer. Ugh, I'm a failure. x3

Offline

 

#73 2012-01-10 20:47:37

prototype47
Scratcher
Registered: 2010-02-25
Posts: 98

Re: Virtual Space (Online Multiplayer)

SPACE! And I'd be glad to help  smile   I know the very very basics of python, but that's about it.  On the other hand, I consider myself very proficient at Scratch.  Any ways you could use me?  (Testing, scripting, etc.?)


SED is temporarily abandoned while I move onto new areas, such as AI with pathfinding, individual reactions, and group communication.  More complex projects are also brewing.
http://dl.dropbox.com/u/41930734/newsig.png

Offline

 

#74 2012-01-10 21:08:26

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: Virtual Space (Online Multiplayer)

ImagineIt: I'm sure later in development I can add the feature to conquer planets. But each player starting with their own planet would be complicated to code. For the galaxies... I'm not sure. It would require adding more solar-systems and planets, AIs... etc.

Offline

 

#75 2012-01-11 05:53:51

Cassiedragon
Scratcher
Registered: 2011-07-07
Posts: 500+

Re: Virtual Space (Online Multiplayer)

Ground!  big_smile


http://imghosting.cassiedragonandfriends.org/cassiedragonsiggy.gif

Offline

 

Board footer