Much much better

This commit is contained in:
2021-02-23 07:57:24 +11:00
parent adc7f5e208
commit 4f02128553
24 changed files with 371 additions and 360 deletions

39
src/dawn/dawngame.c Normal file
View File

@ -0,0 +1,39 @@
/**
* Copyright (c) 2021 Dominic Msters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#include "dawngame.h"
game_t * gameInit(platform_t *platform) {
// Create the game
dawngame_t *dawn = malloc(sizeof(dawngame_t));
if(dawn == NULL) return NULL;
// Load the game engine
dawn->engine = engineInit(platform, GAME_NAME, GAME_INPUT_COUNT);
if(dawn->engine == NULL) {
free(dawn);
return NULL;
}
// Pass to the main game to handle.
return (game_t *)dawn;
}
void gameUpdate(game_t *game) {
dawngame_t *dawn = (dawngame_t *)game;
engineUpdate(dawn->engine);
}
void gameDispose(game_t *game) {
dawngame_t *dawn = (dawngame_t *)game;
engineDispose(dawn->engine);
free(dawn);
}
engine_t * gameGetEngine(game_t *game) {
return ((dawngame_t *)game)->engine;
}

29
src/dawn/dawngame.h Normal file
View File

@ -0,0 +1,29 @@
// Copyright (c) 2021 Dominic Msters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include <malloc.h>
#include "../engine/game/game.h"
#include "../engine/engine.h"
/////////////////////////////////// CONSTANTS //////////////////////////////////
/** Name of the Game */
#define GAME_NAME "Dawn Game"
/** Inputs */
#define GAME_INPUT_UP (inputbind_t)0x01
#define GAME_INPUT_DOWN (inputbind_t)0x02
#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;