From 9131c4a326b7c6b0cd8905c5bfb1f0f62648bf29 Mon Sep 17 00:00:00 2001 From: Ben Basha Date: Fri, 17 Feb 2006 16:02:37 +0000 Subject: *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 --- apps/plugins/brickmania.c | 72 ++++++++++++++++++++++++++++++++++------------- 1 file 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] = { } }; -int pad_pos_x,x,y; +#define MAX_BALLS 10 +int pad_pos_x; +int x[MAX_BALLS],y[MAX_BALLS]; int life; int start_game,con_game; int pad_type; @@ -470,7 +472,6 @@ typedef struct balls { bool glue; } balls; -#define MAX_BALLS 10 balls ball[MAX_BALLS]; typedef struct sfire { @@ -535,12 +536,34 @@ void int_game(int new_game) } +int sw,i,w; -#define HIGH_SCORE "highscore.cfg" +/* sleep timer counting the score */ +void sleep (int secs) { + bool done=false; + char s[20]; + int count=0; + + while (!done) { + + if (vscoresnprintf(s, sizeof(s), "%d", vscore); + rb->lcd_getstringsize(s, &sw, NULL); + rb->lcd_putsxy(LCD_WIDTH/2-sw/2, 2, s); + rb->lcd_update(); + } else { + if (count==0) count=*rb->current_tick+HZ*secs; + if (*rb->current_tick>=count) + done=true; + } + } + +} -#define MENU_LENGTH 4 -int sw,i,w; +#define HIGH_SCORE "highscore.cfg" +#define MENU_LENGTH 4 int game_menu(int when) { int button,cur=0; @@ -847,7 +870,7 @@ int game_loop(void){ life--; if (life>=0) { int_game(0); - rb->sleep(HZ*2); + sleep(2); } break; case 2: @@ -1038,14 +1061,16 @@ int game_loop(void){ life--; if (life>=0){ int_game(0); - rb->sleep(HZ*2); + sleep(2); } } } /* left line ,right line */ - if ((ball[k].pos_x <= 0) || (ball[k].pos_x+BALL >= LCD_WIDTH)) + if ((ball[k].pos_x <= 0) || (ball[k].pos_x+BALL >= LCD_WIDTH)){ ball[k].x = ball[k].x*-1; + ball[k].pos_x = ball[k].pos_x <= 0 ? 0 : LCD_WIDTH-BALL; + } 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)) && start_game != 1 && !ball[k].glue) { @@ -1092,10 +1117,10 @@ int game_loop(void){ if (brick_on_board < 0) { if (cur_level+1sleep(HZ * 2); cur_level++; score+=100; int_game(1); + sleep(2); } else { rb->lcd_getstringsize("Congratulations!", &sw, NULL); rb->lcd_putsxy(LCD_WIDTH/2-sw/2, 140, "Congratulations!"); @@ -1104,11 +1129,11 @@ int game_loop(void){ vscore=score; rb->lcd_update(); if (score>highscore) { - rb->sleep(HZ*2); + sleep(2); highscore=score; rb->splash(HZ*2,true,"New High Score"); } else { - rb->sleep(HZ * 4); + sleep(3); } switch(game_menu(0)){ @@ -1174,8 +1199,15 @@ int game_loop(void){ } start_game =0; } else if (pad_type==1) { - for(k=0;klcd_bitmap(brickmania_gameover,LCD_WIDTH/2-55,LCD_HEIGHT-87,110,52); rb->lcd_update(); if (score>highscore) { - rb->sleep(HZ*2); + sleep(2); highscore=score; rb->splash(HZ*2,true,"New High Score"); } else { - rb->sleep(HZ * 3); + sleep(3); } for(k=0;k