Moved some code around and cleaned things a bit.

This commit is contained in:
2021-02-22 08:08:12 +11:00
parent a456eb1008
commit 11ca3d96e3
14 changed files with 405 additions and 77 deletions

35
src/games/dawn/dawngame.c Normal file
View File

@ -0,0 +1,35 @@
/**
* 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, INPUT_COUNT);
if(dawn->engine == NULL) {
free(dawn);
return NULL;
}
// Pass to the main game to handle.
return (game_t *)dawn;
}
void gameStart(game_t *game) {
dawngame_t *dawn = (dawngame_t *)game;
engineStart(dawn->engine);
}
void gameDispose(game_t *game) {
dawngame_t *dawn = (dawngame_t *)game;
engineDispose(dawn->engine);
free(dawn);
}

28
src/games/dawn/dawngame.h Normal file
View File

@ -0,0 +1,28 @@
// Copyright (c) 2021 Dominic Msters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include <malloc.h>
#include "../../game/game.h"
/////////////////////////////////// CONSTANTS //////////////////////////////////
/** Name of the Game */
#define GAME_NAME "Dawn Game"
/** Inputs */
#define INPUT_UP (inputbind_t)0x01
#define INPUT_DOWN (inputbind_t)0x02
#define INPUT_LEFT (inputbind_t)0x03
#define INPUT_RIGHT (inputbind_t)0x04
#define INPUT_COUNT 5
/////////////////////////////// Type Definitions ///////////////////////////////
/** Context about Dawn Game */
typedef struct {
/** The engine context for the game */
engine_t *engine;
} dawngame_t;