rotation is hard WIP

This commit is contained in:
John Landers
2024-01-15 00:03:21 -06:00
parent f2b9a0842a
commit 517fc94038
6 changed files with 22 additions and 20 deletions

View File

@@ -1,6 +1,7 @@
#include "m_block.h"
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
@@ -364,3 +365,5 @@ int M_B_Generate_Block_Id(void) {
srand(time(NULL));
return rand();
}
int M_B_Can_Spawn_Blocks(void) { return _can_spawn_tetromino_flag; }

View File

@@ -15,7 +15,7 @@ int M_B_Try_Spawn_Blocks_With_Offset(point_offset_t *offsets);
block_t *M_B_Get_Block_At_Point(point_t point);
void M_B_Set_Block_Type(block_t *block, btype_t type);
void M_B_Register_Updated_block(block_t *block);
int M_B_Can_Move_Blocks_Left(block_t **blocks);
int M_B_Can_Move_Blocks_Left(block_t **blocks); // I probably don't need **
int M_B_Can_Move_Block_Left(block_t block);
block_t *M_B_Move_Block_Left(block_t *block);
int M_B_Can_Move_Blocks_Right(block_t **blocks);
@@ -28,5 +28,6 @@ block_t *M_B_Get_Block_At_Offset(block_t *block, point_offset_t offset);
void M_B_On_Block_Spawn(void (*callback)(block_t **blocks));
int M_B_Point_Intersects_Static_Block(point_t point, int id);
int M_B_Generate_Block_Id(void);
int M_B_Can_Spawn_Blocks(void);
#endif /* M_BLOCK_H_ */

View File

@@ -1,5 +1,6 @@
#include "m_tetromino.h"
#include "m_block.h"
#include <limits.h>
/* Blocks are gauranteed to be in order top left to bottom right */
block_t *_tetromino_blocks[BLOCKS_WITHIN_A_TETROMINO];
@@ -28,6 +29,7 @@ void M_T_Register_Falling_Blocks(block_t *blocks[BLOCKS_WITHIN_A_TETROMINO]) {
void M_T_Move_Tetromino_Left(void) {
int i;
printf("test");
if (registered_flag && M_B_Can_Move_Blocks_Left(_tetromino_blocks)) {
for (i = 0; i < BLOCKS_WITHIN_A_TETROMINO; i++) {
_tetromino_blocks[i] = M_B_Move_Block_Left(_tetromino_blocks[i]);

View File

@@ -1,5 +1,4 @@
#include "tc_input.h"
#include "m_tetromino.h"
#include "raylib.h"
@@ -8,13 +7,8 @@ void TC_Process_Input(void) {
issues before but I figured out that I can just cast to
a char to get the result I want :)
THIS IS NOT HOW RAYLIB IS INTENDED TO BE USED
should look into what's going on
should look into what's going on though to understand better
*/
if ((char)IsKeyPressed(KEY_SPACE)) {
/* Implement after rotation */
}
if ((char)IsKeyDown(KEY_A)) {
M_T_Move_Tetromino_Left();
} else if ((char)IsKeyDown(KEY_D)) {

View File

@@ -48,6 +48,7 @@ void TC_Game_Loop(void) {
int tick_rate = 0, n_updated_blocks = 0;
block_t **updated_blocks = NULL;
while (!TC_Close_Window()) {
while (M_B_Can_Spawn_Blocks()) {
R_Draw_Ui();
if (tick_rate == 0) {
TC_Process_Input();
@@ -62,6 +63,7 @@ void TC_Game_Loop(void) {
}
R_Draw_Game_Over(0);
}
}
void TC_Stop(void) {
M_B_Destroy_Blocks();

View File

@@ -1,7 +1,7 @@
#ifndef TC_SETTINGS_H_
#define TC_SETTINGS_H_
/* these settings could probably be more robust, probably doesn't matter until i
/* these settings could probably be more robust, probably doesn't matter unless i
* need more*/
/* Maybe have a load defaults, then optionally update? */