class Client(): def connect(self, ip): factory = pb.PBClientFactory() reactor.connectTCP(ip, 8800, factory) d = factory.login(credentials.Anonymous()) d.addCallback(self.connected) @defer.inlineCallbacks def connected(self, perspective): self.perspective = perspective self.environment = yield perspective.callRemote('getEnvironment') self.environment.team = yield perspective.callRemote('getTeam') self.view = Window(self.environment) self.view.start("Client - %d" % (self.environment.team, )) self.controller = PlayerController(self.perspective, self.view) self.controller.go() def shutdown(self, result): reactor.stop()
class Client(): def connect(self, ip): factory = pb.PBClientFactory() reactor.connectTCP(ip, 8800, factory) d = factory.login(credentials.Anonymous()) d.addCallback(self.connected) @defer.inlineCallbacks def connected(self, perspective): self.perspective = perspective self.environment = yield perspective.callRemote('getEnvironment') self.environment.team = yield perspective.callRemote('getTeam') self.view = Window(self.environment) self.view.start("Client - %d" % (self.environment.team, )) self.controller = PlayerController(self.perspective, self.view) self.controller.go() def shutdown(self, result): reactor.stop() pygame.mixer.pre_init(frequency=16000, size=8, channels=1, buffer=1024) #, size=-8, channels=1)
self.environment.updatePlayerPosition(self.player, position) def perspective_getEnvironment(self): return self.environment def perspective_getTeam(self): return self.player.team #TODO could we add a perspective_getPosition and perspective_getIRTargetStatus here #TODO otherwise, how do we do remote call on a client? pygame.init() pygame.display.set_mode((480, 800), pygame.DOUBLEBUF) realm = GameRealm() env = Environment() view = Window(env) realm.environment = env view.start('Server') LoopingCall(lambda: pygame.event.pump()).start(0.03) portal = portal.Portal(realm, [checkers.AllowAnonymousAccess()]) reactor.listenTCP(8800, pb.PBServerFactory(portal)) from twisted.protocols.basic import LineReceiver from twisted.internet import protocol import cPickle class PlayerBlob: def __init__(self, player): self.player = player self.lights = [] self.x = -1
return self.player.team def perspective_switchTeams(self): return self.environment.switchTeams(self.player) #TODO could we add a perspective_getPosition and perspective_getIRTargetStatus here #TODO otherwise, how do we do remote call on a client? pygame.init() pygame.display.set_mode((800, 480), pygame.DOUBLEBUF) realm = GameRealm() env = Environment() view = Window(env) realm.environment = env view.start('Server') LoopingCall(lambda: pygame.event.pump()).start(0.03) controller = ServerController(realm, view) controller.go() portal = portal.Portal(realm, [checkers.AllowAnonymousAccess()]) reactor.listenTCP(8800, pb.PBServerFactory(portal)) from twisted.protocols.basic import LineReceiver from twisted.internet import protocol import cPickle class PlayerBlob: