Esempio n. 1
0
    def __init__(self,
                 screen_width: int = 480,
                 screen_height: int = 480,
                 ip: str = "127.0.0.1",
                 port: int = 5071):

        Process.__init__(self)
        ConnectionListener.__init__(self)

        # Set the screen size
        self.screen_size = Size(screen_width, screen_height)

        # Synchronization parameter
        self.step = 0

        # Init the id and grid_size, defined later by the server
        self.id = None
        self.grid_size = None
        self.renderer = None
        self.is_connected = False

        # Init a dict to store all snake.
        self.snakes = {}
        self.foods = {}

        # Connect to the server
        self.Connect(address=(ip, port))
        print(f"[Client] Starting complete > Connected to: {ip}:{port}")
Esempio n. 2
0
 def Pump(self):
     connection.Pump()
     ConnectionListener.Pump(self)
     Concurrent.Pump(self)
     # try and reconnect every 30 seconds
     if self.serverconnection != 1 and time() > self.lastConnect + 30:
         self.Connect()
Esempio n. 3
0
	def Pump(self):
		ConnectionListener.Pump(self)
		if self.levelmanager.net.serverconnection == 1 and not self.game.progress.showing:
			if self.On():
				if self.lockButton.CanEdit():
					self.editInterface.Pump()
					Concurrent.Pump(self)
					EventMonitor.Pump(self)
				else:
					self.editButton.Pump()
					self.lockButton.Pump()
					self.newButton.Pump()
			else:
				self.editButton.Pump()
Esempio n. 4
0
    def __init__(self, parent, player):

        Game.__init__(self, parent, player)
        ConnectionListener.__init__(self)

        self.gameid = None
        self.num = None
        self.found_opponnent = False
        self.server_message = None

        # ONLINE

        self.server_message = None
        self.loaded = False

        self.Connect(("localhost", 8000))
        """
        address = raw_input("Address of Server: ")
        try:
            if not address:
                host, port = "localhost", 8000
            else:
                host, port = address.split(":")
            self.Connect((host, int(port)))
        except:
            print "Error Connecting to Server"
            print "Usage:", "host:port"
            print "e.g.", "localhost:31425"
            exit()
        """

        self.running = False
        while not self.running:
            self.Pump()
            connection.Pump()
            pygame.display.update()
            sleep(0.01)
Esempio n. 5
0
	def Pump(self):
		ConnectionListener.Pump(self)
		self.players.Pump()
		Game.Pump(self)
		EventMonitor.Pump(self)
Esempio n. 6
0
 def Pump(self):
     ConnectionListener.Pump(self)
     Character.Pump(self)
     # network players ignore events (keypresses, joysticks etc.)
     if not self.playerid and not self.game.progress.showing:
         EventMonitor.Pump(self)
Esempio n. 7
0
 def Pump(self):
     ConnectionListener.Pump(self)
     if not self.game.progress.showing:
         Concurrent.Pump(self)
         EventMonitor.Pump(self)