increase game speed with keydown

This commit is contained in:
John Landers
2024-01-20 01:08:58 -06:00
parent db003c6c53
commit a76c5722fc
3 changed files with 15 additions and 2 deletions

View File

@@ -1,6 +1,7 @@
#include "tc_input.h" #include "tc_input.h"
#include "m_tetromino.h" #include "m_tetromino.h"
#include "raylib.h" #include "raylib.h"
#include "tc_settings.h"
/* Was having issues with raylib input, wasn't having these /* Was having issues with raylib input, wasn't having these
issues before but I figured out that I can just cast to issues before but I figured out that I can just cast to
@@ -15,6 +16,13 @@ void TC_Process_Input_Per_Tick(void) {
} else if ((char)IsKeyDown(KEY_D)) { } else if ((char)IsKeyDown(KEY_D)) {
M_T_Move_Tetromino_Right(); M_T_Move_Tetromino_Right();
} }
/* Not sure I actually wanna handle this like this */
if ((char)IsKeyDown(KEY_S)) {
TC_Set_Game_Speed(1);
} else if ((char)IsKeyUp(KEY_S)) {
TC_Reset_Game_Speed();
}
} }
void TC_Process_Input_Per_Frame(void) { void TC_Process_Input_Per_Frame(void) {

View File

@@ -1,5 +1,7 @@
#include "tc_settings.h" #include "tc_settings.h"
#define DEFAULT_GAME_SPEED 50
int game_speed_setting = 50; int game_speed_setting = 50;
int target_fps_setting = 60; int target_fps_setting = 60;
@@ -8,3 +10,5 @@ struct TC_Setting *tc_settings;
void TC_Set_Game_Speed(int speed) { game_speed_setting = speed; } void TC_Set_Game_Speed(int speed) { game_speed_setting = speed; }
void TC_Set_Target_Fps(int fps) { target_fps_setting = fps; } void TC_Set_Target_Fps(int fps) { target_fps_setting = fps; }
void TC_Reset_Game_Speed(void) { game_speed_setting = DEFAULT_GAME_SPEED; }

View File

@@ -1,12 +1,13 @@
#ifndef TC_SETTINGS_H_ #ifndef TC_SETTINGS_H_
#define TC_SETTINGS_H_ #define TC_SETTINGS_H_
/* these settings could probably be more robust, probably doesn't matter unless i /* these settings could probably be more robust, probably doesn't matter unless
* need more*/ * i need more*/
/* Maybe have a load defaults, then optionally update? */ /* Maybe have a load defaults, then optionally update? */
void TC_Set_Game_Speed(int speed); void TC_Set_Game_Speed(int speed);
void TC_Set_Target_Fps(int fps); void TC_Set_Target_Fps(int fps);
void TC_Reset_Game_Speed(void);
extern int game_speed_setting; extern int game_speed_setting;
extern int target_fps_setting; extern int target_fps_setting;