summaryrefslogtreecommitdiffhomepage
path: root/digital
diff options
context:
space:
mode:
Diffstat (limited to 'digital')
-rw-r--r--digital/io-hub/src/guybrush/main.c21
-rw-r--r--digital/io-hub/src/guybrush/playground_2012.h4
2 files changed, 24 insertions, 1 deletions
diff --git a/digital/io-hub/src/guybrush/main.c b/digital/io-hub/src/guybrush/main.c
index 2ea97110..ac561ec6 100644
--- a/digital/io-hub/src/guybrush/main.c
+++ b/digital/io-hub/src/guybrush/main.c
@@ -212,7 +212,26 @@ main_coin_detected_ok (void)
int16_t limit = robot_pos.v.y < PG_LENGTH - PG_CAPTAIN_ROOM_LENGTH_MM
? PG_HOLD_NORTH_X + BOT_SIZE_FRONT
: PG_CAPTAIN_ROOM_LENGTH_MM + BOT_SIZE_FRONT;
- return robot_pos.v.x > limit && robot_pos.v.x < PG_MIRROR_X (limit);
+ if (robot_pos.v.x < limit || robot_pos.v.x > PG_MIRROR_X (limit))
+ return 0;
+ if (robot_pos.v.y > PG_COIN_QUARTET_Y - 100
+ && robot_pos.v.y < PG_COIN_QUARTET_Y + 100)
+ {
+ if (robot_pos.a < POSITION_A_DEG (90)
+ || robot_pos.a > POSITION_A_DEG (270))
+ {
+ if (robot_pos.v.x > PG_COIN_QUARTET_X - BOT_SIZE_FRONT - 170
+ && robot_pos.v.x < PG_COIN_QUARTET_X - BOT_SIZE_FRONT + 170)
+ return 0;
+ }
+ else
+ {
+ if (robot_pos.v.x > PG_COIN_QUARTET_X + BOT_SIZE_FRONT - 170
+ && robot_pos.v.x < PG_COIN_QUARTET_X + BOT_SIZE_FRONT + 170)
+ return 0;
+ }
+ }
+ return 1;
}
/** Main events management. */
diff --git a/digital/io-hub/src/guybrush/playground_2012.h b/digital/io-hub/src/guybrush/playground_2012.h
index d33ed472..571ffc09 100644
--- a/digital/io-hub/src/guybrush/playground_2012.h
+++ b/digital/io-hub/src/guybrush/playground_2012.h
@@ -62,4 +62,8 @@
#define PG_BOTTLE2_X PG_MIRROR_X (PG_BOTTLE1_X)
#define PG_BOTTLE3_X PG_MIRROR_X (PG_BOTTLE0_X)
+/** 4 coins. */
+#define PG_COIN_QUARTET_X (PG_WIDTH / 2)
+#define PG_COIN_QUARTET_Y 300
+
#endif /* playground_2012_h */