Added basic player movement.
This commit is contained in:
@ -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),
|
||||
|
@ -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
22
src/game/gametime.c
Normal 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
19
src/game/gametime.h
Normal 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();
|
Reference in New Issue
Block a user