diff options
author | Ben Basha <benbasha@rockbox.org> | 2006-02-17 16:02:37 +0000 |
---|---|---|
committer | Ben Basha <benbasha@rockbox.org> | 2006-02-17 16:02:37 +0000 |
commit | 9131c4a326b7c6b0cd8905c5bfb1f0f62648bf29 (patch) | |
tree | 07b85931eb9a8ded8f4b3f2824f3c7529e6363f1 | |
parent | 57654d443b36aff374c6a92a29654f8398022146 (diff) | |
download | rockbox-9131c4a326b7c6b0cd8905c5bfb1f0f62648bf29.tar.gz rockbox-9131c4a326b7c6b0cd8905c5bfb1f0f62648bf29.zip |
*Side flickering bug fixed. *Continue game bug fixed. + Added sleep timer counting the score.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8714 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | apps/plugins/brickmania.c | 72 |
1 files changed, 53 insertions, 19 deletions
diff --git a/apps/plugins/brickmania.c b/apps/plugins/brickmania.c index 653d00d975..074051d2fe 100644 --- a/apps/plugins/brickmania.c +++ b/apps/plugins/brickmania.c | |||
@@ -439,7 +439,9 @@ static unsigned char levels[29][8][10] = { | |||
439 | } | 439 | } |
440 | }; | 440 | }; |
441 | 441 | ||
442 | int pad_pos_x,x,y; | 442 | #define MAX_BALLS 10 |
443 | int pad_pos_x; | ||
444 | int x[MAX_BALLS],y[MAX_BALLS]; | ||
443 | int life; | 445 | int life; |
444 | int start_game,con_game; | 446 | int start_game,con_game; |
445 | int pad_type; | 447 | int pad_type; |
@@ -470,7 +472,6 @@ typedef struct balls { | |||
470 | bool glue; | 472 | bool glue; |
471 | } balls; | 473 | } balls; |
472 | 474 | ||
473 | #define MAX_BALLS 10 | ||
474 | balls ball[MAX_BALLS]; | 475 | balls ball[MAX_BALLS]; |
475 | 476 | ||
476 | typedef struct sfire { | 477 | typedef struct sfire { |
@@ -535,12 +536,34 @@ void int_game(int new_game) | |||
535 | 536 | ||
536 | } | 537 | } |
537 | 538 | ||
539 | int sw,i,w; | ||
538 | 540 | ||
539 | #define HIGH_SCORE "highscore.cfg" | 541 | /* sleep timer counting the score */ |
542 | void sleep (int secs) { | ||
543 | bool done=false; | ||
544 | char s[20]; | ||
545 | int count=0; | ||
546 | |||
547 | while (!done) { | ||
548 | |||
549 | if (vscore<score) { | ||
550 | vscore++; | ||
551 | rb->snprintf(s, sizeof(s), "%d", vscore); | ||
552 | rb->lcd_getstringsize(s, &sw, NULL); | ||
553 | rb->lcd_putsxy(LCD_WIDTH/2-sw/2, 2, s); | ||
554 | rb->lcd_update(); | ||
555 | } else { | ||
556 | if (count==0) count=*rb->current_tick+HZ*secs; | ||
557 | if (*rb->current_tick>=count) | ||
558 | done=true; | ||
559 | } | ||
560 | } | ||
561 | |||
562 | } | ||
540 | 563 | ||
541 | #define MENU_LENGTH 4 | ||
542 | int sw,i,w; | ||
543 | 564 | ||
565 | #define HIGH_SCORE "highscore.cfg" | ||
566 | #define MENU_LENGTH 4 | ||
544 | int game_menu(int when) | 567 | int game_menu(int when) |
545 | { | 568 | { |
546 | int button,cur=0; | 569 | int button,cur=0; |
@@ -847,7 +870,7 @@ int game_loop(void){ | |||
847 | life--; | 870 | life--; |
848 | if (life>=0) { | 871 | if (life>=0) { |
849 | int_game(0); | 872 | int_game(0); |
850 | rb->sleep(HZ*2); | 873 | sleep(2); |
851 | } | 874 | } |
852 | break; | 875 | break; |
853 | case 2: | 876 | case 2: |
@@ -1038,14 +1061,16 @@ int game_loop(void){ | |||
1038 | life--; | 1061 | life--; |
1039 | if (life>=0){ | 1062 | if (life>=0){ |
1040 | int_game(0); | 1063 | int_game(0); |
1041 | rb->sleep(HZ*2); | 1064 | sleep(2); |
1042 | } | 1065 | } |
1043 | } | 1066 | } |
1044 | } | 1067 | } |
1045 | 1068 | ||
1046 | /* left line ,right line */ | 1069 | /* left line ,right line */ |
1047 | if ((ball[k].pos_x <= 0) || (ball[k].pos_x+BALL >= LCD_WIDTH)) | 1070 | if ((ball[k].pos_x <= 0) || (ball[k].pos_x+BALL >= LCD_WIDTH)){ |
1048 | ball[k].x = ball[k].x*-1; | 1071 | ball[k].x = ball[k].x*-1; |
1072 | ball[k].pos_x = ball[k].pos_x <= 0 ? 0 : LCD_WIDTH-BALL; | ||
1073 | } | ||
1049 | 1074 | ||
1050 | if ((ball[k].pos_y+5 >= PAD_POS_Y && (ball[k].pos_x >= pad_pos_x && ball[k].pos_x <= pad_pos_x+PAD_WIDTH)) && | 1075 | if ((ball[k].pos_y+5 >= PAD_POS_Y && (ball[k].pos_x >= pad_pos_x && ball[k].pos_x <= pad_pos_x+PAD_WIDTH)) && |
1051 | start_game != 1 && !ball[k].glue) { | 1076 | start_game != 1 && !ball[k].glue) { |
@@ -1092,10 +1117,10 @@ int game_loop(void){ | |||
1092 | 1117 | ||
1093 | if (brick_on_board < 0) { | 1118 | if (brick_on_board < 0) { |
1094 | if (cur_level+1<levels_num) { | 1119 | if (cur_level+1<levels_num) { |
1095 | rb->sleep(HZ * 2); | ||
1096 | cur_level++; | 1120 | cur_level++; |
1097 | score+=100; | 1121 | score+=100; |
1098 | int_game(1); | 1122 | int_game(1); |
1123 | sleep(2); | ||
1099 | } else { | 1124 | } else { |
1100 | rb->lcd_getstringsize("Congratulations!", &sw, NULL); | 1125 | rb->lcd_getstringsize("Congratulations!", &sw, NULL); |
1101 | rb->lcd_putsxy(LCD_WIDTH/2-sw/2, 140, "Congratulations!"); | 1126 | rb->lcd_putsxy(LCD_WIDTH/2-sw/2, 140, "Congratulations!"); |
@@ -1104,11 +1129,11 @@ int game_loop(void){ | |||
1104 | vscore=score; | 1129 | vscore=score; |
1105 | rb->lcd_update(); | 1130 | rb->lcd_update(); |
1106 | if (score>highscore) { | 1131 | if (score>highscore) { |
1107 | rb->sleep(HZ*2); | 1132 | sleep(2); |
1108 | highscore=score; | 1133 | highscore=score; |
1109 | rb->splash(HZ*2,true,"New High Score"); | 1134 | rb->splash(HZ*2,true,"New High Score"); |
1110 | } else { | 1135 | } else { |
1111 | rb->sleep(HZ * 4); | 1136 | sleep(3); |
1112 | } | 1137 | } |
1113 | 1138 | ||
1114 | switch(game_menu(0)){ | 1139 | switch(game_menu(0)){ |
@@ -1174,8 +1199,15 @@ int game_loop(void){ | |||
1174 | } | 1199 | } |
1175 | start_game =0; | 1200 | start_game =0; |
1176 | } else if (pad_type==1) { | 1201 | } else if (pad_type==1) { |
1177 | for(k=0;k<used_balls;k++) | 1202 | for(k=0;k<used_balls;k++) { |
1178 | ball[k].glue=false; | 1203 | if (ball[k].glue) |
1204 | ball[k].glue=false; | ||
1205 | else { | ||
1206 | ball[k].x = x[k]; | ||
1207 | ball[k].y = y[k]; | ||
1208 | } | ||
1209 | } | ||
1210 | |||
1179 | if (start_game!=1 && con_game==1) { | 1211 | if (start_game!=1 && con_game==1) { |
1180 | start_game =0; | 1212 | start_game =0; |
1181 | con_game=0; | 1213 | con_game=0; |
@@ -1190,8 +1222,8 @@ int game_loop(void){ | |||
1190 | fire[tfire].left=pad_pos_x+PAD_WIDTH-1; | 1222 | fire[tfire].left=pad_pos_x+PAD_WIDTH-1; |
1191 | } else if (con_game==1 && start_game!=1) { | 1223 | } else if (con_game==1 && start_game!=1) { |
1192 | for(k=0;k<used_balls;k++){ | 1224 | for(k=0;k<used_balls;k++){ |
1193 | ball[k].x=x; | 1225 | ball[k].x=x[k]; |
1194 | ball[k].y=y; | 1226 | ball[k].y=y[k]; |
1195 | } | 1227 | } |
1196 | con_game=0; | 1228 | con_game=0; |
1197 | } | 1229 | } |
@@ -1215,23 +1247,25 @@ int game_loop(void){ | |||
1215 | return 1; | 1247 | return 1; |
1216 | break; | 1248 | break; |
1217 | }; | 1249 | }; |
1250 | |||
1218 | for(k=0;k<used_balls;k++){ | 1251 | for(k=0;k<used_balls;k++){ |
1219 | if (ball[k].x!=0) x=ball[k].x; | 1252 | if (ball[k].x!=0) x[k]=ball[k].x; |
1220 | ball[k].x=0; | 1253 | ball[k].x=0; |
1221 | if (ball[k].y!=0) y=ball[k].y; | 1254 | if (ball[k].y!=0) y[k]=ball[k].y; |
1222 | ball[k].y=0; | 1255 | ball[k].y=0; |
1223 | } | 1256 | } |
1257 | |||
1224 | break; | 1258 | break; |
1225 | } | 1259 | } |
1226 | } else { | 1260 | } else { |
1227 | rb->lcd_bitmap(brickmania_gameover,LCD_WIDTH/2-55,LCD_HEIGHT-87,110,52); | 1261 | rb->lcd_bitmap(brickmania_gameover,LCD_WIDTH/2-55,LCD_HEIGHT-87,110,52); |
1228 | rb->lcd_update(); | 1262 | rb->lcd_update(); |
1229 | if (score>highscore) { | 1263 | if (score>highscore) { |
1230 | rb->sleep(HZ*2); | 1264 | sleep(2); |
1231 | highscore=score; | 1265 | highscore=score; |
1232 | rb->splash(HZ*2,true,"New High Score"); | 1266 | rb->splash(HZ*2,true,"New High Score"); |
1233 | } else { | 1267 | } else { |
1234 | rb->sleep(HZ * 3); | 1268 | sleep(3); |
1235 | } | 1269 | } |
1236 | 1270 | ||
1237 | for(k=0;k<used_balls;k++){ | 1271 | for(k=0;k<used_balls;k++){ |