From bd2858ce154fb677a146abf98e843c9610429456 Mon Sep 17 00:00:00 2001 From: Nicolas Schodet Date: Fri, 10 May 2013 18:57:04 +0200 Subject: host/simu/robots/apbirthday: update cannon model & view --- host/simu/robots/apbirthday/model/cannon.py | 6 +++--- host/simu/robots/apbirthday/view/robot.py | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'host') diff --git a/host/simu/robots/apbirthday/model/cannon.py b/host/simu/robots/apbirthday/model/cannon.py index 04f26328..cad79a29 100644 --- a/host/simu/robots/apbirthday/model/cannon.py +++ b/host/simu/robots/apbirthday/model/cannon.py @@ -31,8 +31,7 @@ from simu.robots.apbirthday.model import back class Cannon (Observable): - # TODO: update distance with real robot. - cannon_hit = (1000, 80) + cannon_hit = (700, 100) def __init__ (self, table, robot_position, arm_cyl, clamp_cyl, contacts, pot): @@ -96,7 +95,8 @@ class Cannon (Observable): self.notify () def __pot_notified (self): - if self.cherries and self.pot.wiper[0] > 0.5: + self.firing = self.pot.wiper[0] > .5 + if self.cherries and self.firing: m = TransMatrix () m.translate (self.robot_position.pos) m.rotate (self.robot_position.angle) diff --git a/host/simu/robots/apbirthday/view/robot.py b/host/simu/robots/apbirthday/view/robot.py index 96139b9b..16b4878a 100644 --- a/host/simu/robots/apbirthday/view/robot.py +++ b/host/simu/robots/apbirthday/view/robot.py @@ -30,6 +30,7 @@ from simu.robots.apbirthday.model import front, back, side COLOR_ROBOT = '#000000' COLOR_AXES = '#202040' COLOR_CANNON = '#808080' +COLOR_CANNON_FIRE = '#800000' COLOR_BALLON = '#ff0000' class Robot (simu.inter.drawable.Drawable): @@ -79,7 +80,8 @@ class Robot (simu.inter.drawable.Drawable): self.draw_polygon ((front, side), (front, -side), (-back, -side), (-back, 81), (-50, side), fill = COLOR_ROBOT) self.draw_circle ((50, self.cannon_model.cannon_hit[1]), 20, - fill = COLOR_CANNON) + fill = COLOR_CANNON_FIRE if self.cannon_model.firing + else COLOR_CANNON) # Draw Robot axis. self.draw_line ((-50, 0), (50, 0), fill = COLOR_AXES, arrow = 'last') -- cgit v1.2.3