diff options
author | Oxore <oxore@protonmail.com> | 2018-07-09 03:04:02 +0300 |
---|---|---|
committer | Oxore <oxore@protonmail.com> | 2018-07-09 03:04:02 +0300 |
commit | a673d86621054f18b25add5878efab6fa035e352 (patch) | |
tree | e20b54aa63290944322bab08381a8f026bb5f202 | |
parent | a9e7132e6a430e86e8a69d1301252e38daf6e593 (diff) |
Introduce hard drop feature
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | src/engine.c | 19 |
2 files changed, 20 insertions, 1 deletions
@@ -37,7 +37,7 @@ Look at the [repo releases](https://github.com/Oxore/tetris-csfml/releases)! Now - [x] Levels speed and scores calibration - [x] Scoring system as in Tetris for NES which is described on [this page](https://tetris.wiki/Scoring) - [Wall kick](https://tetris.wiki/Wall_kick) -- Hard drop +- [x] Hard drop - [x] Phantom shape - Table of records - Settings menu with external `config.yml` file which allows diff --git a/src/engine.c b/src/engine.c index 72fdbfc..6abda95 100644 --- a/src/engine.c +++ b/src/engine.c @@ -20,6 +20,7 @@ #define DOWN (1 << 2) #define LEFT (1 << 3) #define RIGHTHOLD (1 << 4) +#define HARDDROP (1 << 5) #define LEFTHOLD (1 << 7) int level_move_latency[] = { @@ -223,6 +224,14 @@ static void signal_up() project_ghost_shape(&fld, 1, 0); } +static void signal_harddrop() +{ + while (field_move_shape_down(&fld, 1)); + transition_put_shape(); + sfClock_restart(game.gameTick); + sfClock_restart(game.putTick); +} + static void signal_down() { if (field_move_shape_down(&fld, 1)) { @@ -263,6 +272,16 @@ static void game_keys() arrKeys = arrKeys & ~UP; } + /* HARDDROP */ + if (sfKeyboard_isKeyPressed(sfKeySpace)) { + if (!(arrKeys & HARDDROP)) { + arrKeys = arrKeys | HARDDROP; + signal_harddrop(); + } + } else { + arrKeys = arrKeys & ~HARDDROP; + } + /* DOWN */ if (sfKeyboard_isKeyPressed(sfKeyDown)) { if (!(arrKeys & DOWN)) { |