rotation is hard WIP
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
#include "m_block.h"
|
#include "m_block.h"
|
||||||
|
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
@@ -364,3 +365,5 @@ int M_B_Generate_Block_Id(void) {
|
|||||||
srand(time(NULL));
|
srand(time(NULL));
|
||||||
return rand();
|
return rand();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int M_B_Can_Spawn_Blocks(void) { return _can_spawn_tetromino_flag; }
|
||||||
@@ -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);
|
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_Set_Block_Type(block_t *block, btype_t type);
|
||||||
void M_B_Register_Updated_block(block_t *block);
|
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);
|
int M_B_Can_Move_Block_Left(block_t block);
|
||||||
block_t *M_B_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);
|
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));
|
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_Point_Intersects_Static_Block(point_t point, int id);
|
||||||
int M_B_Generate_Block_Id(void);
|
int M_B_Generate_Block_Id(void);
|
||||||
|
int M_B_Can_Spawn_Blocks(void);
|
||||||
|
|
||||||
#endif /* M_BLOCK_H_ */
|
#endif /* M_BLOCK_H_ */
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#include "m_tetromino.h"
|
#include "m_tetromino.h"
|
||||||
#include "m_block.h"
|
#include "m_block.h"
|
||||||
|
#include <limits.h>
|
||||||
|
|
||||||
/* Blocks are gauranteed to be in order top left to bottom right */
|
/* Blocks are gauranteed to be in order top left to bottom right */
|
||||||
block_t *_tetromino_blocks[BLOCKS_WITHIN_A_TETROMINO];
|
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) {
|
void M_T_Move_Tetromino_Left(void) {
|
||||||
int i;
|
int i;
|
||||||
|
printf("test");
|
||||||
if (registered_flag && M_B_Can_Move_Blocks_Left(_tetromino_blocks)) {
|
if (registered_flag && M_B_Can_Move_Blocks_Left(_tetromino_blocks)) {
|
||||||
for (i = 0; i < BLOCKS_WITHIN_A_TETROMINO; i++) {
|
for (i = 0; i < BLOCKS_WITHIN_A_TETROMINO; i++) {
|
||||||
_tetromino_blocks[i] = M_B_Move_Block_Left(_tetromino_blocks[i]);
|
_tetromino_blocks[i] = M_B_Move_Block_Left(_tetromino_blocks[i]);
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
#include "tc_input.h"
|
#include "tc_input.h"
|
||||||
|
|
||||||
#include "m_tetromino.h"
|
#include "m_tetromino.h"
|
||||||
#include "raylib.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
|
issues before but I figured out that I can just cast to
|
||||||
a char to get the result I want :)
|
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 though to understand better
|
||||||
|
|
||||||
should look into what's going on
|
|
||||||
*/
|
*/
|
||||||
if ((char)IsKeyPressed(KEY_SPACE)) {
|
|
||||||
/* Implement after rotation */
|
|
||||||
}
|
|
||||||
if ((char)IsKeyDown(KEY_A)) {
|
if ((char)IsKeyDown(KEY_A)) {
|
||||||
M_T_Move_Tetromino_Left();
|
M_T_Move_Tetromino_Left();
|
||||||
} else if ((char)IsKeyDown(KEY_D)) {
|
} else if ((char)IsKeyDown(KEY_D)) {
|
||||||
|
|||||||
@@ -48,19 +48,21 @@ void TC_Game_Loop(void) {
|
|||||||
int tick_rate = 0, n_updated_blocks = 0;
|
int tick_rate = 0, n_updated_blocks = 0;
|
||||||
block_t **updated_blocks = NULL;
|
block_t **updated_blocks = NULL;
|
||||||
while (!TC_Close_Window()) {
|
while (!TC_Close_Window()) {
|
||||||
R_Draw_Ui();
|
while (M_B_Can_Spawn_Blocks()) {
|
||||||
if (tick_rate == 0) {
|
R_Draw_Ui();
|
||||||
TC_Process_Input();
|
if (tick_rate == 0) {
|
||||||
M_T_Update_Tetromino();
|
TC_Process_Input();
|
||||||
M_B_Update_Blocks();
|
M_T_Update_Tetromino();
|
||||||
updated_blocks = M_B_Get_Blocks(&n_updated_blocks);
|
M_B_Update_Blocks();
|
||||||
R_Draw_Blocks(updated_blocks, n_updated_blocks);
|
updated_blocks = M_B_Get_Blocks(&n_updated_blocks);
|
||||||
tick_rate = game_speed_setting;
|
R_Draw_Blocks(updated_blocks, n_updated_blocks);
|
||||||
} else {
|
tick_rate = game_speed_setting;
|
||||||
tick_rate--;
|
} else {
|
||||||
|
tick_rate--;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
R_Draw_Game_Over(0);
|
||||||
}
|
}
|
||||||
R_Draw_Game_Over(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TC_Stop(void) {
|
void TC_Stop(void) {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#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 until i
|
/* these settings could probably be more robust, probably doesn't matter unless i
|
||||||
* need more*/
|
* need more*/
|
||||||
/* Maybe have a load defaults, then optionally update? */
|
/* Maybe have a load defaults, then optionally update? */
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user