summaryrefslogtreecommitdiff
path: root/test.py
diff options
context:
space:
mode:
authorFlorian Jung <flo@windfisch.org>2015-08-09 23:45:23 +0200
committerFlorian Jung <flo@windfisch.org>2015-08-09 23:45:23 +0200
commit9830c309d355d083218375c16bf311071741f3fb (patch)
treeb723265e85acf3e637d64f7a382c2e2125145f91 /test.py
parent94af883aa6fa75da3ed09a464874a644994b0828 (diff)
draw_world_border() function
Diffstat (limited to 'test.py')
-rw-r--r--test.py28
1 files changed, 16 insertions, 12 deletions
diff --git a/test.py b/test.py
index 9603571..ad290ac 100644
--- a/test.py
+++ b/test.py
@@ -125,7 +125,7 @@ def generateVirus(spikes, spike_length, radius, global_coords):
points.append(t);
return points
-def initializeFont():
+def initializeFont():
if font_fallback:
pygame.font.init()
else:
@@ -184,6 +184,17 @@ def draw_leaderboard():
screen.blit(surface, (5, next_y))
next_y += surface.get_height()+5
+def draw_world_borders():
+ 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)
+
+ 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))
+ if (left >= 0): gfxdraw.vline(screen, left, 0, screensize[1], (0,0,0))
+ if (right <= screensize[0]): gfxdraw.vline(screen, right, 0, screensize[1], (0,0,0))
+
sub = MeinSubskribierer()
c = client.Client(sub)
@@ -209,19 +220,11 @@ zoom = calc_zoom()
while True:
pygame.event.pump()
clock.tick()
- screen.fill((255,255,255))
-
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)
-
- 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))
- if (left >= 0): gfxdraw.vline(screen, left, 0, screensize[1], (0,0,0))
- if (right <= screensize[0]): gfxdraw.vline(screen, right, 0, screensize[1], (0,0,0))
+ screen.fill((255,255,255))
+ draw_world_borders()
for cell in c.world.cells.values():
drawCell(cell)
@@ -262,4 +265,5 @@ while True:
if event.type == MOUSEMOTION:
if movement:
c.send_target(*win_to_world_pt(event.pos, c.player.center))
+
pygame.display.update()