-
Notifications
You must be signed in to change notification settings - Fork 0
/
client_ui.py
executable file
·59 lines (45 loc) · 1.55 KB
/
client_ui.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env python
import pygame
from twisted.internet import reactor
from twisted.internet.task import LoopingCall
from client.map_render import MapRender
from client.mouse import MouseHandler
from client.pantalla import Pantalla
from client.teclado import KeyboardHandler
from generic_client import GenericClient
class WindowClient(GenericClient):
DESIRED_FPS = 30.0 # 30 frames per second
def run_loop(self):
self.loop = LoopingCall(self.update)
self.loop.start(1.0 / self.DESIRED_FPS)
if self.STANDALONE:
reactor.run()
def load_io_handlers(self):
self.pantalla = Pantalla(self)
self.teclado = KeyboardHandler(self)
self.mouse = MouseHandler(self)
def update(self):
self.pantalla.update()
self.mouse.update()
if not self.teclado.update():
self.close_window()
def activate_io_handlers(self):
self.pantalla.activar()
self.teclado.activar()
self.mouse.activar()
def create_map(self, sequence):
mapa = MapRender(sequence)
self.pantalla.dibujar.set_map(mapa)
return mapa
def set_principal(self, player):
self.principal = player
self.hcriat.my_team = player.equipo
self.pantalla.set_principal(player)
def close_window(self):
self.on = False
pygame.quit()
reactor.stop()
if __name__ == '__main__':
team = raw_input('1 - blue ; 2 - red\n') or 1
ip = raw_input('IP: (default is 127.0.0.1)\n') or '127.0.0.1'
WindowClient(ip, int(team))