summaryrefslogtreecommitdiff
path: root/apps/plugins
diff options
context:
space:
mode:
authorTomer Shalev <shalev.tomer@gmail.com>2010-02-16 20:58:59 +0000
committerTomer Shalev <shalev.tomer@gmail.com>2010-02-16 20:58:59 +0000
commit82d456717e82e24c7d3e4ccc7204d2b0f5af28bb (patch)
tree05efd508bd5213d0caf434dbafab2d38941ae366 /apps/plugins
parente5b63c61aba1c35edd67b8024da80cbaa23aff89 (diff)
downloadrockbox-82d456717e82e24c7d3e4ccc7204d2b0f5af28bb.tar.gz
rockbox-82d456717e82e24c7d3e4ccc7204d2b0f5af28bb.zip
Brickmania: Fix FS#10959 - Ball disappears
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@24700 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins')
-rw-r--r--apps/plugins/brickmania.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/apps/plugins/brickmania.c b/apps/plugins/brickmania.c
index 44e1aa0684..68f53aab30 100644
--- a/apps/plugins/brickmania.c
+++ b/apps/plugins/brickmania.c
@@ -299,6 +299,7 @@ CONFIG_KEYPAD == SANSA_M200_PAD
299#define POWERUP_WIDTH FIXED3(BMPWIDTH_brickmania_powerups) 299#define POWERUP_WIDTH FIXED3(BMPWIDTH_brickmania_powerups)
300#define BALL FIXED3(BMPHEIGHT_brickmania_ball) 300#define BALL FIXED3(BMPHEIGHT_brickmania_ball)
301#define HALFBALL (BALL / 2) 301#define HALFBALL (BALL / 2)
302#define ON_PAD_POS_Y (PAD_POS_Y - HALFBALL)
302 303
303#define GAMEOVER_WIDTH FIXED3(BMPWIDTH_brickmania_gameover) 304#define GAMEOVER_WIDTH FIXED3(BMPWIDTH_brickmania_gameover)
304#define GAMEOVER_HEIGHT FIXED3(BMPHEIGHT_brickmania_gameover) 305#define GAMEOVER_HEIGHT FIXED3(BMPHEIGHT_brickmania_gameover)
@@ -968,7 +969,7 @@ static void brickmania_init_game(bool new_game)
968 ball[i].speedy = 0; 969 ball[i].speedy = 0;
969 ball[i].tempy = 0; 970 ball[i].tempy = 0;
970 ball[i].tempx = 0; 971 ball[i].tempx = 0;
971 ball[i].pos_y = PAD_POS_Y - HALFBALL; 972 ball[i].pos_y = ON_PAD_POS_Y;
972 ball[i].pos_x = GAMESCREEN_WIDTH/2; 973 ball[i].pos_x = GAMESCREEN_WIDTH/2;
973 ball[i].glue = false; 974 ball[i].glue = false;
974 } 975 }
@@ -1774,7 +1775,10 @@ static int brickmania_game_loop(void)
1774 1775
1775 screen_edge.p2.x = FIXED3(LCD_WIDTH); 1776 screen_edge.p2.x = FIXED3(LCD_WIDTH);
1776 screen_edge.p2.y = 0; 1777 screen_edge.p2.y = 0;
1777 if (check_lines(&misc_line, &screen_edge, &pt_hit)) 1778 /* the test for pos_y prevents the ball from bouncing back
1779 * from _over_ the top to infinity on some rare cases */
1780 if (ball[k].pos_y > 0 &&
1781 check_lines(&misc_line, &screen_edge, &pt_hit))
1778 { 1782 {
1779 ball[k].tempy = pt_hit.y + 1; 1783 ball[k].tempy = pt_hit.y + 1;
1780 ball[k].tempx = pt_hit.x; 1784 ball[k].tempx = pt_hit.x;
@@ -1804,7 +1808,7 @@ static int brickmania_game_loop(void)
1804 ball[used_balls].speedy=0; 1808 ball[used_balls].speedy=0;
1805 ball[used_balls].tempy=0; 1809 ball[used_balls].tempy=0;
1806 ball[used_balls].tempx=0; 1810 ball[used_balls].tempx=0;
1807 ball[used_balls].pos_y=PAD_POS_Y-BALL; 1811 ball[used_balls].pos_y=ON_PAD_POS_Y;
1808 ball[used_balls].pos_x=pad_pos_x+(pad_width/2)-2; 1812 ball[used_balls].pos_x=pad_pos_x+(pad_width/2)-2;
1809 1813
1810 k--; 1814 k--;
@@ -1830,7 +1834,8 @@ static int brickmania_game_loop(void)
1830 1834
1831 screen_edge.p2.x = 0; 1835 screen_edge.p2.x = 0;
1832 screen_edge.p2.y = FIXED3(LCD_HEIGHT); 1836 screen_edge.p2.y = FIXED3(LCD_HEIGHT);
1833 if ( check_lines(&misc_line, &screen_edge, &pt_hit)) 1837 if ( !ball[k].glue &&
1838 check_lines(&misc_line, &screen_edge, &pt_hit))
1834 { 1839 {
1835 /* Reverse direction */ 1840 /* Reverse direction */
1836 ball[k].speedx = -ball[k].speedx; 1841 ball[k].speedx = -ball[k].speedx;
@@ -1846,7 +1851,8 @@ static int brickmania_game_loop(void)
1846 1851
1847 screen_edge.p2.x = FIXED3(LCD_WIDTH); 1852 screen_edge.p2.x = FIXED3(LCD_WIDTH);
1848 screen_edge.p2.y = FIXED3(LCD_HEIGHT); 1853 screen_edge.p2.y = FIXED3(LCD_HEIGHT);
1849 if ( check_lines(&misc_line, &screen_edge, &pt_hit)) 1854 if ( !ball[k].glue &&
1855 check_lines(&misc_line, &screen_edge, &pt_hit))
1850 { 1856 {
1851 /* Reverse direction */ 1857 /* Reverse direction */
1852 ball[k].speedx = -ball[k].speedx; 1858 ball[k].speedx = -ball[k].speedx;
@@ -1863,7 +1869,7 @@ static int brickmania_game_loop(void)
1863 check_lines(&misc_line, &pad_line, &pt_hit) ) 1869 check_lines(&misc_line, &pad_line, &pt_hit) )
1864 { 1870 {
1865 /* Re-position ball based on collision */ 1871 /* Re-position ball based on collision */
1866 ball[k].tempy = pt_hit.y - 1; 1872 ball[k].tempy = ON_PAD_POS_Y;
1867 ball[k].tempx = pt_hit.x; 1873 ball[k].tempx = pt_hit.x;
1868 1874
1869 /* Calculate the ball position relative to the paddle width */ 1875 /* Calculate the ball position relative to the paddle width */
@@ -1942,7 +1948,7 @@ static int brickmania_game_loop(void)
1942 * position should be forced to keep the ball at the paddle. 1948 * position should be forced to keep the ball at the paddle.
1943 */ 1949 */
1944 ball[k].tempx = 0; 1950 ball[k].tempx = 0;
1945 ball[k].tempy = pt_hit.y - BALL; 1951 ball[k].tempy = ON_PAD_POS_Y;
1946 } 1952 }
1947 } 1953 }
1948 1954