summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorTomer Shalev <shalev.tomer@gmail.com>2010-03-27 18:17:58 +0000
committerTomer Shalev <shalev.tomer@gmail.com>2010-03-27 18:17:58 +0000
commit8e8d2c2a5b9550307f97e4396cacdfd00caabf21 (patch)
treec743f16b4862f261b94e8548928083a833a6920b /apps
parentbe730dce0ccb9ce5c848b7295f5f81493470a5bd (diff)
downloadrockbox-8e8d2c2a5b9550307f97e4396cacdfd00caabf21.tar.gz
rockbox-8e8d2c2a5b9550307f97e4396cacdfd00caabf21.tar.bz2
rockbox-8e8d2c2a5b9550307f97e4396cacdfd00caabf21.zip
Brickmania: Simplify movement of pad (and any balls that are sticked to it)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25356 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r--apps/plugins/brickmania.c49
1 files changed, 20 insertions, 29 deletions
diff --git a/apps/plugins/brickmania.c b/apps/plugins/brickmania.c
index a28eaf084f..a4adcc29d0 100644
--- a/apps/plugins/brickmania.c
+++ b/apps/plugins/brickmania.c
@@ -2238,7 +2238,7 @@ static int brickmania_game_loop(void)
else
#endif
{
- int button_right, button_left;
+ int button_right, button_left, dx;
#ifdef ALTRIGHT
button_right = move_button & (RIGHT | ALTRIGHT);
button_left = move_button & (LEFT | ALTLEFT);
@@ -2248,40 +2248,31 @@ static int brickmania_game_loop(void)
#endif
if ((game_state==ST_PAUSE) && (button_right || button_left))
continue;
- if ((button_right && !flip_sides) ||
- (button_left && flip_sides))
+
+ if (button_left || button_right)
{
- if (pad_pos_x+SPEED_PAD+pad_width > GAMESCREEN_WIDTH)
+ if ((button_right && !flip_sides) ||
+ (button_left && flip_sides))
{
- for(k=0;k<used_balls;k++)
- if (game_state==ST_READY || ball[k].glue)
- ball[k].pos_x += GAMESCREEN_WIDTH-pad_pos_x -
- pad_width;
- pad_pos_x += GAMESCREEN_WIDTH - pad_pos_x - pad_width;
- }
- else {
- for(k=0;k<used_balls;k++)
- if ((game_state==ST_READY || ball[k].glue))
- ball[k].pos_x+=SPEED_PAD;
- pad_pos_x+=SPEED_PAD;
+ if (pad_pos_x+SPEED_PAD+pad_width > GAMESCREEN_WIDTH)
+ dx = GAMESCREEN_WIDTH - pad_pos_x - pad_width;
+ else
+ dx = SPEED_PAD;
}
- }
- else if ((button_left && !flip_sides) ||
- (button_right && flip_sides))
- {
- if (pad_pos_x-SPEED_PAD < 0)
+ else if ((button_left && !flip_sides) ||
+ (button_right && flip_sides))
{
- for(k=0;k<used_balls;k++)
- if (game_state==ST_READY || ball[k].glue)
- ball[k].pos_x-=pad_pos_x;
- pad_pos_x -= pad_pos_x;
+ if (pad_pos_x-SPEED_PAD < 0)
+ dx = -pad_pos_x;
+ else
+ dx = -SPEED_PAD;
}
- else
+
+ pad_pos_x+=dx;
+ for(k=0;k<used_balls;k++)
{
- for(k=0;k<used_balls;k++)
- if (game_state==ST_READY || ball[k].glue)
- ball[k].pos_x-=SPEED_PAD;
- pad_pos_x-=SPEED_PAD;
+ if (game_state==ST_READY || ball[k].glue)
+ ball[k].pos_x+=dx;
}
}
}