mirror of
https://github.com/thepigeongenerator/tetris_clone.git
synced 2025-12-17 05:55:46 +01:00
42 lines
1.3 KiB
C
42 lines
1.3 KiB
C
#pragma once
|
|
#include <math.h>
|
|
#include <stdbool.h>
|
|
#include <stdint.h>
|
|
|
|
#include "../io/audio.h"
|
|
#include "../io/colour/colour8.h"
|
|
#include "../util/types.h"
|
|
#include "gametime.h"
|
|
|
|
// constants for pi(π) and tau(τ)
|
|
#define PI (M_PI) // π constant
|
|
#define TAU (M_PI * 2.0) // τ constant
|
|
#define PIf (M_PIf) // π constant as a 32-bit floating point
|
|
#define TAUf (M_PIf * 2.0F) // τ constant as a 32-bit floating point
|
|
|
|
// stores the data used in the game
|
|
#define COLUMNS ((int8_t)10)
|
|
#define ROWS ((int8_t)24)
|
|
|
|
typedef colour8 const* const row_const;
|
|
typedef colour8* row;
|
|
|
|
typedef struct {
|
|
colour8 rowdat[ROWS * COLUMNS];
|
|
colour8* rows[ROWS];
|
|
struct gametime time;
|
|
audiodata music;
|
|
audiodata place_sfx;
|
|
uint16_t score;
|
|
u8 nxt[7]; // the order of the shape ids that they should appear in
|
|
uint8_t curr_idx; // current shape index
|
|
int8_t sel_x; // selected shape x position
|
|
int8_t sel_y; // selected shape y position
|
|
bool run;
|
|
} gamedata;
|
|
|
|
void next_shape(gamedata*); // initializes everything needed to start the game; outputs to gamedata
|
|
void game_init(gamedata*); // initializes the game
|
|
void game_update(gamedata*); // causes an update to occur within the game
|
|
void game_free(gamedata*); // frees the resources associated with the game
|