summaryrefslogtreecommitdiff
path: root/apps/plugins/robotfindskitten.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/robotfindskitten.c')
-rw-r--r--apps/plugins/robotfindskitten.c49
1 files changed, 14 insertions, 35 deletions
diff --git a/apps/plugins/robotfindskitten.c b/apps/plugins/robotfindskitten.c
index 1010531951..ed3cda2fc7 100644
--- a/apps/plugins/robotfindskitten.c
+++ b/apps/plugins/robotfindskitten.c
@@ -30,6 +30,7 @@
30 30
31#include "plugin.h" 31#include "plugin.h"
32#include "lib/pluginlib_actions.h" 32#include "lib/pluginlib_actions.h"
33#include "lib/display_text.h"
33 34
34/* This macros must always be included. Should be placed at the top by 35/* This macros must always be included. Should be placed at the top by
35 convention, although the actual position doesn't matter */ 36 convention, although the actual position doesn't matter */
@@ -692,7 +693,7 @@ static void play_game()
692#else 693#else
693 input = rb->button_get(true); 694 input = rb->button_get(true);
694#endif 695#endif
695 } 696 }
696 message("Bye!"); 697 message("Bye!");
697 refresh(); 698 refresh();
698} 699}
@@ -794,7 +795,7 @@ static int validchar(char a)
794 switch(a) 795 switch(a)
795 { 796 {
796 case '#': 797 case '#':
797 case ' ': 798 case ' ':
798 case 127: 799 case 127:
799 return 0; 800 return 0;
800 } 801 }
@@ -850,45 +851,23 @@ static void play_animation(int input)
850 851
851static void instructions() 852static void instructions()
852{ 853{
853#define MARGIN 2 854#define WORDS (sizeof help_text / sizeof (char*))
854 int y = MARGIN, space_w, width, height; 855 static char* help_text[] = {
855 unsigned short x = MARGIN, i = 0;
856#define WORDS (sizeof instructions / sizeof (char*))
857 static char* instructions[] = {
858#if 0 856#if 0
859 /* Not sure if we want to include this? */ 857 /* Not sure if we want to include this? */
860 "robotfindskitten", RFK_VERSION, "", "", 858 "robotfindskitten", RFK_VERSION, "", "",
861 "By", "the", "illustrious", "Leonard", "Richardson", "(C)", "1997,", "2000", "", 859 "By", "the", "illustrious", "Leonard", "Richardson", "(C)", "1997,", "2000", "",
862 "Written", "originally", "for", "the", "Nerth", "Pork", "robotfindskitten", "contest", "", "", 860 "Written", "originally", "for", "the", "Nerth", "Pork", "robotfindskitten", "contest", "", "",
863#endif 861#endif
864 "In", "this", "game", "you", "are", "robot", "(#).", "Your", "job", "is", "to", "find", "kitten.", "This", "task", "is", "complicated", "by", "the", "existence", "of", "various", "things", "which", "are", "not", "kitten.", "Robot", "must", "touch", "items", "to", "determine", "if", "they", "are", "kitten", "or", "not.", "", 862 "In", "this", "game", "you", "are", "robot", "(#).", "Your", "job", "is",
863 "to", "find", "kitten.", "This", "task", "is", "complicated", "by", "the",
864 "existence", "of", "various", "things", "which", "are", "not", "kitten.",
865 "Robot", "must", "touch", "items", "to", "determine", "if", "they", "are",
866 "kitten", "or", "not.", "",
865 "The", "game", "ends", "when", "robotfindskitten.", "", "", 867 "The", "game", "ends", "when", "robotfindskitten.", "", "",
866 "Press", "any", "key", "to", "start", 868 "Press", "any", "key", "to", "start",
867 }; 869 };
868 rb->lcd_clear_display(); 870 display_text(WORDS, help_text, NULL, NULL);
869 rb->lcd_getstringsize(" ", &space_w, &height);
870 for (i = 0; i < WORDS; i++) {
871 rb->lcd_getstringsize(instructions[i], &width, NULL);
872 /* Skip to next line if the current one can't fit the word */
873 if (x + width > LCD_WIDTH - MARGIN) {
874 x = MARGIN;
875 y += height;
876 }
877 /* .. or if the word is the empty string */
878 if (rb->strcmp(instructions[i], "") == 0) {
879 x = MARGIN;
880 y += height;
881 continue;
882 }
883 /* We filled the screen */
884 if (y + height > LCD_HEIGHT - MARGIN) {
885 y = MARGIN;
886 pause();
887 rb->lcd_clear_display();
888 }
889 rb->lcd_putsxy(x, y, instructions[i]);
890 x += width + space_w;
891 }
892 pause(); 871 pause();
893} 872}
894 873
@@ -953,7 +932,7 @@ static void initialize_kitten()
953 /*Assign the kitten a character and a color.*/ 932 /*Assign the kitten a character and a color.*/
954 do { 933 do {
955 kitten.character = randchar(); 934 kitten.character = randchar();
956 } while (!(validchar(kitten.character))); 935 } while (!(validchar(kitten.character)));
957 screen[kitten.x][kitten.y] = KITTEN; 936 screen[kitten.x][kitten.y] = KITTEN;
958 937
959 kitten.color = colors[randcolor()]; 938 kitten.color = colors[randcolor()];
@@ -973,7 +952,7 @@ static void initialize_bogus()
973 /*Give it a character.*/ 952 /*Give it a character.*/
974 do { 953 do {
975 bogus[counter].character = randchar(); 954 bogus[counter].character = randchar();
976 } while (!(validchar(bogus[counter].character))); 955 } while (!(validchar(bogus[counter].character)));
977 956
978 /*Give it a position.*/ 957 /*Give it a position.*/
979 do { 958 do {
@@ -1059,7 +1038,7 @@ enum plugin_status plugin_start(const void* parameter)
1059 /* 1038 /*
1060 * Run the game 1039 * Run the game
1061 */ 1040 */
1062 instructions(); 1041 instructions();
1063 1042
1064 initialize_screen(); 1043 initialize_screen();
1065 1044