diff options
-rw-r--r-- | apps/plugins/robotfindskitten.c | 61 |
1 files changed, 32 insertions, 29 deletions
diff --git a/apps/plugins/robotfindskitten.c b/apps/plugins/robotfindskitten.c index 844863a972..9fabfcb54f 100644 --- a/apps/plugins/robotfindskitten.c +++ b/apps/plugins/robotfindskitten.c | |||
@@ -152,18 +152,22 @@ static void play_game(void); | |||
152 | static void process_input(int); | 152 | static void process_input(int); |
153 | 153 | ||
154 | /*Helper functions*/ | 154 | /*Helper functions*/ |
155 | static void pause(void); | ||
155 | static int validchar(char); | 156 | static int validchar(char); |
156 | |||
157 | static void play_animation(int); | 157 | static void play_animation(int); |
158 | 158 | ||
159 | /*Global variables. Bite me, it's fun.*/ | 159 | /*Global variables. Bite me, it's fun.*/ |
160 | screen_object robot; | 160 | screen_object robot; |
161 | screen_object kitten; | 161 | screen_object kitten; |
162 | 162 | ||
163 | int num_bogus; | 163 | #if X_MAX*Y_MAX < 200 |
164 | screen_object bogus[MESSAGES]; | 164 | #define NUM_BOGUS 15 |
165 | int bogus_messages[MESSAGES]; | 165 | #else |
166 | int used_messages[MESSAGES]; | 166 | #define NUM_BOGUS 20 |
167 | #endif | ||
168 | screen_object bogus[NUM_BOGUS]; | ||
169 | unsigned short bogus_messages[NUM_BOGUS]; | ||
170 | bool used_messages[MESSAGES]; | ||
167 | 171 | ||
168 | bool exit_rfk; | 172 | bool exit_rfk; |
169 | 173 | ||
@@ -263,9 +267,6 @@ static void play_game() | |||
263 | */ | 267 | */ |
264 | static void process_input(int input) | 268 | static void process_input(int input) |
265 | { | 269 | { |
266 | #ifdef __PLUGINLIB_ACTIONS_H__ | ||
267 | const struct button_mapping *plugin_contexts[] = {generic_directions, generic_actions}; | ||
268 | #endif | ||
269 | int check_x = robot.x; | 270 | int check_x = robot.x; |
270 | int check_y = robot.y; | 271 | int check_y = robot.y; |
271 | 272 | ||
@@ -313,12 +314,7 @@ static void process_input(int input) | |||
313 | case KITTEN: /*Found it!*/ | 314 | case KITTEN: /*Found it!*/ |
314 | play_animation(input); | 315 | play_animation(input); |
315 | /* Wait for the user to click something */ | 316 | /* Wait for the user to click something */ |
316 | rb->button_clear_queue(); | 317 | pause(); |
317 | #ifdef __PLUGINLIB_ACTIONS_H__ | ||
318 | input = pluginlib_getaction(rb, TIMEOUT_BLOCK, plugin_contexts, 2); | ||
319 | #else | ||
320 | input = rb->button_get(true); | ||
321 | #endif | ||
322 | break; | 318 | break; |
323 | default: /*We hit a bogus object; print its message.*/ | 319 | default: /*We hit a bogus object; print its message.*/ |
324 | message(messages[bogus_messages[screen[check_x][check_y]-2]]); | 320 | message(messages[bogus_messages[screen[check_x][check_y]-2]]); |
@@ -346,6 +342,16 @@ static void finish(int sig) | |||
346 | * | 342 | * |
347 | *****************************************************************************/ | 343 | *****************************************************************************/ |
348 | 344 | ||
345 | static void pause() | ||
346 | { | ||
347 | int button; | ||
348 | rb->lcd_update(); | ||
349 | do | ||
350 | button = rb->button_get(true); | ||
351 | while( ( button == BUTTON_NONE ) | ||
352 | || ( button & (BUTTON_REL|BUTTON_REPEAT) ) ); | ||
353 | } | ||
354 | |||
349 | static int validchar(char a) | 355 | static int validchar(char a) |
350 | { | 356 | { |
351 | switch(a) | 357 | switch(a) |
@@ -459,11 +465,14 @@ static void initialize_arrays() | |||
459 | 465 | ||
460 | /*Initialize the other arrays.*/ | 466 | /*Initialize the other arrays.*/ |
461 | for (counter = 0; counter < MESSAGES; counter++) | 467 | for (counter = 0; counter < MESSAGES; counter++) |
462 | { | 468 | { |
463 | used_messages[counter] = 0; | 469 | used_messages[counter] = false; |
464 | bogus_messages[counter] = 0; | 470 | } |
465 | bogus[counter] = empty; | 471 | for (counter = 0; counter < NUM_BOGUS; counter++) |
466 | } | 472 | { |
473 | bogus_messages[counter] = 0; | ||
474 | bogus[counter] = empty; | ||
475 | } | ||
467 | } | 476 | } |
468 | 477 | ||
469 | /*initialize_robot initializes robot.*/ | 478 | /*initialize_robot initializes robot.*/ |
@@ -503,7 +512,7 @@ static void initialize_kitten() | |||
503 | static void initialize_bogus() | 512 | static void initialize_bogus() |
504 | { | 513 | { |
505 | int counter, index; | 514 | int counter, index; |
506 | for (counter = 0; counter < num_bogus; counter++) | 515 | for (counter = 0; counter < NUM_BOGUS; counter++) |
507 | { | 516 | { |
508 | /*Give it a color.*/ | 517 | /*Give it a color.*/ |
509 | bogus[counter].color = colors[randcolor()]; | 518 | bogus[counter].color = colors[randcolor()]; |
@@ -526,9 +535,9 @@ static void initialize_bogus() | |||
526 | /*Find a message for this object.*/ | 535 | /*Find a message for this object.*/ |
527 | do { | 536 | do { |
528 | index = rb->rand() % MESSAGES; | 537 | index = rb->rand() % MESSAGES; |
529 | } while (used_messages[index] != 0); | 538 | } while (used_messages[index] != false); |
530 | bogus_messages[counter] = index; | 539 | bogus_messages[counter] = index; |
531 | used_messages[index] = 1; | 540 | used_messages[index] = true; |
532 | } | 541 | } |
533 | 542 | ||
534 | } | 543 | } |
@@ -566,7 +575,7 @@ static void initialize_screen() | |||
566 | /* | 575 | /* |
567 | *Draw all the objects on the playing field. | 576 | *Draw all the objects on the playing field. |
568 | */ | 577 | */ |
569 | for (counter = 0; counter < num_bogus; counter++) | 578 | for (counter = 0; counter < NUM_BOGUS; counter++) |
570 | { | 579 | { |
571 | draw(bogus[counter]); | 580 | draw(bogus[counter]); |
572 | } | 581 | } |
@@ -584,12 +593,6 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) | |||
584 | (void)parameter; | 593 | (void)parameter; |
585 | rb = api; | 594 | rb = api; |
586 | 595 | ||
587 | /* Get a number of non-kitten objects */ | ||
588 | #if X_MAX*Y_MAX < 200 | ||
589 | num_bogus = 15; | ||
590 | #else | ||
591 | num_bogus = 20; | ||
592 | #endif | ||
593 | exit_rfk = false; | 596 | exit_rfk = false; |
594 | 597 | ||
595 | rb->srand(*rb->current_tick); | 598 | rb->srand(*rb->current_tick); |