mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-11-27 15:00:46 +00:00
Merge pull request #64 from TQMatvey/dev
arkanoid: dont allow user to jump after start
This commit is contained in:
commit
9ad96f782e
1 changed files with 18 additions and 11 deletions
|
@ -50,6 +50,7 @@ typedef struct {
|
||||||
unsigned int score; //Score for the game
|
unsigned int score; //Score for the game
|
||||||
unsigned int brickCount; //Amount of bricks hit
|
unsigned int brickCount; //Amount of bricks hit
|
||||||
int tick; //Tick counter
|
int tick; //Tick counter
|
||||||
|
bool gameStarted; // Did the game start?
|
||||||
} ArkanoidState;
|
} ArkanoidState;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -102,6 +103,7 @@ void move_ball(Canvas* canvas, ArkanoidState* st) {
|
||||||
st->ball_state.yb = 60;
|
st->ball_state.yb = 60;
|
||||||
st->ball_state.released = false;
|
st->ball_state.released = false;
|
||||||
st->lives--;
|
st->lives--;
|
||||||
|
st->gameStarted = false;
|
||||||
|
|
||||||
if(rand_range(0, 2) == 0) {
|
if(rand_range(0, 2) == 0) {
|
||||||
st->ball_state.dx = 1;
|
st->ball_state.dx = 1;
|
||||||
|
@ -294,6 +296,7 @@ static void arkanoid_state_init(ArkanoidState* arkanoid_state) {
|
||||||
|
|
||||||
// Reset initial state
|
// Reset initial state
|
||||||
arkanoid_state->initialDraw = false;
|
arkanoid_state->initialDraw = false;
|
||||||
|
arkanoid_state->gameStarted = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void arkanoid_draw_callback(Canvas* const canvas, void* ctx) {
|
static void arkanoid_draw_callback(Canvas* const canvas, void* ctx) {
|
||||||
|
@ -416,6 +419,7 @@ int32_t arkanoid_game_app(void* p) {
|
||||||
case InputKeyDown:
|
case InputKeyDown:
|
||||||
break;
|
break;
|
||||||
case InputKeyOk:
|
case InputKeyOk:
|
||||||
|
if(arkanoid_state->gameStarted == false) {
|
||||||
//Release ball if FIRE pressed
|
//Release ball if FIRE pressed
|
||||||
arkanoid_state->ball_state.released = true;
|
arkanoid_state->ball_state.released = true;
|
||||||
|
|
||||||
|
@ -428,10 +432,13 @@ int32_t arkanoid_game_app(void* p) {
|
||||||
|
|
||||||
//Makes sure the ball heads upwards
|
//Makes sure the ball heads upwards
|
||||||
arkanoid_state->ball_state.dy = -1;
|
arkanoid_state->ball_state.dy = -1;
|
||||||
|
//start the game flag
|
||||||
|
arkanoid_state->gameStarted = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// Event timeout
|
// Event timeout
|
||||||
FURI_LOG_D(TAG, "furi_message_queue: Event timeout");
|
FURI_LOG_D(TAG, "furi_message_queue: Event timeout");
|
||||||
|
|
Loading…
Reference in a new issue