GdElement what = get_dir(cave, x, y, player_move);
// gravity for falling wall, bladder, ...
- GdDirection grav_compat = cave->gravity_affects_all ? cave->gravity : GD_MV_DOWN;
+ GdDirection grav_compat = (cave->gravity_affects_all ? cave->gravity : GD_MV_DOWN);
boolean result = FALSE;
// this is tagged as sloped up&left.
// first check if the stone or diamond is coming from "up" (ie. opposite of gravity)
// then check the direction to roll (left or right)
- // this way, gravity can also be pointing right, and the above slope will work as one would expect
+ // this way, gravity can also be pointing right, and the above slope will work as one
+ // would expect
else if (sloped(cave, x, y, falling_direction, opposite[falling_direction]))
{
// rolling down if sitting on a sloped object
{
// this is a 1stB-style vodo. explodes by stone, collects diamonds
explode_dir(cave, x, y, fall_dir);
+
return TRUE;
}
- else
- return FALSE;
+
+ return FALSE;
}
// When the element at (x, y) is falling in the direction fall_dir,
// this is a 1stB-style voodoo. explodes by stone, collects diamonds
player_eat_element(cave, O_DIAMOND, x, y, fall_dir); // as if player got diamond
store(cave, x, y, O_SPACE); // diamond disappears
+
return TRUE;
}
- else
- return FALSE;
+
+ return FALSE;
}
// Element at (x, y) is falling. Try to crack nut under it.
// @param fall_dir The direction the element is falling in.
// @param bouncing The element which it is converted to, if it has cracked a nut.
// @return True, if nut is cracked.
-static boolean do_fall_try_crack_nut(GdCave *cave, int x, int y,
- GdDirection fall_dir, GdElement bouncing)
+static boolean do_fall_try_crack_nut(GdCave *cave, int x, int y, GdDirection fall_dir,
+ GdElement bouncing)
{
if (get_dir(cave, x, y, fall_dir) == O_NUT ||
get_dir(cave, x, y, fall_dir) == O_NUT_F)
return TRUE;
}
- else
- return FALSE;
+
+ return FALSE;
}
// For a falling element, try if a magic wall is under it.
// @param fall_dir The direction the element is falling to.
// @param magic The element a magic wall turns it to.
// @return If The element is processed by the magic wall.
-static boolean do_fall_try_magic(GdCave *cave, int x, int y,
- GdDirection fall_dir, GdElement magic)
+static boolean do_fall_try_magic(GdCave *cave, int x, int y, GdDirection fall_dir, GdElement magic)
{
if (get_dir(cave, x, y, fall_dir) == O_MAGIC_WALL)
{
return TRUE;
}
- else
- return FALSE;
+
+ return FALSE;
}
// For a falling element, test if an explodable element is under it;
if (explodes_by_hit(cave, x, y, fall_dir))
{
explode_dir(cave, x, y, fall_dir);
+
return TRUE;
}
- else
- return FALSE;
+
+ return FALSE;
}
// For a falling element, try if a sloped element is under it.
// If no rolling is possible, it is converted to a bouncing element.
// So this always "does something" with the element, and this should be the last
// function to call when checking what happens to a falling element.
-static boolean do_fall_roll_or_stop(GdCave *cave, int x, int y,
- GdDirection fall_dir, GdElement bouncing)
+static void do_fall_roll_or_stop(GdCave *cave, int x, int y, GdDirection fall_dir,
+ GdElement bouncing)
{
if (is_like_space(cave, x, y, fall_dir))
{
// falling further
move(cave, x, y, fall_dir, get(cave, x, y));
- return TRUE;
+ return;
}
// check if it is on a sloped element, and it can roll.
// this is tagged as sloped up&left.
// first check if the stone or diamond is coming from "up" (ie. opposite of gravity)
// then check the direction to roll (left or right)
- // this way, gravity can also be pointing right, and the above slope will work as one would expect
+ // this way, gravity can also be pointing right, and the above slope will work as one
+ // would expect
if (sloped(cave, x, y, fall_dir, opposite[fall_dir]))
{
store(cave, x, y, bouncing);
}
- return TRUE;
+ return;
}
// any other element, stops
play_sound_of_element(cave, get(cave, x, y), x, y);
store(cave, x, y, bouncing);
- return TRUE;
}
static void update_cave_speed(GdCave *cave)
case GD_SCHEDULING_BD1:
if (!cave->intermission)
+ {
// non-intermissions
- cave->speed = (88 + 3.66 * cave->c64_timing + (cave->ckdelay + cave->ckdelay_extra_for_animation) / 1000);
+ cave->speed = (88 + 3.66 * cave->c64_timing +
+ (cave->ckdelay + cave->ckdelay_extra_for_animation) / 1000);
+ }
else
+ {
// intermissions were quicker, as only lines 1-12 were processed by the engine.
- cave->speed = (60 + 3.66 * cave->c64_timing + (cave->ckdelay + cave->ckdelay_extra_for_animation) / 1000);
+ cave->speed = (60 + 3.66 * cave->c64_timing +
+ (cave->ckdelay + cave->ckdelay_extra_for_animation) / 1000);
+ }
break;
case GD_SCHEDULING_BD1_ATARI:
// about 20ms/frame faster than c64 version
if (!cave->intermission)
- cave->speed = (74 + 3.2 * cave->c64_timing + (cave->ckdelay) / 1000); // non-intermissions
+ {
+ // non-intermissions
+ cave->speed = (74 + 3.2 * cave->c64_timing + (cave->ckdelay) / 1000);
+ }
else
- cave->speed = (65 + 2.88 * cave->c64_timing + (cave->ckdelay) / 1000); // for intermissions
+ {
+ // for intermissions
+ cave->speed = (65 + 2.88 * cave->c64_timing + (cave->ckdelay) / 1000);
+ }
break;
case GD_SCHEDULING_BD2:
// 60 is a guess.
- cave->speed = MAX(60 + (cave->ckdelay + cave->ckdelay_extra_for_animation)/1000, cave->c64_timing * 20);
+ cave->speed = MAX(60 + (cave->ckdelay + cave->ckdelay_extra_for_animation) / 1000,
+ cave->c64_timing * 20);
break;
case GD_SCHEDULING_PLCK:
boolean start_signal;
// gravity for falling wall, bladder, ...
- GdDirection grav_compat = cave->gravity_affects_all ? cave->gravity : GD_MV_DOWN;
+ GdDirection grav_compat = (cave->gravity_affects_all ? cave->gravity : GD_MV_DOWN);
// directions for o_something_1, 2, 3 and 4 (creatures)
static const GdDirection creature_dir[] =
{
O_DIRT,
cave->biter_eat,
- O_SPACE, O_STONE
+ O_SPACE,
+ O_STONE
};
boolean amoeba_sound, magic_sound;
// score collected this frame
cave->score = 0;
- // to implement buggy bd1 amoeba+magic wall behaviour
+ // to implement buggy bd1 amoeba + magic wall behaviour
cave->convert_amoeba_this_frame = FALSE;
// suicide only kills the active player
if (cave->kill_player)
{
explode (cave, x, y);
+
break;
}
cave->player_seen_ago = 0;
+
// bd4 intermission caves have many players. so if one of them has exited,
// do not change the flag anymore. so this if () is needed
if (cave->player_state != GD_PL_EXITED)
cave->player_state = GD_PL_LIVING;
// check for pneumatic hammer things
- // 1) press fire, 2) have pneumatic hammer 4) space on left or right
- // for hammer 5) stand on something
+ // 1) press fire, 2) have pneumatic hammer 4) space on left or right for hammer
+ // 5) stand on something
if (player_fire && cave->got_pneumatic_hammer &&
is_like_space(cave, x, y, player_move) &&
!is_like_space(cave, x, y, GD_MV_DOWN))
cave->pneumatic_hammer_active_delay = cave->pneumatic_hammer_frame;
store_dir(cave, x, y, GD_MV_LEFT, O_PNEUMATIC_ACTIVE_LEFT);
store(cave, x, y, O_PLAYER_PNEUMATIC_LEFT);
+
break; // finished.
}
cave->pneumatic_hammer_active_delay = cave->pneumatic_hammer_frame;
store_dir(cave, x, y, GD_MV_RIGHT, O_PNEUMATIC_ACTIVE_RIGHT);
store(cave, x, y, O_PLAYER_PNEUMATIC_RIGHT);
+
break; // finished.
}
}
GdElement what = get_dir(cave, x, y, player_move);
// O_NONE in this variable will mean that there is no change.
GdElement remains = O_NONE;
- boolean push;
// if we are 'eating' a teleporter, and the function returns true
// (teleporting worked), break here
break;
// try to push element; if successful, break
- push = do_push(cave, x, y, player_move, player_fire);
+ boolean push = do_push(cave, x, y, player_move, player_fire);
+
if (push)
{
remains = O_SPACE;
store(cave, x, y, O_PLAYER_BOMB);
else
move(cave, x, y, player_move, O_PLAYER_BOMB);
+
break;
case O_ROCKET_LAUNCHER:
store(cave, x, y, O_PLAYER_ROCKET_LAUNCHER);
else
move(cave, x, y, player_move, O_PLAYER_ROCKET_LAUNCHER);
+
break;
case O_POT:
// get element - process others.
// if cannot get, player_eat_element will return the same
remains = player_eat_element(cave, what, x, y, player_move);
+
break;
}
}
break;
case O_PLAYER_BOMB:
- // much simpler; cannot steal stones
+ // much simpler; cannot snap-push stones
if (cave->kill_player)
{
explode(cave, x, y);
+
break;
}
cave->player_seen_ago = 0;
+
// bd4 intermission caves have many players. so if one of them has exited,
// do not change the flag anymore. so this if () is needed
if (cave->player_state != GD_PL_EXITED)
store(cave, x, y, O_PLAYER);
gd_sound_play(cave, GD_S_BOMB_PLACING, O_BOMB, x, y);
}
+
break;
}
if (cave->kill_player)
{
explode(cave, x, y);
+
break;
}
cave->player_seen_ago = 0;
+
// bd4 intermission caves have many players. so if one of them has exited,
// do not change the flag anymore. so this if () is needed
if (cave->player_state != GD_PL_EXITED)
if (cave->kill_player)
{
explode(cave, x, y);
+
break;
}
- // stirring sound, if no other walking sound or explosion
+ // stirring sound
gd_sound_play(cave, GD_S_STIRRING, O_PLAYER_STIRRING, x, y);
cave->player_seen_ago = 0;
+
// bd4 intermission caves have many players. so if one of them has exited,
// do not change the flag anymore. so this if () is needed
if (cave->player_state != GD_PL_EXITED)
if (cave->kill_player)
{
explode(cave, x, y);
+
break;
}
cave->player_seen_ago = 0;
+
if (cave->player_state != GD_PL_EXITED)
cave->player_state = GD_PL_LIVING;
// if hammering time is up, becomes a normal player again.
if (cave->pneumatic_hammer_active_delay == 0)
store(cave, x, y, O_PLAYER);
+
break;
// the active pneumatic hammer itself