Mercurial > zrpn
changeset 69:3f1b3699faf2
Sorted label rendering
| author | Michael Rochseter <m.rochester93@googlemail.com> |
|---|---|
| date | Sun, 08 Jul 2012 11:35:52 +0200 |
| parents | 5c367b82fdf0 |
| children | acefa2e2ad36 d7875b63f525 |
| files | zrpn/client.py zrpn/display.py |
| diffstat | 2 files changed, 17 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/zrpn/client.py Sun Jul 08 11:23:01 2012 +0200 +++ b/zrpn/client.py Sun Jul 08 11:35:52 2012 +0200 @@ -12,20 +12,24 @@ import sgc +import time + class Client(object): def __init__(self, address, port): self.display = display.Display() self.connected = False self.client = net.Client() self.connection = self.client.connect(address, port) - self.lbl_time=sgc.Label(pos=(0,0),text="time wasted=\n0") - self.lbl_score=sgc.Label(pos=(0,0),text="score=0") - self.lbl_highscore = sgc.Label(pos=(0,0),text="First=0") + self.lbl_time=sgc.Label(pos=(0,0),text="time\nwasted=\n0") + self.lbl_score=sgc.Label(pos=(0,70),text="score=0") + self.lbl_highscore = sgc.Label(pos=(0,100),text="First=0") - w=[self.lbl_time,self.lbl_score,self.lbl_score] + w=[self.lbl_time,self.lbl_score,self.lbl_highscore] - self.container=sgc.Container((50,600),pos=(700,0),widgets=w) + self.container=sgc.Container((80,600),pos=(720,0),widgets=w) self.container.add(0) + self.start = time.time() + self.x = 0 def run(self): while True: @@ -43,6 +47,11 @@ elif event.p_type == packets.ANIMATIONS: self.display.do_animations(event.packet.animations) self.client.step() + t = time.time() - self.start + self.lbl_time.config(text="time\nwasted=\n"+str(t)) + + self.x=self.x+1 + self.lbl_score.config(text="score="+str(self.x)) self.display.frame()
--- a/zrpn/display.py Sun Jul 08 11:23:01 2012 +0200 +++ b/zrpn/display.py Sun Jul 08 11:35:52 2012 +0200 @@ -19,7 +19,7 @@ self.sprites = pygame.sprite.LayeredDirty() self.cids = {} self.clock = pygame.time.Clock() - + self.sgc_rect=((720,0),(800,200)) def load_board(self, board, board_ids): for y, line in enumerate(board): @@ -47,6 +47,8 @@ self.sprites.update() dirty = self.sprites.draw(self.screen) time = self.clock.tick(15) + self.screen.fill((0x33, 0x33, 0x33),self.sgc_rect) sgc.update(time) + dirty.append(self.sgc_rect) pygame.display.update(dirty)
