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:
2025-03-22 15:29:42 +01:00
parent 7fb624311f
commit 60ae11de10
17 changed files with 416 additions and 265 deletions

View File

@@ -1,9 +1,8 @@
#pragma once
#include <SDL_render.h>
#include <SDL_surface.h>
#include <SDL_ttf.h>
#include <SDL_video.h>
#include <stdint.h>
#include "../game/game.h"
@@ -16,20 +15,22 @@
#define BLOCK_WIDTH (TET_WIDTH / COLUMNS) // width of a block
#define BLOCK_HEIGHT (TET_HEIGHT / ROWS) // height of a block
// contains the data that's cached between renders
struct render_cache {
SDL_Texture* score_texture;
SDL_Surface* score_surface;
uint16_t prevscore;
};
// contains the data necessary for rendering
typedef struct {
game_data const* game_dat;
gamedata const* game_dat;
SDL_Window* window;
SDL_Renderer* renderer;
TTF_Font* font;
struct render_cache* cache;
} render_data;
} renderdata;
void renderer_init(render_data* render_dat, game_data const* game_dat);
void renderer_update(render_data const* dat);
void renderer_free(render_data* dat);
void render_init(renderdata*, gamedata const*); // initializes the renderer, outputs to render_data
void render_update(renderdata const*); // causes a draw to occur, will also determine update rate
void render_free(renderdata*); // frees the memory allocated to the renderer in render_data