def register(self): a_id, a_x, a_y, a_a, packet = from_bytes(self.server.recv(PACKET_SIZE)) self.ally = AllySpaceShip(a_id, (a_x, a_y), a_a) self.group.add(self.ally) e_id, e_x, e_y, e_a, packet = from_bytes(self.server.recv(PACKET_SIZE)) self.enemy = EnemySpaceShip(e_id, (e_x, e_y), e_a) self.group.add(self.enemy)
def receive(self): try: data = self.server.recv(self.max_packets * PACKET_SIZE) except timeout: return else: for i in range(0, len(data), PACKET_SIZE): s_id, s_x, s_y, s_a, pack_type = from_bytes(data[i:i + PACKET_SIZE]) yield s_id, s_x, s_y, s_a, pack_type