Added basic player movement.

This commit is contained in:
2021-04-23 08:17:42 +10:00
parent f7c1380f06
commit e323cf2721
23 changed files with 428 additions and 14 deletions

View File

@ -14,6 +14,7 @@ bool gameInit() {
GAME_STATE.name = GAME_NAME;
// Init the renderer.
gameTimeInit();
renderInit();
inputInit();
worldInit();
@ -23,11 +24,14 @@ bool gameInit() {
"shaders/test.vert", "shaders/test.frag"
);
entityInit(0x00, 0x01);
// Init the input manger.
return true;
}
bool gameUpdate() {
gameTimeUpdate();
renderFrameStart();
inputUpdate();
@ -35,7 +39,7 @@ bool gameUpdate() {
shaderUse(GAME_STATE.shaderWorld);
// Set up the camera.
int32_t d = 50;
int32_t d = 10;
cameraLookAt(&GAME_STATE.cameraWorld, d, d, d, 0, 0, 0);
cameraPerspective(&GAME_STATE.cameraWorld, 45.0f,
((float)RENDER_STATE.width) / ((float)RENDER_STATE.height),

View File

@ -5,12 +5,14 @@
#pragma once
#include <dawn/dawn.h>
#include "gametime.h"
#include "../display/render.h"
#include "../display/camera.h"
#include "../display/shader.h"
#include "../file/asset.h"
#include "../input/input.h"
#include "../world/world.h"
#include "../world/entity/entity.h"
/**
* Initialize the game context.

22
src/game/gametime.c Normal file
View File

@ -0,0 +1,22 @@
/**
* Copyright (c) 2021 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#include "gametime.h"
gametime_t TIME_STATE;
void gameTimeInit() {
TIME_STATE.delta = GAMETIME_STEP;
TIME_STATE.last = GAMETIME_STEP;
TIME_STATE.current = GAMETIME_STEP + GAMETIME_STEP;
}
void gameTimeUpdate() {
TIME_STATE.last = TIME_STATE.current;
TIME_STATE.current = TIME_STATE.current + GAMETIME_STEP;
TIME_STATE.delta = TIME_STATE.current - TIME_STATE.last;
}

19
src/game/gametime.h Normal file
View File

@ -0,0 +1,19 @@
/**
* Copyright (c) 2021 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#include <dawn/dawn.h>
/**
* Initializes the gametime global time tracking.
*/
void gameTimeInit();
/**
* Ticks the current game time.
*/
void gameTimeUpdate();