Added some defineable types

This commit is contained in:
2021-02-23 08:28:20 +11:00
parent 4f02128553
commit 700a1b8c7f
7 changed files with 55 additions and 33 deletions

View File

@ -9,31 +9,29 @@
game_t * gameInit(platform_t *platform) {
// Create the game
dawngame_t *dawn = malloc(sizeof(dawngame_t));
if(dawn == NULL) return NULL;
game_t *game = malloc(sizeof(game_t));
if(game == NULL) return NULL;
// Load the game engine
dawn->engine = engineInit(platform, GAME_NAME, GAME_INPUT_COUNT);
if(dawn->engine == NULL) {
free(dawn);
game->engine = engineInit(platform, GAME_NAME, GAME_INPUT_COUNT);
if(game->engine == NULL) {
free(game);
return NULL;
}
// Pass to the main game to handle.
return (game_t *)dawn;
// Pass to the main game to handle.r
return game;
}
void gameUpdate(game_t *game) {
dawngame_t *dawn = (dawngame_t *)game;
engineUpdate(dawn->engine);
engineUpdate(game->engine);
}
void gameDispose(game_t *game) {
dawngame_t *dawn = (dawngame_t *)game;
engineDispose(dawn->engine);
free(dawn);
engineDispose(game->engine);
free(game);
}
engine_t * gameGetEngine(game_t *game) {
return ((dawngame_t *)game)->engine;
return game->engine;
}

View File

@ -5,11 +5,21 @@
#pragma once
#include <malloc.h>
#include "../engine/game/game.h"
#include "../engine/engine.h"
/////////////////////////////////// CONSTANTS //////////////////////////////////
/////////////////////////////// TYPE DEFINITIONS ///////////////////////////////
/** Context about Dawn Game */
typedef struct {
/** The engine context for the game */
engine_t *engine;
} dawngame_t;
#define GAMETYPE_T dawngame_t
////////////////////////////// TYPE BOUND INCLUDES /////////////////////////////
#include "../engine/game/game.h"
/////////////////////////////////// CONSTANTS //////////////////////////////////
/** Name of the Game */
#define GAME_NAME "Dawn Game"
@ -19,11 +29,4 @@
#define GAME_INPUT_LEFT (inputbind_t)0x03
#define GAME_INPUT_RIGHT (inputbind_t)0x04
#define GAME_INPUT_COUNT 5
/////////////////////////////// Type Definitions ///////////////////////////////
/** Context about Dawn Game */
typedef struct {
/** The engine context for the game */
engine_t *engine;
} dawngame_t;
#define GAME_INPUT_COUNT 5