diff options
author | Karl Kurbjun <kkurbjun@gmail.com> | 2009-09-01 02:07:35 +0000 |
---|---|---|
committer | Karl Kurbjun <kkurbjun@gmail.com> | 2009-09-01 02:07:35 +0000 |
commit | 1facc2e2c8bf3ea3ea055dec09b44d65da74418e (patch) | |
tree | 4988e0953c36f8bd203d86ce77791b097ff4d899 | |
parent | 6f9fde95a58a984d8e6a7f3d0bc7506d3030bf2b (diff) | |
download | rockbox-1facc2e2c8bf3ea3ea055dec09b44d65da74418e.tar.gz rockbox-1facc2e2c8bf3ea3ea055dec09b44d65da74418e.zip |
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
-rw-r--r-- | apps/plugins/brickmania.c | 61 |
1 files changed, 43 insertions, 18 deletions
diff --git a/apps/plugins/brickmania.c b/apps/plugins/brickmania.c index c8b9f2ac1c..3d5b644db8 100644 --- a/apps/plugins/brickmania.c +++ b/apps/plugins/brickmania.c | |||
@@ -270,10 +270,33 @@ CONFIG_KEYPAD == SANSA_M200_PAD | |||
270 | #define STRINGPOS_NAVI (STRINGPOS_FINISH - 10) | 270 | #define STRINGPOS_NAVI (STRINGPOS_FINISH - 10) |
271 | #define STRINGPOS_FLIP (STRINGPOS_FINISH - 10) | 271 | #define STRINGPOS_FLIP (STRINGPOS_FINISH - 10) |
272 | 272 | ||
273 | /* Brickmania was originally designed for the H300, other targets should scale | ||
274 | * up/down as needed based on the screen height. | ||
275 | */ | ||
276 | #define SPEED_SCALE *GAMESCREEN_HEIGHT/176 | ||
277 | |||
278 | /* These are all used as ball speeds depending on where the ball hit the | ||
279 | * paddle. | ||
280 | */ | ||
281 | #define SPEED_1Q_X ( 6 SPEED_SCALE) | ||
282 | #define SPEED_1Q_Y (-2 SPEED_SCALE) | ||
283 | #define SPEED_2Q_X ( 4 SPEED_SCALE) | ||
284 | #define SPEED_2Q_Y (-3 SPEED_SCALE) | ||
285 | #define SPEED_3Q_X ( 3 SPEED_SCALE) | ||
286 | #define SPEED_3Q_Y (-4 SPEED_SCALE) | ||
287 | #define SPEED_4Q_X ( 2 SPEED_SCALE) | ||
288 | #define SPEED_4Q_Y (-4 SPEED_SCALE) | ||
289 | |||
290 | /* This is used to determine the speed of the paddle */ | ||
291 | #define SPEED_PAD ( 8 SPEED_SCALE) | ||
292 | |||
293 | #define SPEED_POWER ( 2 SPEED_SCALE) | ||
294 | |||
295 | #define SPEED_FIRE ( 4 SPEED_SCALE) | ||
296 | |||
273 | /*calculate paddle y-position */ | 297 | /*calculate paddle y-position */ |
274 | #define PAD_POS_Y (GAMESCREEN_HEIGHT - PAD_HEIGHT - 1) | 298 | #define PAD_POS_Y (GAMESCREEN_HEIGHT - PAD_HEIGHT - 1) |
275 | 299 | ||
276 | |||
277 | int levels_num = 29; | 300 | int levels_num = 29; |
278 | 301 | ||
279 | static unsigned char levels[29][8][10] = { | 302 | static unsigned char levels[29][8][10] = { |
@@ -1042,7 +1065,7 @@ static int brickmania_game_loop(void) | |||
1042 | for(i=0;i<30;i++) { | 1065 | for(i=0;i<30;i++) { |
1043 | if (fire[i].top+7>0) { | 1066 | if (fire[i].top+7>0) { |
1044 | if (game_state!=ST_PAUSE) | 1067 | if (game_state!=ST_PAUSE) |
1045 | fire[i].top-=4; | 1068 | fire[i].top -= SPEED_FIRE; |
1046 | rb->lcd_vline(fire[i].left, fire[i].top, fire[i].top+7); | 1069 | rb->lcd_vline(fire[i].left, fire[i].top, fire[i].top+7); |
1047 | } | 1070 | } |
1048 | } | 1071 | } |
@@ -1053,7 +1076,7 @@ static int brickmania_game_loop(void) | |||
1053 | if (brick[i*10+j].power<9) { | 1076 | if (brick[i*10+j].power<9) { |
1054 | if (brick[i*10+j].poweruse==2) { | 1077 | if (brick[i*10+j].poweruse==2) { |
1055 | if (game_state!=ST_PAUSE) | 1078 | if (game_state!=ST_PAUSE) |
1056 | brick[i*10+j].powertop+=2; | 1079 | brick[i*10+j].powertop+=SPEED_POWER; |
1057 | rb->lcd_bitmap_part(brickmania_powerups,0, | 1080 | rb->lcd_bitmap_part(brickmania_powerups,0, |
1058 | POWERUP_HEIGHT*brick[i*10+j | 1081 | POWERUP_HEIGHT*brick[i*10+j |
1059 | ].power, | 1082 | ].power, |
@@ -1066,6 +1089,7 @@ static int brickmania_game_loop(void) | |||
1066 | } | 1089 | } |
1067 | } | 1090 | } |
1068 | 1091 | ||
1092 | /* Did the brick hit the pad */ | ||
1069 | if ((pad_pos_x<LEFTMARGIN+j*BRICK_WIDTH+5 && | 1093 | if ((pad_pos_x<LEFTMARGIN+j*BRICK_WIDTH+5 && |
1070 | pad_pos_x+pad_width>LEFTMARGIN+j*BRICK_WIDTH+5) && | 1094 | pad_pos_x+pad_width>LEFTMARGIN+j*BRICK_WIDTH+5) && |
1071 | brick[i*10+j].powertop+6>=PAD_POS_Y && | 1095 | brick[i*10+j].powertop+6>=PAD_POS_Y && |
@@ -1472,35 +1496,36 @@ static int brickmania_game_loop(void) | |||
1472 | { | 1496 | { |
1473 | /* Ball hit the outer edge of the paddle */ | 1497 | /* Ball hit the outer edge of the paddle */ |
1474 | case 0: | 1498 | case 0: |
1475 | ball[k].y = -2; | 1499 | ball[k].y = SPEED_1Q_Y; |
1476 | ball[k].x = 6 * x_direction; | 1500 | ball[k].x = SPEED_1Q_X * x_direction; |
1477 | break; | 1501 | break; |
1478 | /* Ball hit the next fourth of the paddle */ | 1502 | /* Ball hit the next fourth of the paddle */ |
1479 | case 1: | 1503 | case 1: |
1480 | ball[k].y = -3; | 1504 | ball[k].y = SPEED_2Q_Y; |
1481 | ball[k].x = 4 * x_direction; | 1505 | ball[k].x = SPEED_2Q_X * x_direction; |
1482 | break; | 1506 | break; |
1483 | /* Ball hit the third fourth of the paddle */ | 1507 | /* Ball hit the third fourth of the paddle */ |
1484 | case 2: | 1508 | case 2: |
1485 | ball[k].y = -4; | 1509 | ball[k].y = SPEED_3Q_Y; |
1486 | ball[k].x = 3 * x_direction; | 1510 | ball[k].x = SPEED_3Q_X * x_direction; |
1487 | break; | 1511 | break; |
1488 | /* Ball hit the fourth fourth of the paddle or dead | 1512 | /* Ball hit the fourth fourth of the paddle or dead |
1489 | * center. | 1513 | * center. |
1490 | */ | 1514 | */ |
1491 | case 3: | 1515 | case 3: |
1492 | case 4: | 1516 | case 4: |
1493 | ball[k].y = -4; | 1517 | ball[k].y = SPEED_4Q_Y; |
1494 | /* Since this is the middle we don't want to | 1518 | /* Since this is the middle we don't want to |
1495 | * force the ball in a different direction. | 1519 | * force the ball in a different direction. |
1496 | * Just keep it going in the same direction | 1520 | * Just keep it going in the same direction |
1497 | * with a specific speed. | 1521 | * with a specific speed. |
1498 | */ | 1522 | */ |
1499 | ball[k].x = (ball[k].x > 0) ? 2: -2; | 1523 | ball[k].x = (ball[k].x > 0) ? |
1524 | SPEED_4Q_X: -SPEED_4Q_X; | ||
1500 | break; | 1525 | break; |
1501 | 1526 | ||
1502 | default: | 1527 | default: |
1503 | ball[k].y = -4; | 1528 | ball[k].y = SPEED_4Q_Y; |
1504 | break; | 1529 | break; |
1505 | } | 1530 | } |
1506 | } | 1531 | } |
@@ -1604,7 +1629,7 @@ static int brickmania_game_loop(void) | |||
1604 | continue; | 1629 | continue; |
1605 | if ((button_right && flip_sides==false) || | 1630 | if ((button_right && flip_sides==false) || |
1606 | (button_left && flip_sides==true)) { | 1631 | (button_left && flip_sides==true)) { |
1607 | if (pad_pos_x+8+pad_width > LCD_WIDTH) { | 1632 | if (pad_pos_x+SPEED_PAD+pad_width > LCD_WIDTH) { |
1608 | for(k=0;k<used_balls;k++) | 1633 | for(k=0;k<used_balls;k++) |
1609 | if (game_state==ST_READY || ball[k].glue) | 1634 | if (game_state==ST_READY || ball[k].glue) |
1610 | ball[k].pos_x+=LCD_WIDTH-pad_pos_x-pad_width; | 1635 | ball[k].pos_x+=LCD_WIDTH-pad_pos_x-pad_width; |
@@ -1613,13 +1638,13 @@ static int brickmania_game_loop(void) | |||
1613 | else { | 1638 | else { |
1614 | for(k=0;k<used_balls;k++) | 1639 | for(k=0;k<used_balls;k++) |
1615 | if ((game_state==ST_READY || ball[k].glue)) | 1640 | if ((game_state==ST_READY || ball[k].glue)) |
1616 | ball[k].pos_x+=8; | 1641 | ball[k].pos_x+=SPEED_PAD; |
1617 | pad_pos_x+=8; | 1642 | pad_pos_x+=SPEED_PAD; |
1618 | } | 1643 | } |
1619 | } | 1644 | } |
1620 | else if ((button_left && flip_sides==false) || | 1645 | else if ((button_left && flip_sides==false) || |
1621 | (button_right && flip_sides==true)) { | 1646 | (button_right && flip_sides==true)) { |
1622 | if (pad_pos_x-8 < 0) { | 1647 | if (pad_pos_x-SPEED_PAD < 0) { |
1623 | for(k=0;k<used_balls;k++) | 1648 | for(k=0;k<used_balls;k++) |
1624 | if (game_state==ST_READY || ball[k].glue) | 1649 | if (game_state==ST_READY || ball[k].glue) |
1625 | ball[k].pos_x-=pad_pos_x; | 1650 | ball[k].pos_x-=pad_pos_x; |
@@ -1628,8 +1653,8 @@ static int brickmania_game_loop(void) | |||
1628 | else { | 1653 | else { |
1629 | for(k=0;k<used_balls;k++) | 1654 | for(k=0;k<used_balls;k++) |
1630 | if (game_state==ST_READY || ball[k].glue) | 1655 | if (game_state==ST_READY || ball[k].glue) |
1631 | ball[k].pos_x-=8; | 1656 | ball[k].pos_x-=SPEED_PAD; |
1632 | pad_pos_x-=8; | 1657 | pad_pos_x-=SPEED_PAD; |
1633 | } | 1658 | } |
1634 | } | 1659 | } |
1635 | #ifdef HAVE_TOUCHSCREEN | 1660 | #ifdef HAVE_TOUCHSCREEN |