From 73f25d3310706c5d7a559f120805c54860b16795 Mon Sep 17 00:00:00 2001 From: Nicolas Schodet Date: Sun, 15 May 2011 20:14:12 +0200 Subject: host/simu/robots/robospierre: add tower management --- host/simu/view/table_eurobot2011.py | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) (limited to 'host/simu/view') diff --git a/host/simu/view/table_eurobot2011.py b/host/simu/view/table_eurobot2011.py index f0a65ce1..5725e5b8 100644 --- a/host/simu/view/table_eurobot2011.py +++ b/host/simu/view/table_eurobot2011.py @@ -31,17 +31,25 @@ GREEN = '#268126' BLACK = '#181818' YELLOW = '#cccc00' -def draw_pawn (d, radius, kind): - d.draw_circle ((0, 0), radius, fill = YELLOW) - if kind == 'king': - a = 0.1 * radius - b = 0.5 * radius - d.draw_line ((a, b), (a, a), (b, a), (b, -a), (a, -a), (a, -b), - (-a, -b), (-a, -a), (-b, -a), (-b, a), (-a, a), (-a, b), - (a, b)) - elif kind == 'queen': - d.draw_circle ((0, 0), 0.5 * radius) - d.draw_circle ((0, 0), 0.4 * radius) +def draw_pawn (d, pawn): + d.trans_push () + if pawn.kind == 'tower': + pawns = pawn.tower + else: + pawns = (pawn, ) + for p in pawns: + d.draw_circle ((0, 0), p.radius, fill = YELLOW) + if p.kind == 'king': + a = 0.1 * p.radius + b = 0.5 * p.radius + d.draw_line ((a, b), (a, a), (b, a), (b, -a), (a, -a), (a, -b), + (-a, -b), (-a, -a), (-b, -a), (-b, a), (-a, a), (-a, b), + (a, b)) + elif p.kind == 'queen': + d.draw_circle ((0, 0), 0.5 * p.radius) + d.draw_circle ((0, 0), 0.4 * p.radius) + d.trans_scale (0.95) + d.trans_pop () class Pawn (Drawable): @@ -59,7 +67,7 @@ class Pawn (Drawable): self.reset () if self.pos: self.trans_translate (self.pos) - draw_pawn (self, self.model.radius, self.model.kind) + draw_pawn (self, self.model) Drawable.draw (self) class Table (Drawable): -- cgit v1.2.3