summaryrefslogtreecommitdiffhomepage
path: root/host
diff options
context:
space:
mode:
authorNicolas Schodet2013-05-10 18:57:04 +0200
committerNicolas Schodet2013-05-10 18:57:04 +0200
commitbd2858ce154fb677a146abf98e843c9610429456 (patch)
tree4ee57b09b5154a3dbefa2b38acb3fc27c949c956 /host
parente4442bb23654930f4bc50ad48082815ee59ba46c (diff)
host/simu/robots/apbirthday: update cannon model & view
Diffstat (limited to 'host')
-rw-r--r--host/simu/robots/apbirthday/model/cannon.py6
-rw-r--r--host/simu/robots/apbirthday/view/robot.py4
2 files changed, 6 insertions, 4 deletions
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')