mirror of
https://github.com/thepigeongenerator/tetris_clone.git
synced 2025-12-17 14:05:45 +01:00
synchronise with the template
- use the version of audio management which doesn't crash the application if something goes wrong - include colour32 - update error management to be more reflective of the one defined in the template - modify the renderer functions to be more reflective of the template - modify the game functions to be more reflective of the template (& use a more failproof method of initializing) - add gametime - remove set_gamestatus logic and just use a run boolean in gamedata - remove emscripten preprocessors as those haven't really been used
This commit is contained in:
@@ -1,10 +1,19 @@
|
||||
#pragma once
|
||||
|
||||
#include <SDL_scancode.h>
|
||||
#include <math.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "../window/audio.h"
|
||||
#include "../window/colour8.h"
|
||||
#include "tetromino/shapes.h"
|
||||
#include "../window/colour/colour8.h"
|
||||
#include "./tetromino/shapes.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)
|
||||
@@ -15,8 +24,9 @@ typedef colour8* row;
|
||||
|
||||
typedef struct {
|
||||
row rows[ROWS];
|
||||
audio_device* audio_device;
|
||||
audio_data music;
|
||||
gametime* time;
|
||||
audiodevice* audio_device;
|
||||
audiodata music;
|
||||
uint32_t timer_music;
|
||||
uint32_t timer_update;
|
||||
uint32_t timer_input;
|
||||
@@ -25,9 +35,10 @@ typedef struct {
|
||||
uint8_t curr_idx; // current shape index
|
||||
int8_t sel_x; // selected shape x position
|
||||
int8_t sel_y; // selected shape y position
|
||||
} game_data;
|
||||
bool run;
|
||||
} gamedata;
|
||||
|
||||
void next_shape(game_data* dat);
|
||||
void game_init(game_data* dat); // initializes the game
|
||||
void game_update(game_data* dat, uint8_t const* keys); // updates the game's state
|
||||
void game_free(game_data* dat); // free all data stored with the game
|
||||
void next_shape(gamedata*); // initializes everything needed to start the game; outputs to gamedata
|
||||
void game_init(gamedata*, gametime*); // 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
|
||||
|
||||
Reference in New Issue
Block a user