From afdad624ffcd83d8f17ead0cb6a1fa0c7c436704 Mon Sep 17 00:00:00 2001 From: Nicolas Schodet Date: Fri, 18 May 2012 10:43:19 +0200 Subject: digital/io-hub/src/guybrush: slow down coin quartet collection --- digital/io-hub/src/guybrush/main.c | 21 ++++++++++++++++++++- digital/io-hub/src/guybrush/playground_2012.h | 4 ++++ 2 files changed, 24 insertions(+), 1 deletion(-) (limited to 'digital/io-hub') 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 */ -- cgit v1.2.3