projects
/
rocksndiamonds.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
e7708c1
)
changed delays in MM engine from clock delay to deterministic frame delay
author
Holger Schemel
<info@artsoft.org>
Thu, 6 Apr 2017 10:49:44 +0000
(12:49 +0200)
committer
Holger Schemel
<info@artsoft.org>
Fri, 23 Mar 2018 22:21:12 +0000
(23:21 +0100)
src/game_mm/mm_game.c
patch
|
blob
|
history
diff --git
a/src/game_mm/mm_game.c
b/src/game_mm/mm_game.c
index d282dfe110eccbb1db631072a13035ee07ce64c0..ffb0fc5bcc4399a9e7ea63ec6ddba86a9024bc62 100644
(file)
--- a/
src/game_mm/mm_game.c
+++ b/
src/game_mm/mm_game.c
@@
-66,12
+66,17
@@
#define DL_LASER_ENABLED 1
/* values for 'click_delay_value' in ClickElement() */
#define DL_LASER_ENABLED 1
/* values for 'click_delay_value' in ClickElement() */
-#define CLICK_DELAY_
SHORT 125
-#define CLICK_DELAY
_LONG 250
+#define CLICK_DELAY_
FIRST 12 /* delay (frames) after first click */
+#define CLICK_DELAY
6 /* delay (frames) for pressed butten */
-#define AUTO_ROTATE_DELAY CLICK_DELAY
_SHORT
-#define INIT_GAME_ACTIONS_DELAY
ONE_SECOND_DELAY
+#define AUTO_ROTATE_DELAY CLICK_DELAY
+#define INIT_GAME_ACTIONS_DELAY
(ONE_SECOND_DELAY / GAME_FRAME_DELAY)
#define NUM_INIT_CYCLE_STEPS 16
#define NUM_INIT_CYCLE_STEPS 16
+#define PACMAN_MOVE_DELAY 12
+#define ENERGY_DELAY (4 * ONE_SECOND_DELAY / GAME_FRAME_DELAY)
+#define HEALTH_DEC_DELAY 3
+#define HEALTH_INC_DELAY 9
+#define HEALTH_DELAY(x) ((x) ? HEALTH_DEC_DELAY : HEALTH_INC_DELAY)
/* forward declaration for internal use */
static int MovingOrBlocked2Element_MM(int, int);
/* forward declaration for internal use */
static int MovingOrBlocked2Element_MM(int, int);
@@
-342,7
+347,7
@@
void InitGameEngine_MM()
void InitGameActions_MM()
{
void InitGameActions_MM()
{
- int num_init_game_frames = INIT_GAME_ACTIONS_DELAY
/ GAME_FRAME_DELAY
;
+ int num_init_game_frames = INIT_GAME_ACTIONS_DELAY;
int cycle_steps_done = 0;
int i;
int cycle_steps_done = 0;
int i;
@@
-2434,7
+2439,7
@@
static void ContinueMoving_MM(int x, int y)
void ClickElement(int x, int y, int button)
{
static unsigned int click_delay = 0;
void ClickElement(int x, int y, int button)
{
static unsigned int click_delay = 0;
- static int click_delay_value = CLICK_DELAY
_SHORT
;
+ static int click_delay_value = CLICK_DELAY;
static boolean new_button = TRUE;
int element;
static boolean new_button = TRUE;
int element;
@@
-2445,7
+2450,7
@@
void ClickElement(int x, int y, int button)
if (button == MB_RELEASED)
{
new_button = TRUE;
if (button == MB_RELEASED)
{
new_button = TRUE;
- click_delay_value = CLICK_DELAY
_SHORT
;
+ click_delay_value = CLICK_DELAY;
/* release eventually hold auto-rotating mirror */
RotateMirror(x, y, MB_RELEASED);
/* release eventually hold auto-rotating mirror */
RotateMirror(x, y, MB_RELEASED);
@@
-2453,7
+2458,7
@@
void ClickElement(int x, int y, int button)
return;
}
return;
}
- if (!
Delay
Reached(&click_delay, click_delay_value) && !new_button)
+ if (!
Frame
Reached(&click_delay, click_delay_value) && !new_button)
return;
if (button == MB_MIDDLEBUTTON) /* middle button has no function */
return;
if (button == MB_MIDDLEBUTTON) /* middle button has no function */
@@
-2530,7
+2535,7
@@
void ClickElement(int x, int y, int button)
DrawLaser(0, DL_LASER_ENABLED);
}
DrawLaser(0, DL_LASER_ENABLED);
}
- click_delay_value = (new_button ? CLICK_DELAY_
LONG : CLICK_DELAY_SHORT
);
+ click_delay_value = (new_button ? CLICK_DELAY_
FIRST : CLICK_DELAY
);
new_button = FALSE;
}
new_button = FALSE;
}
@@
-2636,7
+2641,7
@@
void AutoRotateMirrors()
static unsigned int rotate_delay = 0;
int x, y;
static unsigned int rotate_delay = 0;
int x, y;
- if (!
Delay
Reached(&rotate_delay, AUTO_ROTATE_DELAY))
+ if (!
Frame
Reached(&rotate_delay, AUTO_ROTATE_DELAY))
return;
for (x = 0; x < lev_fieldx; x++)
return;
for (x = 0; x < lev_fieldx; x++)
@@
-2764,7
+2769,6
@@
void ColorCycling(void)
static void GameActions_MM_Ext(struct MouseActionInfo action, boolean warp_mode)
{
static void GameActions_MM_Ext(struct MouseActionInfo action, boolean warp_mode)
{
- static unsigned int action_delay = 0;
static unsigned int pacman_delay = 0;
static unsigned int energy_delay = 0;
static unsigned int overload_delay = 0;
static unsigned int pacman_delay = 0;
static unsigned int energy_delay = 0;
static unsigned int overload_delay = 0;
@@
-2773,8
+2777,6
@@
static void GameActions_MM_Ext(struct MouseActionInfo action, boolean warp_mode)
int r, d;
int r, d;
- WaitUntilDelayReached(&action_delay, GameFrameDelay);
-
for (y = 0; y < lev_fieldy; y++) for (x = 0; x < lev_fieldx; x++)
Stop[x][y] = FALSE;
for (y = 0; y < lev_fieldy; y++) for (x = 0; x < lev_fieldx; x++)
Stop[x][y] = FALSE;
@@
-2811,7
+2813,7
@@
static void GameActions_MM_Ext(struct MouseActionInfo action, boolean warp_mode)
CT = Counter();
CT = Counter();
- if (game_mm.num_pacman &&
DelayReached(&pacman_delay, 250
))
+ if (game_mm.num_pacman &&
FrameReached(&pacman_delay, PACMAN_MOVE_DELAY
))
{
MovePacMen();
{
MovePacMen();
@@
-2822,7
+2824,7
@@
static void GameActions_MM_Ext(struct MouseActionInfo action, boolean warp_mode)
}
}
}
}
- if (
DelayReached(&energy_delay, 4000
))
+ if (
FrameReached(&energy_delay, ENERGY_DELAY
))
{
game_mm.energy_left--;
if (game_mm.energy_left >= 0)
{
game_mm.energy_left--;
if (game_mm.energy_left >= 0)
@@
-2902,7
+2904,7
@@
static void GameActions_MM_Ext(struct MouseActionInfo action, boolean warp_mode)
if (((laser.overloaded && laser.overload_value < MAX_LASER_OVERLOAD) ||
(!laser.overloaded && laser.overload_value > 0)) &&
if (((laser.overloaded && laser.overload_value < MAX_LASER_OVERLOAD) ||
(!laser.overloaded && laser.overload_value > 0)) &&
-
DelayReached(&overload_delay, 60 + !laser.overloaded * 120
))
+
FrameReached(&overload_delay, HEALTH_DELAY(laser.overloaded)
))
{
if (laser.overloaded)
laser.overload_value++;
{
if (laser.overloaded)
laser.overload_value++;