Added basic player movement.
This commit is contained in:
@ -17,6 +17,7 @@
|
||||
#include "file/asset.h"
|
||||
|
||||
#include "game/game.h"
|
||||
#include "game/gametime.h"
|
||||
|
||||
#include "input/input.h"
|
||||
|
||||
|
38
include/dawn/game/gametime.h
Normal file
38
include/dawn/game/gametime.h
Normal file
@ -0,0 +1,38 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#define GAMETIME_STEP 0.016
|
||||
|
||||
typedef struct {
|
||||
/**
|
||||
* Current time (as a float of seconds since game start).
|
||||
*
|
||||
* When time is initialized this will start at a fixed value of 2/60ths of a
|
||||
* second, regardless of what engine the game is running.
|
||||
*
|
||||
* This is to avoid any divide by zero errors.
|
||||
*/
|
||||
float current;
|
||||
|
||||
/**
|
||||
* Last Time (as a float of seconds since the game start).
|
||||
*
|
||||
* This value will start at 1/60th of a second regardless of engine the game
|
||||
* is running on to avoid divide by zero errors.
|
||||
*/
|
||||
float last;
|
||||
|
||||
/**
|
||||
* Fixed timestep that occured since the last frame. Typically locked to 1/60
|
||||
* steps per second.
|
||||
*/
|
||||
float delta;
|
||||
} gametime_t;
|
||||
|
||||
extern gametime_t TIME_STATE;
|
@ -9,10 +9,10 @@
|
||||
|
||||
|
||||
/** 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 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_NULL (inputbind_t)0x00
|
||||
#define INPUT_BIND_COUNT 128
|
||||
|
@ -7,17 +7,50 @@
|
||||
|
||||
#pragma once
|
||||
#include "../../libs.h"
|
||||
#include "../../display/spritebatch.h"
|
||||
|
||||
/** Entity ID Definitions */
|
||||
#define ENTITY_TYPE_NULL 0x00
|
||||
#define ENTITY_TYPE_PLAYER 0x01
|
||||
|
||||
/** Max count of entities in the world */
|
||||
#define ENTITY_COUNT 64
|
||||
|
||||
/** Count of different types of entities */
|
||||
#define ENTITY_TYPE_COUNT ENTITY_TYPE_PLAYER + 1
|
||||
|
||||
/** Unique Entity ID */
|
||||
typedef uint8_t entityid_t;
|
||||
|
||||
/** Unique Entity ID for the Entity Type */
|
||||
typedef uint8_t entitytypeid_t;
|
||||
|
||||
/** Entity Definition */
|
||||
typedef struct {
|
||||
entitytypeid_t type;
|
||||
int32_t gridX, gridY, gridZ;
|
||||
int32_t oldGridX, oldGridY, oldGridZ;
|
||||
float positionX, positionY, positionZ;
|
||||
} entity_t;
|
||||
|
||||
/** Definition for an entity type */
|
||||
typedef struct {
|
||||
entity_t entities[ENTITY_COUNT]
|
||||
void (*entityInit)(entityid_t entityId, entity_t *entity);
|
||||
void (*entityUpdate)(entityid_t entityId, entity_t *entity);
|
||||
void (*entityDispose)(entityid_t entityId, entity_t *entity);
|
||||
} entitytype_t;
|
||||
|
||||
/** Entity State Management */
|
||||
typedef struct {
|
||||
/** Entities within the state */
|
||||
entity_t entities[ENTITY_COUNT];
|
||||
|
||||
/** Sprite Batch in the state */
|
||||
spritebatch_t *spriteBatch;
|
||||
} entitystate_t;
|
||||
|
||||
extern entitystate_t ENTITY_STATE;
|
||||
/** Global Entity State */
|
||||
extern entitystate_t ENTITY_STATE;
|
||||
|
||||
/** Global Entity Type Definitions */
|
||||
extern entitytype_t ENTITY_TYPES[ENTITY_TYPE_COUNT];
|
Reference in New Issue
Block a user