forked from len0rd/rockbox
Brickmania: Make the game speed scale with the GAMESCREEN_HEIGHT.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22582 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
6f9fde95a5
commit
1facc2e2c8
1 changed files with 43 additions and 18 deletions
|
@ -270,10 +270,33 @@ CONFIG_KEYPAD == SANSA_M200_PAD
|
||||||
#define STRINGPOS_NAVI (STRINGPOS_FINISH - 10)
|
#define STRINGPOS_NAVI (STRINGPOS_FINISH - 10)
|
||||||
#define STRINGPOS_FLIP (STRINGPOS_FINISH - 10)
|
#define STRINGPOS_FLIP (STRINGPOS_FINISH - 10)
|
||||||
|
|
||||||
|
/* Brickmania was originally designed for the H300, other targets should scale
|
||||||
|
* up/down as needed based on the screen height.
|
||||||
|
*/
|
||||||
|
#define SPEED_SCALE *GAMESCREEN_HEIGHT/176
|
||||||
|
|
||||||
|
/* These are all used as ball speeds depending on where the ball hit the
|
||||||
|
* paddle.
|
||||||
|
*/
|
||||||
|
#define SPEED_1Q_X ( 6 SPEED_SCALE)
|
||||||
|
#define SPEED_1Q_Y (-2 SPEED_SCALE)
|
||||||
|
#define SPEED_2Q_X ( 4 SPEED_SCALE)
|
||||||
|
#define SPEED_2Q_Y (-3 SPEED_SCALE)
|
||||||
|
#define SPEED_3Q_X ( 3 SPEED_SCALE)
|
||||||
|
#define SPEED_3Q_Y (-4 SPEED_SCALE)
|
||||||
|
#define SPEED_4Q_X ( 2 SPEED_SCALE)
|
||||||
|
#define SPEED_4Q_Y (-4 SPEED_SCALE)
|
||||||
|
|
||||||
|
/* This is used to determine the speed of the paddle */
|
||||||
|
#define SPEED_PAD ( 8 SPEED_SCALE)
|
||||||
|
|
||||||
|
#define SPEED_POWER ( 2 SPEED_SCALE)
|
||||||
|
|
||||||
|
#define SPEED_FIRE ( 4 SPEED_SCALE)
|
||||||
|
|
||||||
/*calculate paddle y-position */
|
/*calculate paddle y-position */
|
||||||
#define PAD_POS_Y (GAMESCREEN_HEIGHT - PAD_HEIGHT - 1)
|
#define PAD_POS_Y (GAMESCREEN_HEIGHT - PAD_HEIGHT - 1)
|
||||||
|
|
||||||
|
|
||||||
int levels_num = 29;
|
int levels_num = 29;
|
||||||
|
|
||||||
static unsigned char levels[29][8][10] = {
|
static unsigned char levels[29][8][10] = {
|
||||||
|
@ -1042,7 +1065,7 @@ static int brickmania_game_loop(void)
|
||||||
for(i=0;i<30;i++) {
|
for(i=0;i<30;i++) {
|
||||||
if (fire[i].top+7>0) {
|
if (fire[i].top+7>0) {
|
||||||
if (game_state!=ST_PAUSE)
|
if (game_state!=ST_PAUSE)
|
||||||
fire[i].top-=4;
|
fire[i].top -= SPEED_FIRE;
|
||||||
rb->lcd_vline(fire[i].left, fire[i].top, fire[i].top+7);
|
rb->lcd_vline(fire[i].left, fire[i].top, fire[i].top+7);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1053,7 +1076,7 @@ static int brickmania_game_loop(void)
|
||||||
if (brick[i*10+j].power<9) {
|
if (brick[i*10+j].power<9) {
|
||||||
if (brick[i*10+j].poweruse==2) {
|
if (brick[i*10+j].poweruse==2) {
|
||||||
if (game_state!=ST_PAUSE)
|
if (game_state!=ST_PAUSE)
|
||||||
brick[i*10+j].powertop+=2;
|
brick[i*10+j].powertop+=SPEED_POWER;
|
||||||
rb->lcd_bitmap_part(brickmania_powerups,0,
|
rb->lcd_bitmap_part(brickmania_powerups,0,
|
||||||
POWERUP_HEIGHT*brick[i*10+j
|
POWERUP_HEIGHT*brick[i*10+j
|
||||||
].power,
|
].power,
|
||||||
|
@ -1066,6 +1089,7 @@ static int brickmania_game_loop(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Did the brick hit the pad */
|
||||||
if ((pad_pos_x<LEFTMARGIN+j*BRICK_WIDTH+5 &&
|
if ((pad_pos_x<LEFTMARGIN+j*BRICK_WIDTH+5 &&
|
||||||
pad_pos_x+pad_width>LEFTMARGIN+j*BRICK_WIDTH+5) &&
|
pad_pos_x+pad_width>LEFTMARGIN+j*BRICK_WIDTH+5) &&
|
||||||
brick[i*10+j].powertop+6>=PAD_POS_Y &&
|
brick[i*10+j].powertop+6>=PAD_POS_Y &&
|
||||||
|
@ -1472,35 +1496,36 @@ static int brickmania_game_loop(void)
|
||||||
{
|
{
|
||||||
/* Ball hit the outer edge of the paddle */
|
/* Ball hit the outer edge of the paddle */
|
||||||
case 0:
|
case 0:
|
||||||
ball[k].y = -2;
|
ball[k].y = SPEED_1Q_Y;
|
||||||
ball[k].x = 6 * x_direction;
|
ball[k].x = SPEED_1Q_X * x_direction;
|
||||||
break;
|
break;
|
||||||
/* Ball hit the next fourth of the paddle */
|
/* Ball hit the next fourth of the paddle */
|
||||||
case 1:
|
case 1:
|
||||||
ball[k].y = -3;
|
ball[k].y = SPEED_2Q_Y;
|
||||||
ball[k].x = 4 * x_direction;
|
ball[k].x = SPEED_2Q_X * x_direction;
|
||||||
break;
|
break;
|
||||||
/* Ball hit the third fourth of the paddle */
|
/* Ball hit the third fourth of the paddle */
|
||||||
case 2:
|
case 2:
|
||||||
ball[k].y = -4;
|
ball[k].y = SPEED_3Q_Y;
|
||||||
ball[k].x = 3 * x_direction;
|
ball[k].x = SPEED_3Q_X * x_direction;
|
||||||
break;
|
break;
|
||||||
/* Ball hit the fourth fourth of the paddle or dead
|
/* Ball hit the fourth fourth of the paddle or dead
|
||||||
* center.
|
* center.
|
||||||
*/
|
*/
|
||||||
case 3:
|
case 3:
|
||||||
case 4:
|
case 4:
|
||||||
ball[k].y = -4;
|
ball[k].y = SPEED_4Q_Y;
|
||||||
/* Since this is the middle we don't want to
|
/* Since this is the middle we don't want to
|
||||||
* force the ball in a different direction.
|
* force the ball in a different direction.
|
||||||
* Just keep it going in the same direction
|
* Just keep it going in the same direction
|
||||||
* with a specific speed.
|
* with a specific speed.
|
||||||
*/
|
*/
|
||||||
ball[k].x = (ball[k].x > 0) ? 2: -2;
|
ball[k].x = (ball[k].x > 0) ?
|
||||||
|
SPEED_4Q_X: -SPEED_4Q_X;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
ball[k].y = -4;
|
ball[k].y = SPEED_4Q_Y;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1604,7 +1629,7 @@ static int brickmania_game_loop(void)
|
||||||
continue;
|
continue;
|
||||||
if ((button_right && flip_sides==false) ||
|
if ((button_right && flip_sides==false) ||
|
||||||
(button_left && flip_sides==true)) {
|
(button_left && flip_sides==true)) {
|
||||||
if (pad_pos_x+8+pad_width > LCD_WIDTH) {
|
if (pad_pos_x+SPEED_PAD+pad_width > LCD_WIDTH) {
|
||||||
for(k=0;k<used_balls;k++)
|
for(k=0;k<used_balls;k++)
|
||||||
if (game_state==ST_READY || ball[k].glue)
|
if (game_state==ST_READY || ball[k].glue)
|
||||||
ball[k].pos_x+=LCD_WIDTH-pad_pos_x-pad_width;
|
ball[k].pos_x+=LCD_WIDTH-pad_pos_x-pad_width;
|
||||||
|
@ -1613,13 +1638,13 @@ static int brickmania_game_loop(void)
|
||||||
else {
|
else {
|
||||||
for(k=0;k<used_balls;k++)
|
for(k=0;k<used_balls;k++)
|
||||||
if ((game_state==ST_READY || ball[k].glue))
|
if ((game_state==ST_READY || ball[k].glue))
|
||||||
ball[k].pos_x+=8;
|
ball[k].pos_x+=SPEED_PAD;
|
||||||
pad_pos_x+=8;
|
pad_pos_x+=SPEED_PAD;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ((button_left && flip_sides==false) ||
|
else if ((button_left && flip_sides==false) ||
|
||||||
(button_right && flip_sides==true)) {
|
(button_right && flip_sides==true)) {
|
||||||
if (pad_pos_x-8 < 0) {
|
if (pad_pos_x-SPEED_PAD < 0) {
|
||||||
for(k=0;k<used_balls;k++)
|
for(k=0;k<used_balls;k++)
|
||||||
if (game_state==ST_READY || ball[k].glue)
|
if (game_state==ST_READY || ball[k].glue)
|
||||||
ball[k].pos_x-=pad_pos_x;
|
ball[k].pos_x-=pad_pos_x;
|
||||||
|
@ -1628,8 +1653,8 @@ static int brickmania_game_loop(void)
|
||||||
else {
|
else {
|
||||||
for(k=0;k<used_balls;k++)
|
for(k=0;k<used_balls;k++)
|
||||||
if (game_state==ST_READY || ball[k].glue)
|
if (game_state==ST_READY || ball[k].glue)
|
||||||
ball[k].pos_x-=8;
|
ball[k].pos_x-=SPEED_PAD;
|
||||||
pad_pos_x-=8;
|
pad_pos_x-=SPEED_PAD;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef HAVE_TOUCHSCREEN
|
#ifdef HAVE_TOUCHSCREEN
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue