diff options
author | SpitfireX <timm.weber@me.com> | 2015-08-08 19:46:20 +0200 |
---|---|---|
committer | SpitfireX <timm.weber@me.com> | 2015-08-08 19:46:20 +0200 |
commit | 48339d2e33b2e00a04c591c93fe6f2caac6b8ca9 (patch) | |
tree | bef9098df93715218908f45c1e93ba9380350589 /test.py | |
parent | 5230e79cb82ca673cfa63ded56a2628bcb0042cf (diff) |
Fixed buggy event handling
Events were polled at two different places which broke the window
resizing.
Diffstat (limited to 'test.py')
-rw-r--r-- | test.py | 22 |
1 files changed, 8 insertions, 14 deletions
@@ -194,20 +194,11 @@ c.send_spectate() screensize=(800,600) screen=pygame.display.set_mode(screensize,HWSURFACE|DOUBLEBUF|RESIZABLE) zoom = calc_zoom() - i=0 - mb=pygame.mouse.get_pressed() while True: pygame.event.pump() - - for event in pygame.event.get(): - if event.type==VIDEORESIZE: - screensize = event.dict['size'] - screen=pygame.display.set_mode(screensize,HWSURFACE|DOUBLEBUF|RESIZABLE) - zoom = calc_zoom() - pygame.display.update() i=i+1 print(i) @@ -216,14 +207,13 @@ while True: screen.fill((255,255,255)) - c.on_message() + c.on_message() - top = int((c.world.top_left[0] - c.player.center[1])*zoom + screensize[1]/2) left = int((c.world.top_left[1] - c.player.center[0])*zoom + screensize[0]/2) bottom = int((c.world.bottom_right[0] - c.player.center[1])*zoom + screensize[1]/2) right = int((c.world.bottom_right[1] - c.player.center[0])*zoom + screensize[0]/2) - + print ((top,bottom,left,right)) if (top >= 0): gfxdraw.hline(screen, 0, screensize[0], top, (0,0,0)) if (bottom <= screensize[1]): gfxdraw.hline(screen, 0, screensize[0], bottom, (0,0,0)) @@ -259,6 +249,11 @@ while True: events = pygame.event.get() for event in events: + if event.type==VIDEORESIZE: + screensize = event.dict['size'] + screen=pygame.display.set_mode(screensize,HWSURFACE|DOUBLEBUF|RESIZABLE) + zoom = calc_zoom() + pygame.display.update() if event.type == pygame.KEYDOWN: if event.key == pygame.K_r: c.send_respawn() @@ -268,5 +263,4 @@ while True: if event.key == pygame.K_ESCAPE: pygame.quit() - pygame.display.update() - + pygame.display.update()
\ No newline at end of file |