From: <Blu...@us...> - 2010-09-27 22:02:55
|
Revision: 412 http://virtplayground.svn.sourceforge.net/virtplayground/?rev=412&view=rev Author: BlueWolf_ Date: 2010-09-27 22:02:49 +0000 (Mon, 27 Sep 2010) Log Message: ----------- Sending move-events to the server Modified Paths: -------------- trunk/client/core/client.py trunk/client/playground.py Modified: trunk/client/core/client.py =================================================================== --- trunk/client/core/client.py 2010-09-26 22:16:14 UTC (rev 411) +++ trunk/client/core/client.py 2010-09-27 22:02:49 UTC (rev 412) @@ -274,6 +274,12 @@ "version": __version__ }) + def move(self, moving, pos, direction = None, speed = None): + data = {"moving": moving, "pos": pos} + if moving: + data['direction'] = direction + data['speed'] = speed + self.send("move", data) def send(self, data_header, data_body = {}): Modified: trunk/client/playground.py =================================================================== --- trunk/client/playground.py 2010-09-26 22:16:14 UTC (rev 411) +++ trunk/client/playground.py 2010-09-27 22:02:49 UTC (rev 412) @@ -20,8 +20,6 @@ from playground_avatar import Avatar from playground_background import Background -POS_UPDATE_DELAY = 1 # Determines when a pos-update should be send. - # Every x seconds. MOVE_SPEED = 175 # How fast the avatar shoud walk @@ -75,12 +73,16 @@ if direction == None and self.direction != None: # Stop the timer. We are not walking self.direction = None + sh['client'].move(False, self.this_user['pos'][0:2]) sh['timer'].stop("playground-walk") elif self.direction == None or \ direction != self.direction[0]: # We started walking or changed direction + sh['client'].move(True, self.this_user['pos'][0:2], + direction, MOVE_SPEED) + self.direction = (direction, time.time(), self.this_user['pos'][:]) sh['timer'].start("playground-walk", @@ -139,6 +141,7 @@ if data['action'] == "update": self.background.update_landscapes(sh['landscapes']) + def update(self, rect = None, doupdate = True): # This will blit and update the screen at rect @@ -283,7 +286,3 @@ sh['update']() if self.viewport_float == desired_pos: return True - - - elif name == "playground-pos-update": - pass This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |