start new wipe approach
This commit is contained in:
parent
09fe302e63
commit
78df7eee66
@ -69,24 +69,26 @@ void gameExec(void *handle) {
|
||||
proceedDelay--;
|
||||
if (proceedDelay == 0) {
|
||||
rowIndex = 0;
|
||||
state = e_ClearRows;
|
||||
}
|
||||
break;
|
||||
|
||||
case e_ClearRows:
|
||||
state = e_Down;
|
||||
}
|
||||
break;
|
||||
|
||||
case e_Down:
|
||||
if (! stoneMoveDown()) {
|
||||
soundCtrl(SOUND_LOCK);
|
||||
state = e_NewStone;
|
||||
stoneLock();
|
||||
state = e_ClearRows;
|
||||
} else {
|
||||
proceedDelay = delayFactor(level);
|
||||
state = e_DownDelay;
|
||||
}
|
||||
break;
|
||||
|
||||
case e_ClearRows:
|
||||
// clear filled lines
|
||||
state = e_NewStone;
|
||||
break;
|
||||
|
||||
// --- phase: game over ---------------------------------------------------
|
||||
case e_GameOver:
|
||||
soundCtrl(SOUND_GAMEOVER);
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "shapes.h"
|
||||
#include "myrand.h"
|
||||
@ -19,6 +20,7 @@ typedef struct {
|
||||
orientation_t orientation;
|
||||
uint8_t x; // column
|
||||
uint8_t y; // row
|
||||
bool locked;
|
||||
} stone_t;
|
||||
|
||||
typedef struct {
|
||||
@ -363,6 +365,11 @@ void stoneCreate() {
|
||||
stone.orientation = e_0;
|
||||
stone.x = 4;
|
||||
stone.y = 0;
|
||||
stone.locked = false;
|
||||
}
|
||||
|
||||
void stoneLock() {
|
||||
stone.locked = true;
|
||||
}
|
||||
|
||||
uint8_t stoneIsValid() {
|
||||
@ -376,6 +383,12 @@ static uint8_t move(direction_t direction) {
|
||||
if (motions[stone.shape].nullRotation && (direction == e_RotateLeft || direction == e_RotateRight)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
// if the stone is already locked, do nothing
|
||||
if (stone.locked) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// check whether the pixels to move to are free
|
||||
if (canvasIsPixelFree(stone.x + motions[stone.shape].motion[direction][stone.orientation].set[0].x,
|
||||
stone.y + motions[stone.shape].motion[direction][stone.orientation].set[0].y) &&
|
||||
|
@ -5,6 +5,7 @@
|
||||
|
||||
void shapesInit();
|
||||
void stoneCreate();
|
||||
void stoneLock();
|
||||
uint8_t stoneIsValid();
|
||||
uint8_t stoneDraw();
|
||||
uint8_t stoneMoveDown();
|
||||
|
Loading…
x
Reference in New Issue
Block a user