Update events.c
This commit is contained in:
+11
-9
@@ -6,21 +6,21 @@
|
|||||||
#include "column.h"
|
#include "column.h"
|
||||||
#include "sdl.h"
|
#include "sdl.h"
|
||||||
|
|
||||||
bool next_p = false; // next piece flag
|
bool next_p = false; // Next Piece flag
|
||||||
bool restart = false; // restart flag
|
bool pause_f = false; // Pause Flag
|
||||||
bool pause_f = false; // pause flag
|
bool quit = false; // Quit flag
|
||||||
bool quit = false; // quit flag
|
bool gradient_d = false; // Gradient Direction flag
|
||||||
bool gradient_d = false; // gradient direction flag
|
int game_end = 0; // 0 = game, 1 = restart, 2 = game over
|
||||||
|
|
||||||
int handle_events(void) {
|
int handle_events(void) {
|
||||||
|
|
||||||
////////////////////////////// EVENT LOOP //////////////////////////
|
////////////////////////////// EVENT LOOP //////////////////////////
|
||||||
|
|
||||||
while (restart == false) {
|
while (game_end == 0) {
|
||||||
SDL_PollEvent (&event);
|
SDL_PollEvent (&event);
|
||||||
switch (event.type) {
|
switch (event.type) {
|
||||||
case SDL_KEYDOWN:
|
case SDL_KEYDOWN:
|
||||||
|
count_col(); // could this be the fix?
|
||||||
// gradient colour cycle
|
// gradient colour cycle
|
||||||
if(event.key.keysym.sym == SDLK_c
|
if(event.key.keysym.sym == SDLK_c
|
||||||
&& (event.key.keysym.mod & KMOD_CTRL) != 0 ) {
|
&& (event.key.keysym.mod & KMOD_CTRL) != 0 ) {
|
||||||
@@ -68,7 +68,7 @@ int handle_events(void) {
|
|||||||
// restart
|
// restart
|
||||||
if( event.key.keysym.sym == SDLK_r
|
if( event.key.keysym.sym == SDLK_r
|
||||||
&& (event.key.keysym.mod & KMOD_CTRL) != 0 ) {
|
&& (event.key.keysym.mod & KMOD_CTRL) != 0 ) {
|
||||||
restart = true;
|
game_end = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -82,10 +82,12 @@ int handle_events(void) {
|
|||||||
|
|
||||||
// drop/fall block/piece/brick
|
// drop/fall block/piece/brick
|
||||||
if (event.key.keysym.sym == SDLK_SPACE) {
|
if (event.key.keysym.sym == SDLK_SPACE) {
|
||||||
|
game_logic();
|
||||||
|
Ren_frame();
|
||||||
for (int i = -1; i < 3; i++) {
|
for (int i = -1; i < 3; i++) {
|
||||||
grid[0][row + i][col] = 0; // zero out old column
|
grid[0][row + i][col] = 0; // zero out old column
|
||||||
}
|
}
|
||||||
row = 18 - (18-colcnt[col]);
|
row = 18 - (18 - colcnt[col]);
|
||||||
disp_column(row, col);
|
disp_column(row, col);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user