summaryrefslogtreecommitdiff
path: root/src/engine.c
diff options
context:
space:
mode:
authorOxore <oxore@protonmail.com>2018-07-09 03:53:22 +0300
committerOxore <oxore@protonmail.com>2018-07-09 03:53:22 +0300
commita3eaa5d7cd4bdb5cf1977c4cd4e8b4dd28e737ea (patch)
tree16b61f03e1dab98aa9aebcf8a0a37f43c673654d /src/engine.c
parenta673d86621054f18b25add5878efab6fa035e352 (diff)
Introduce wall kick, refactor
Refactor controls a little: move key repeat clocks reset to the keys handler. Refactor field: rename rotation function (add "clockwise" postfix).
Diffstat (limited to 'src/engine.c')
-rw-r--r--src/engine.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/engine.c b/src/engine.c
index 6abda95..fd00e34 100644
--- a/src/engine.c
+++ b/src/engine.c
@@ -220,8 +220,9 @@ static void game_tick()
static void signal_up()
{
- field_rotate_shape(&fld, 1);
+ field_rotate_shape_clockwise(&fld, 1);
project_ghost_shape(&fld, 1, 0);
+ sfClock_restart(game.putTick);
}
static void signal_harddrop()
@@ -239,7 +240,6 @@ static void signal_down()
sfClock_restart(game.gameTick);
game.scoreCurrent++;
}
- sfClock_restart(game.repPushDown);
}
static void signal_left()
@@ -248,7 +248,6 @@ static void signal_left()
project_ghost_shape(&fld, 1, 0);
sfClock_restart(game.putTick);
}
- sfClock_restart(game.repKeyLeft);
}
static void signal_right()
@@ -257,7 +256,6 @@ static void signal_right()
project_ghost_shape(&fld, 1, 0);
sfClock_restart(game.putTick);
}
- sfClock_restart(game.repKeyRight);
}
static void game_keys()
@@ -287,6 +285,7 @@ static void game_keys()
if (!(arrKeys & DOWN)) {
arrKeys = arrKeys | DOWN;
signal_down();
+ sfClock_restart(game.repPushDown);
} else {
if (sfClock_getElapsedTime(game.repPushDown).microseconds >= moveRepeatLatency2)
arrKeys = arrKeys & ~DOWN;
@@ -300,6 +299,7 @@ static void game_keys()
if (!(arrKeys & LEFT)) {
arrKeys = arrKeys | LEFT;
signal_left();
+ sfClock_restart(game.repKeyLeft);
} else if (!(arrKeys & LEFTHOLD)) {
if (sfClock_getElapsedTime(game.repKeyLeft).microseconds >= moveRepeatLatency1) {
arrKeys = arrKeys | LEFTHOLD;
@@ -319,6 +319,7 @@ static void game_keys()
if (!(arrKeys & RIGHT)) {
arrKeys = arrKeys | RIGHT;
signal_right();
+ sfClock_restart(game.repKeyRight);
} else if (!(arrKeys & RIGHTHOLD)) {
if (sfClock_getElapsedTime(game.repKeyRight).microseconds >= moveRepeatLatency1) {
arrKeys = arrKeys | RIGHTHOLD;