summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/plugins/brickmania.c70
1 files changed, 35 insertions, 35 deletions
diff --git a/apps/plugins/brickmania.c b/apps/plugins/brickmania.c
index 0981e61b21..400ee022fc 100644
--- a/apps/plugins/brickmania.c
+++ b/apps/plugins/brickmania.c
@@ -798,15 +798,15 @@ cube brick[80];
798 798
799typedef struct balls 799typedef struct balls
800{ 800{
801 /* pos_x and y store the current position of the ball */ 801 /* pos_x and y store the current center position of the ball */
802 int pos_x; 802 int pos_x;
803 int pos_y; 803 int pos_y;
804 /* Tempx and tempy store an absolute position the ball should be in. If 804 /* tempx and tempy store an absolute position the ball should be in. If
805 * they are equal to 0, they are not used when positioning the ball. 805 * they are equal to 0, they are not used when positioning the ball.
806 */ 806 */
807 int tempx; 807 int tempx;
808 int tempy; 808 int tempy;
809 /* x and y store the current speed of the ball */ 809 /* speedx and speedy store the current speed of the ball */
810 int speedx; 810 int speedx;
811 int speedy; 811 int speedy;
812 bool glue; /* Is the ball stuck to the paddle? */ 812 bool glue; /* Is the ball stuck to the paddle? */
@@ -949,8 +949,8 @@ static void brickmania_init_game(bool new_game)
949 ball[i].speedy = 0; 949 ball[i].speedy = 0;
950 ball[i].tempy = 0; 950 ball[i].tempy = 0;
951 ball[i].tempx = 0; 951 ball[i].tempx = 0;
952 ball[i].pos_y = PAD_POS_Y - BALL; 952 ball[i].pos_y = PAD_POS_Y - HALFBALL;
953 ball[i].pos_x = GAMESCREEN_WIDTH/2 - HALFBALL; 953 ball[i].pos_x = GAMESCREEN_WIDTH/2;
954 ball[i].glue = false; 954 ball[i].glue = false;
955 } 955 }
956 956
@@ -1375,7 +1375,9 @@ static int brickmania_game_loop(void)
1375 /* draw the ball */ 1375 /* draw the ball */
1376 for(i=0;i<used_balls;i++) 1376 for(i=0;i<used_balls;i++)
1377 rb->lcd_bitmap(brickmania_ball, 1377 rb->lcd_bitmap(brickmania_ball,
1378 INT3(ball[i].pos_x), INT3(ball[i].pos_y), INT3(BALL), INT3(BALL)); 1378 INT3(ball[i].pos_x - HALFBALL),
1379 INT3(ball[i].pos_y - HALFBALL),
1380 INT3(BALL), INT3(BALL));
1379 1381
1380 if (brick_on_board==0) 1382 if (brick_on_board==0)
1381 brick_on_board--; 1383 brick_on_board--;
@@ -1401,7 +1403,7 @@ static int brickmania_game_loop(void)
1401 pad_line.p2.x = pad_pos_x + pad_width; 1403 pad_line.p2.x = pad_pos_x + pad_width;
1402 pad_line.p2.y = PAD_POS_Y; 1404 pad_line.p2.y = PAD_POS_Y;
1403 1405
1404 /* handle all of the bricks */ 1406 /* handle all of the bricks/powerups */
1405 for (i=0; i<=7; i++) 1407 for (i=0; i<=7; i++)
1406 { 1408 {
1407 for (j=0; j<=9 ;j++) 1409 for (j=0; j<=9 ;j++)
@@ -1635,13 +1637,11 @@ static int brickmania_game_loop(void)
1635 * position and the line it makes to its next 1637 * position and the line it makes to its next
1636 * position. 1638 * position.
1637 */ 1639 */
1638 misc_line.p1.x = ball[k].pos_x + HALFBALL; 1640 misc_line.p1.x = ball[k].pos_x;
1639 misc_line.p1.y = ball[k].pos_y + HALFBALL; 1641 misc_line.p1.y = ball[k].pos_y;
1640 1642
1641 misc_line.p2.x = ball[k].pos_x + ball[k].speedx 1643 misc_line.p2.x = ball[k].pos_x + ball[k].speedx;
1642 + HALFBALL; 1644 misc_line.p2.y = ball[k].pos_y + ball[k].speedy;
1643 misc_line.p2.y = ball[k].pos_y + ball[k].speedy
1644 + HALFBALL;
1645 1645
1646 /* Check to see if the ball and the bottom hit. If 1646 /* Check to see if the ball and the bottom hit. If
1647 * the ball is moving down we don't want to 1647 * the ball is moving down we don't want to
@@ -1656,8 +1656,8 @@ static int brickmania_game_loop(void)
1656 check_lines(&misc_line, &bot_brick, &pt_hit)) 1656 check_lines(&misc_line, &bot_brick, &pt_hit))
1657 { 1657 {
1658 ball[k].speedy = -ball[k].speedy; 1658 ball[k].speedy = -ball[k].speedy;
1659 ball[k].tempy = pt_hit.y + HALFBALL; 1659 ball[k].tempy = pt_hit.y;
1660 ball[k].tempx = pt_hit.x - HALFBALL; 1660 ball[k].tempx = pt_hit.x;
1661 brick_hit(bnum); 1661 brick_hit(bnum);
1662 } 1662 }
1663 /* Check the top, if the ball is moving up dont 1663 /* Check the top, if the ball is moving up dont
@@ -1667,8 +1667,8 @@ static int brickmania_game_loop(void)
1667 check_lines(&misc_line, &top_brick, &pt_hit)) 1667 check_lines(&misc_line, &top_brick, &pt_hit))
1668 { 1668 {
1669 ball[k].speedy = -ball[k].speedy; 1669 ball[k].speedy = -ball[k].speedy;
1670 ball[k].tempy = pt_hit.y - HALFBALL; 1670 ball[k].tempy = pt_hit.y;
1671 ball[k].tempx = pt_hit.x - HALFBALL; 1671 ball[k].tempx = pt_hit.x;
1672 brick_hit(bnum); 1672 brick_hit(bnum);
1673 } 1673 }
1674 /* Check the left side of the brick */ 1674 /* Check the left side of the brick */
@@ -1676,8 +1676,8 @@ static int brickmania_game_loop(void)
1676 check_lines(&misc_line, &left_brick, &pt_hit)) 1676 check_lines(&misc_line, &left_brick, &pt_hit))
1677 { 1677 {
1678 ball[k].speedx = -ball[k].speedx; 1678 ball[k].speedx = -ball[k].speedx;
1679 ball[k].tempy = pt_hit.y - HALFBALL; 1679 ball[k].tempy = pt_hit.y;
1680 ball[k].tempx = pt_hit.x - HALFBALL; 1680 ball[k].tempx = pt_hit.x;
1681 brick_hit(bnum); 1681 brick_hit(bnum);
1682 } 1682 }
1683 /* Check the right side of the brick */ 1683 /* Check the right side of the brick */
@@ -1685,8 +1685,8 @@ static int brickmania_game_loop(void)
1685 check_lines(&misc_line, &rght_brick, &pt_hit)) 1685 check_lines(&misc_line, &rght_brick, &pt_hit))
1686 { 1686 {
1687 ball[k].speedx = -ball[k].speedx; 1687 ball[k].speedx = -ball[k].speedx;
1688 ball[k].tempy = pt_hit.y - HALFBALL; 1688 ball[k].tempy = pt_hit.y;
1689 ball[k].tempx = pt_hit.x + HALFBALL; 1689 ball[k].tempx = pt_hit.x;
1690 brick_hit(bnum); 1690 brick_hit(bnum);
1691 } 1691 }
1692 } /* for k */ 1692 } /* for k */
@@ -1736,11 +1736,11 @@ static int brickmania_game_loop(void)
1736 line screen_edge; 1736 line screen_edge;
1737 1737
1738 /* Describe the ball movement for the edge collision detection */ 1738 /* Describe the ball movement for the edge collision detection */
1739 misc_line.p1.x = ball[k].pos_x + HALFBALL; 1739 misc_line.p1.x = ball[k].pos_x;
1740 misc_line.p1.y = ball[k].pos_y + HALFBALL; 1740 misc_line.p1.y = ball[k].pos_y;
1741 1741
1742 misc_line.p2.x = ball[k].pos_x + ball[k].speedx + HALFBALL; 1742 misc_line.p2.x = ball[k].pos_x + ball[k].speedx;
1743 misc_line.p2.y = ball[k].pos_y + ball[k].speedy + HALFBALL; 1743 misc_line.p2.y = ball[k].pos_y + ball[k].speedy;
1744 1744
1745 /* Did the Ball hit the top of the screen? */ 1745 /* Did the Ball hit the top of the screen? */
1746 screen_edge.p1.x = 0; 1746 screen_edge.p1.x = 0;
@@ -1750,14 +1750,14 @@ static int brickmania_game_loop(void)
1750 screen_edge.p2.y = 0; 1750 screen_edge.p2.y = 0;
1751 if (check_lines(&misc_line, &screen_edge, &pt_hit)) 1751 if (check_lines(&misc_line, &screen_edge, &pt_hit))
1752 { 1752 {
1753 ball[k].tempy = pt_hit.y - HALFBALL + 1; 1753 ball[k].tempy = pt_hit.y + 1;
1754 ball[k].tempx = pt_hit.x - HALFBALL; 1754 ball[k].tempx = pt_hit.x;
1755 /* Reverse the direction */ 1755 /* Reverse the direction */
1756 ball[k].speedy = -ball[k].speedy; 1756 ball[k].speedy = -ball[k].speedy;
1757 } 1757 }
1758 1758
1759 /* Player missed the ball and hit bottom of screen */ 1759 /* Player missed the ball and hit bottom of screen */
1760 if (ball[k].pos_y+HALFBALL >= GAMESCREEN_HEIGHT) 1760 if (ball[k].pos_y >= GAMESCREEN_HEIGHT)
1761 { 1761 {
1762 /* Player had balls to spare, so handle the removal */ 1762 /* Player had balls to spare, so handle the removal */
1763 if (used_balls>1) 1763 if (used_balls>1)
@@ -1810,8 +1810,8 @@ static int brickmania_game_loop(void)
1810 ball[k].speedx = -ball[k].speedx; 1810 ball[k].speedx = -ball[k].speedx;
1811 1811
1812 /* Re-position ball in gameboard */ 1812 /* Re-position ball in gameboard */
1813 ball[k].tempy = pt_hit.y - HALFBALL; 1813 ball[k].tempy = pt_hit.y;
1814 ball[k].tempx = pt_hit.x - HALFBALL + 1; 1814 ball[k].tempx = 0;
1815 } 1815 }
1816 1816
1817 /* Check if the ball hit the right side */ 1817 /* Check if the ball hit the right side */
@@ -1826,8 +1826,8 @@ static int brickmania_game_loop(void)
1826 ball[k].speedx = -ball[k].speedx; 1826 ball[k].speedx = -ball[k].speedx;
1827 1827
1828 /* Re-position ball in gameboard */ 1828 /* Re-position ball in gameboard */
1829 ball[k].tempy = pt_hit.y - HALFBALL; 1829 ball[k].tempy = pt_hit.y;
1830 ball[k].tempx = pt_hit.x - HALFBALL - 1; 1830 ball[k].tempx = FIXED3(LCD_WIDTH - 1);
1831 } 1831 }
1832 1832
1833 /* Did the ball hit the paddle? Depending on where the ball 1833 /* Did the ball hit the paddle? Depending on where the ball
@@ -1837,8 +1837,8 @@ static int brickmania_game_loop(void)
1837 check_lines(&misc_line, &pad_line, &pt_hit) ) 1837 check_lines(&misc_line, &pad_line, &pt_hit) )
1838 { 1838 {
1839 /* Re-position ball based on collision */ 1839 /* Re-position ball based on collision */
1840 ball[k].tempy = pt_hit.y - HALFBALL - 1; 1840 ball[k].tempy = pt_hit.y - 1;
1841 ball[k].tempx = pt_hit.x - HALFBALL; 1841 ball[k].tempx = pt_hit.x;
1842 1842
1843 /* Calculate the ball position relative to the paddle width */ 1843 /* Calculate the ball position relative to the paddle width */
1844 int ball_repos = pt_hit.x - pad_pos_x; 1844 int ball_repos = pt_hit.x - pad_pos_x;
@@ -2007,7 +2007,7 @@ static int brickmania_game_loop(void)
2007 pad_pos_x = GAMESCREEN_WIDTH-pad_width; 2007 pad_pos_x = GAMESCREEN_WIDTH-pad_width;
2008 for(k=0; k<used_balls; k++) 2008 for(k=0; k<used_balls; k++)
2009 if (game_state==ST_READY || ball[k].glue) 2009 if (game_state==ST_READY || ball[k].glue)
2010 ball[k].pos_x = pad_pos_x + pad_width/2 - HALFBALL; 2010 ball[k].pos_x = pad_pos_x + pad_width/2;
2011 } 2011 }
2012 else 2012 else
2013#endif 2013#endif