Skip to content

Commit

Permalink
Added .rect, .fill_rect, .line and .text commands to python debug client
Browse files Browse the repository at this point in the history
  • Loading branch information
Vasily committed Nov 16, 2015
1 parent 36b683d commit 11d01fd
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
1 change: 1 addition & 0 deletions clients/python2/MyStrategy.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def move(self, me, world, game, move):
dbg.circle(game.world_width * game.track_tile_size - 100,
game.world_height * game.track_tile_size - 100,
50.0, self.GREEN)
dbg.text(me.x, me.y, 'wooo!', (0.0, 0.0, 1.0))

move.engine_power = 1.0
move.throw_projectile = True
Expand Down
22 changes: 18 additions & 4 deletions clients/python2/debug_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,28 @@ def __make_color(color):
return Color(r=color[0], g=color[1], b=color[2])
return color

def __send_command(self, cmd, color, *args):
def __send_command(self, cmd, color, args, pattern=None):
assert self.mode != self.MODE_UNKNOWN
color = self.__make_color(color)
pattern = '%s' + (' %f' * len(args)) + ' %f %f %f\n'
if not pattern:
pattern = '%s' + (' %f' * len(args)) + ' %f %f %f\n'
self.socket.sendall(pattern % ((cmd,) + args + color))

def circle(self, x0, y0, r0, color):
self.__send_command('circle', color, x0, y0, r0)
self.__send_command('circle', color, args=(x0, y0, r0))

def fill_circle(self, x0, y0, r0, color):
self.__send_command('fill_circle', color, x0, y0, r0)
self.__send_command('fill_circle', color, args=(x0, y0, r0))

def rect(self, x0, y0, x1, y1, color):
self.__send_command('rect', color, args=(x0, y0, x1, y1))

def fill_rect(self, x0, y0, x1, y1, color):
self.__send_command('fill_rect', color, args=(x0, y0, x1, y1))

def line(self, x0, y0, x1, y1, color):
self.__send_command('line', color, args=(x0, y0, x1, y1))

def text(self, x0, y0, msg, color):
self.__send_command('text', color, args=(x0, y0, msg),
pattern='%s %f %f %s %f %f %f\n')

0 comments on commit 11d01fd

Please sign in to comment.