Permalink
Browse files

fixed coin color

  • Loading branch information...
Alec Goebel
Alec Goebel committed Apr 26, 2012
1 parent ae6d71c commit 890b50514ab9d1f9d641096b831af42526ba4cd0
Showing with 7 additions and 4 deletions.
  1. +7 −4 samplecode/networking_example/coinget/client/sprites/coin.py
@@ -3,24 +3,27 @@
import pygame
from pygame.sprite import Sprite, Group
+from coinget import settings
from coinget import signals
from coinget.world import Coin
-
class CoinSprite(Sprite):
def __init__(self, coin):
Sprite.__init__(self)
self.image = pygame.Surface(coin.rect.size)
self.rect = self.image.get_rect()
- self.image.fill((0,0,0))
- self.image.fill((255,255,0), self.rect.inflate(-4,-4))
-
self.rect.center = coin.rect.center
self.coin = coin
dispatcher.connect(self.kill, signal=signals.DEL_OBJECT, sender=coin)
+ def redraw(self):
+ rect = self.image.get_rect()
+ ratio = 1.0 * self.coin.life / settings.COIN_LIFE
+
+ self.image.fill((0,0,0))
+ self.image.fill((255,255 * ratio,0), rect.inflate(-4,-4))
class CoinGroup(Group):

0 comments on commit 890b505

Please sign in to comment.