I added the protocol.py file.
[krufty_fps.git] / client_twisted.py
blob0e7dc5aba890500776ec06c204053e3d996d0f01
1 #!/usr/bin/python
3 # PyOpenGL + Pygame
5 CONFIG = 'game_config.xml'
7 WINDOW_SIZE = (640, 480)
8 WINDOW_CAPTION = "Testing stuff"
10 BROADCAST = 50030
11 BROADCAST_BIND = 50031
12 MESSAGE = 40030
14 BUFSIZE = 120
16 ECHO_TIME = 5
18 TIMEOUT = .1
20 BROADCAST = ''
21 MULTICAST = '234.0.0.1'
23 SERVER_TIMEOUT = 0
25 # this will change
27 SERVERREQUEST = "i_want_server"
28 SERVEROFFER = "Want_server?"
29 SERVERKILL = "DIE_server!!"
30 YOUTHERE = "you_there?"
31 IMHERE = "yeah,i'm_here"
32 WANTIN = "i_want_in"
33 YOUREIN = "urine"
34 IMOUT = "i_leave"
35 GETLIST = "get_list"
36 LIST = "peoples_on_server"
37 SOMEONEJOINED = "dude,someone_joined"
38 SOMEONELEFT = "someone_left"
39 YOUROUT = "get_lost_punk"
40 LETTER = "listen_to_me"
41 SERVER_GONE = 'its_gone'
43 the_functions = {}
44 in_script = 0
46 import os, sys
47 from os import *
48 from os.path import *
50 import threading
51 from socket import *
52 from xml.dom.minidom import parse, parseString
53 from threading import Lock
54 from signal import *
55 from zipfile import *
57 from twisted.internet.protocol import DatagramProtocol
58 from twisted.internet import reactor
59 from twisted.internet import task
61 import pygame
62 from pygame import *
64 import pgu
65 from pgu import gui as pgui
67 import lamina
69 import OpenGL
70 import OpenGL.GL
71 from OpenGL.GL import *
72 import OpenGL.GLU
73 from OpenGL.GLU import *
75 import StringIO
77 def getBroadcast(ip):
78 global BROADCAST
79 BROADCAST = ip
81 print "getBroadcast(): Broadcast is reported to be", ip
82 return
84 reactor.resolve('<broadcast>').addCallback(getBroadcast)
86 the_event_receiver = 0
88 global the_engine
89 global the_client
91 class Engine:
93 def __init__(self, config):
95 self.config = config
96 self.running = 1
98 global the_engine
99 the_engine = self
101 video_flags = OPENGL|DOUBLEBUF
103 return
105 def run(self):
107 global the_client
109 while self.running:
111 self.process_events()
113 self.draw()
115 pygame.display.flip()
117 return
119 if __name__ == '__main__':
120 main()