From: <Blu...@us...> - 2010-08-31 18:34:42
|
Revision: 382 http://virtplayground.svn.sourceforge.net/virtplayground/?rev=382&view=rev Author: BlueWolf_ Date: 2010-08-31 18:34:36 +0000 (Tue, 31 Aug 2010) Log Message: ----------- Added a transition effect for the playground. Not sure if I like it yet Modified Paths: -------------- trunk/client/playground.py Modified: trunk/client/playground.py =================================================================== --- trunk/client/playground.py 2010-08-31 18:19:41 UTC (rev 381) +++ trunk/client/playground.py 2010-08-31 18:34:36 UTC (rev 382) @@ -20,7 +20,7 @@ class Playground(): def __init__(self): - self.surf = pygame.Surface((1000, 700), SRCALPHA).convert_alpha() + self.surf = pygame.Surface((1000, 700)).convert() self.surf.fill([0,0,0]) self.status = None @@ -78,6 +78,7 @@ if data['status'] != self.status: # Unload data from the playground if self.status != None: + sh['timer'].stop("playground-transit") for name in self.backgrounds.keys(): sh['downloader'].remove_usage(name) self.backgrounds = {} @@ -113,8 +114,10 @@ # Load the data for the playground self.viewport = Rect(0, 0, 1000, 700) self.oldsurf = self.surf.copy() - self.transit = 0 + self.transit = 1 self.playground_render(None, True) + sh['timer'].start("playground-transit", self.timer, \ + time.time()) self.status = data['status'] self.statuswhere = data['where'] @@ -229,6 +232,7 @@ y_max = y_min + 250 * ((float(self.viewport.height) / 250)+1) y_max = int(y_max) + # Find the blocks that are within rect for y in range(y_min, y_max, 250): for x in range(x_min, x_max, 250): bg_rect = Rect(x, y, 250, 250) @@ -243,6 +247,10 @@ self.surf.blit(background, rect, bg_area) + if self.transit != None: # An transition is happening + self.oldsurf.set_alpha(self.transit*255) + self.surf.blit(self.oldsurf, (0,0)) + if doupdate: sh['update'](rect) @@ -260,9 +268,21 @@ "status": "playground", "where": "playground" }) - - - + + def timer(self, name, starttime): + if name == "playground-transit": + length = 1 + timeline = (time.time() - starttime) / length + + if timeline > 1: + self.transit = None + self.playground_render() + return True + + self.transit = 1 - timeline + self.playground_render() + + class LoginFeedback(gui.Feedback): def __init__(self, parent): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |