Skip to content

Commit

Permalink
Nice cell names and sizes
Browse files Browse the repository at this point in the history
  • Loading branch information
xzfc committed Jul 28, 2015
1 parent 04b8d79 commit 749496b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
9 changes: 5 additions & 4 deletions agario_gtk/draw_cells.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ def on_draw_cells(self, c, w):
for cell in w.world.cells.values():
if cell.name:
pos = w.world_to_screen_pos(cell.pos)
draw_text_center(c, pos, '%s' % cell.name)
size = w.world_to_screen_size(max(0.3*cell.size, 24))
draw_text_center(c, pos, '%s' % cell.name, size=size, outline=(BLACK, 2))


class RemergeTimes(Subscriber):
Expand Down Expand Up @@ -51,9 +52,9 @@ def on_draw_cells(self, c, w):
continue
pos = w.world_to_screen_pos(cell.pos)
if cell.name:
pos.iadd(Vec(0, 12))
text = '%i mass' % cell.mass
draw_text_center(c, pos, text)
nameSize = w.world_to_screen_size(max(0.3*cell.size, 24))
pos.iadd(Vec(0, nameSize//2+2))
draw_text_center(c, pos, '%i' % cell.mass, outline=(BLACK, 2), size=15)


class CellHostility(Subscriber):
Expand Down
3 changes: 3 additions & 0 deletions agario_gtk/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ def screen_to_world_pos(self, screen_pos):
return (screen_pos - self.screen_center) \
.idiv(self.screen_scale).iadd(self.world_center)

def world_to_screen_size(self, world_size):
return world_size * self.screen_scale

def recalculate(self):
alloc = self.drawing_area.get_allocation()
self.win_size.set(alloc.width, alloc.height)
Expand Down

0 comments on commit 749496b

Please sign in to comment.