Moved some code around and cleaned things a bit.
This commit is contained in:
@ -1,39 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Msters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#include "game.h"
|
||||
|
||||
typedef struct {
|
||||
engine_t *engine;
|
||||
} dawngame_t;
|
||||
|
||||
game_t * gameInit(char *gameName) {
|
||||
// Create the game
|
||||
dawngame_t *dawn = malloc(sizeof(dawngame_t));
|
||||
if(dawn == NULL) return NULL;
|
||||
|
||||
// Load the game engine
|
||||
dawn->engine = engineInit("Dawn Game");
|
||||
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);
|
||||
}
|
@ -7,6 +7,7 @@
|
||||
|
||||
#pragma once
|
||||
#include <stdbool.h>
|
||||
#include "../platform/platform.h"
|
||||
#include "../engine/engine.h"
|
||||
|
||||
/** Information about the current game context. */
|
||||
@ -14,9 +15,11 @@ typedef void game_t;
|
||||
|
||||
/**
|
||||
* Initialize the game context.
|
||||
*
|
||||
* @param platform The platform that the game is running on.
|
||||
* @return The game instance context.
|
||||
*/
|
||||
game_t * gameInit();
|
||||
game_t * gameInit(platform_t *platform);
|
||||
|
||||
/**
|
||||
* Start the main game loop.
|
||||
|
Reference in New Issue
Block a user