From: <ch...@us...> - 2009-02-24 20:14:42
|
Revision: 279 http://virtplayground.svn.sourceforge.net/virtplayground/?rev=279&view=rev Author: chozone Date: 2009-02-24 20:14:37 +0000 (Tue, 24 Feb 2009) Log Message: ----------- Avatars are now moved correctly(blit+update is now good). There are still some bugs, like when user enters, you don't see his avatar, and when other people walk, it's waaay too slow. Modified Paths: -------------- branches/VP-Grounds/modules/playground/avatar-static.py branches/VP-Grounds/modules/playground.py Modified: branches/VP-Grounds/modules/playground/avatar-static.py =================================================================== --- branches/VP-Grounds/modules/playground/avatar-static.py 2009-02-22 10:59:48 UTC (rev 278) +++ branches/VP-Grounds/modules/playground/avatar-static.py 2009-02-24 20:14:37 UTC (rev 279) @@ -23,3 +23,19 @@ rect = rect.move(-self.rect[0], -self.rect[1]) #Move rect to our position myPos = (self.rect[0] + rect[0], self.rect[1] + rect[1]) #Calculate our position from the rect screen.blit(self.image, myPos, rect) #Blit + + + def move(self, pos): + """ + Call this def to move this avatar to pos x=pos[1], y=pos[2]. + Will update rect, and make playground module update our old+new area + """ + oldRect=self.rect.__copy__() + + self.rect.x=pos[1] + self.rect.y=pos[2] + self.zorder = self.rect.top + self.rect.height + + updateRect=oldRect.union(self.rect) + + self.sh['Playground'].blit(updateRect) Modified: branches/VP-Grounds/modules/playground.py =================================================================== --- branches/VP-Grounds/modules/playground.py 2009-02-22 10:59:48 UTC (rev 278) +++ branches/VP-Grounds/modules/playground.py 2009-02-24 20:14:37 UTC (rev 279) @@ -95,7 +95,10 @@ user = arg[1] #Is this on our ground? Do we need to update it? if user.has_key('Pos') and user['Pos'] != None: - self.openObject('avatar-' + user['Avatar'][0], 'av-' + user['Name'], user) + if 'av-' + user['Name'] in self.objects.keys(): + self.objects['av-%s'%user['Name']].move(user['Pos']) + else: + self.openObject('avatar-' + user['Avatar'][0], 'av-' + user['Name'], user) @@ -148,6 +151,7 @@ self.createRects() def openObject(self, objname, name, data): + print '## Open Object', name, 'as', objname #DEBUG obj = self.modObjects[objname] obj = obj(data, self.sh) self.objects[name] = obj This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |