From: <Blu...@us...> - 2009-02-10 19:17:58
|
Revision: 277 http://virtplayground.svn.sourceforge.net/virtplayground/?rev=277&view=rev Author: BlueWolf_ Date: 2009-02-10 19:17:47 +0000 (Tue, 10 Feb 2009) Log Message: ----------- Making the first changes for the ground Modified Paths: -------------- branches/VP-Grounds/brains.py branches/VP-Grounds/connection.py branches/VP-Grounds/interface.py branches/VP-Grounds/modules/playground/background.py branches/VP-Grounds/modules/playground/object.py branches/VP-Grounds/modules/playground.py Added Paths: ----------- branches/VP-Grounds/modules/playground/avatar-static.py Modified: branches/VP-Grounds/brains.py =================================================================== --- branches/VP-Grounds/brains.py 2009-02-10 19:15:51 UTC (rev 276) +++ branches/VP-Grounds/brains.py 2009-02-10 19:17:47 UTC (rev 277) @@ -78,7 +78,6 @@ #Change the values self.walkingDir[direction] += speedRel - #Check if we have to start/stop a timer if self.walkingDir == [0,0,0,0]: #Not walking @@ -89,7 +88,6 @@ else: #We are walking - #Is our timer NOT running? if self.walkTimer == None or self.walkTimer.isRunning == False: #Start it! @@ -112,11 +110,14 @@ name = self.sh['conf']['account']['user'] users = self.sh['users'] if name in users: - users[name]['Pos'][1] -= self.walkingDir[0] - users[name]['Pos'][2] -= self.walkingDir[1] - users[name]['Pos'][1] += self.walkingDir[2] - users[name]['Pos'][2] += self.walkingDir[3] - print users[name]['Pos'] + users[name]['Pos'][2] -= self.walkingDir[0] + users[name]['Pos'][1] -= self.walkingDir[1] + users[name]['Pos'][2] += self.walkingDir[2] + users[name]['Pos'][1] += self.walkingDir[3] + + self.sh['Interface'].call('playground', 'UserUpdate', users[name]) + + #print users[name]['Pos'] def doWalkUpdate(self): Modified: branches/VP-Grounds/connection.py =================================================================== --- branches/VP-Grounds/connection.py 2009-02-10 19:15:51 UTC (rev 276) +++ branches/VP-Grounds/connection.py 2009-02-10 19:17:47 UTC (rev 277) @@ -40,7 +40,7 @@ resp['Reason'] = 'VP' #What we are resp['Client'] = 'VPclient/0.0.1' #Who we are resp['Version'] = '1.00' #What protocol-version we're going to use - resp['Pos'] = ['', 0, 0, 0,] #Our location (Default) + resp['Pos'] = ['treehouse.0.0', 0, 0, 0,] #Our location (Default) auth = {} #Authentation auth['User'] = self.userAuth[0] auth['Passwd'] = self.userAuth[1] Modified: branches/VP-Grounds/interface.py =================================================================== --- branches/VP-Grounds/interface.py 2009-02-10 19:15:51 UTC (rev 276) +++ branches/VP-Grounds/interface.py 2009-02-10 19:17:47 UTC (rev 277) @@ -278,6 +278,7 @@ class __Timer(): def __init__(self, forceUpdate, delay, function, *arg, **kwarg): + if 'notFirstTime' in kwarg: del kwarg['notFirstTime'] dontRun = True @@ -297,6 +298,7 @@ self.timer.start() def run(self): + if self.isRunning == False: return resp = self.function[0](*self.function[1], **self.function[2]) self.forceUpdate() Added: branches/VP-Grounds/modules/playground/avatar-static.py =================================================================== --- branches/VP-Grounds/modules/playground/avatar-static.py (rev 0) +++ branches/VP-Grounds/modules/playground/avatar-static.py 2009-02-10 19:17:47 UTC (rev 277) @@ -0,0 +1,25 @@ +from functions import * + +class Object(): + def __init__(self, data, share): + self.sh = share + + + self.rect = Rect(data['Pos'][1], data['Pos'][2], 0, 0) + self.zorder = self.rect.top + self.rect.height + + self.sh['Downloader'].getImage(data['Avatar'][1], self.imageUpdate) + + def imageUpdate(self, image, *arg): + self.image = image[0] + self.rect.size = image[1].size + self.zorder = self.rect.top + self.rect.height + + self.sh['Playground'].blit(self.rect) + + + def update(self, screen, rect): + if self.rect.colliderect(rect): #Check if the rect collide with ours + 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 Modified: branches/VP-Grounds/modules/playground/background.py =================================================================== --- branches/VP-Grounds/modules/playground/background.py 2009-02-10 19:15:51 UTC (rev 276) +++ branches/VP-Grounds/modules/playground/background.py 2009-02-10 19:17:47 UTC (rev 277) @@ -2,8 +2,7 @@ class Object(): def __init__(self, data, share): - self.downloader = share['downloader'] - self.master = share['master'] + self.sh = share #Settings defaults data['background'] = data.get('background', None) @@ -17,7 +16,7 @@ if self.data['background'] != None: self.background = None - self.downloader.getImage(self.data['background'], self.imageChange) + self.sh['Downloader'].getImage(self.data['background'], self.imageChange) else: self.background = pygame.Surface((726,402)) self.background.fill(self.data['backgroundcolor']) @@ -35,7 +34,7 @@ pos[0] += image[1].w pos[1] += image[1].h pos[0] = 0 - self.master.blit(self.rect) + self.sh['Playground'].blit(self.rect) def update(self, screen, rect): if self.rect.colliderect(rect): #Check if the rect collide with ours Modified: branches/VP-Grounds/modules/playground/object.py =================================================================== --- branches/VP-Grounds/modules/playground/object.py 2009-02-10 19:15:51 UTC (rev 276) +++ branches/VP-Grounds/modules/playground/object.py 2009-02-10 19:17:47 UTC (rev 277) @@ -2,8 +2,7 @@ class Object(): def __init__(self, data, share): - self.downloader = share['downloader'] - self.master = share['master'] + self.sh = share obj = data['objecttype'] @@ -11,8 +10,6 @@ self.size = [int(i) for i in obj['size']] self.objZorder = int(obj['zorder']) - #self.image = None - #self.imageName = 'default' self.imageD = obj['imageD'] self.imageN = obj['imageN'] self.imageStyle = 'D' @@ -30,7 +27,7 @@ else: name = self.imageN[name] - self.downloader.getImage(name, self.imageUpdate) + self.sh['Downloader'].getImage(name, self.imageUpdate) def imageUpdate(self, image, *arg): @@ -38,7 +35,7 @@ if list(image[1].size) != self.size: self.image[0] = pygame.transform.smoothscale(self.image[0], self.size) - self.master.blit(self.rect) + self.sh['Playground'].blit(self.rect) def update(self, screen, rect): Modified: branches/VP-Grounds/modules/playground.py =================================================================== --- branches/VP-Grounds/modules/playground.py 2009-02-10 19:15:51 UTC (rev 276) +++ branches/VP-Grounds/modules/playground.py 2009-02-10 19:17:47 UTC (rev 277) @@ -4,6 +4,7 @@ class Module(): def __init__(self, share, *arg): self.sh = share + self.sh['Playground'] = self self.dontUpdate = False self.lock = Lock() @@ -77,6 +78,7 @@ if msg['state'] == 'wait': #Wait with updating until all data has arrived self.dontUpdate = True + self.objects = {} elif msg['state'] == 'free': #We're free to update! @@ -93,7 +95,7 @@ user = arg[1] #Is this on our ground? Do we need to update it? if user.has_key('Pos') and user['Pos'] != None: - pass + self.openObject('avatar-' + user['Avatar'][0], 'av-' + user['Name'], user) @@ -108,12 +110,14 @@ screen.blit(self.surf, myPos, rect) #Blit def close(self): - pass + del self.sh['Playground'] def blit(self, rect): if self.dontUpdate == False: self.lock.acquire() + self.createRects() + collidelist = rect.collidedictall(self.rects) collidelist = self.sortObjectList(collidelist) @@ -129,8 +133,6 @@ def loadGround(self, data): self.ground = data - self.objects = {} - #Loading all the objects for name, info in data.items(): if name == '_general': @@ -146,12 +148,8 @@ self.createRects() def openObject(self, objname, name, data): - share = {} - share['downloader'] = self.sh['Downloader'] - share['master'] = self - obj = self.modObjects[objname] - obj = obj(data, share) + obj = obj(data, self.sh) self.objects[name] = obj @@ -171,7 +169,7 @@ def walking(self, direction, speed, keyDown): - #Repeating keys prevention. + #Repeating key prevention. #Check if keyDown was already send to this direction if keyDown == True: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |