cam test
This commit is contained in:
@@ -46,6 +46,10 @@ void entityUpdate(entity_t *entity) {
|
||||
assertTrue(entity->type < ENTITY_TYPE_COUNT, "Invalid entity type");
|
||||
assertTrue(entity->type != ENTITY_TYPE_NULL, "Cannot have NULL entity type");
|
||||
|
||||
if(entity->type == ENTITY_TYPE_PLAYER) {
|
||||
playerMovement(entity);
|
||||
}
|
||||
|
||||
// Velocity
|
||||
for(uint8_t i = 0; i < WORLD_DIMENSIONS; i++) {
|
||||
if(entity->velocity[i] == 0) continue;
|
||||
|
||||
@@ -17,17 +17,20 @@ void playerInit(entity_t *entity) {
|
||||
void playerMovement(entity_t *entity) {
|
||||
assertNotNull(entity, "Entity pointer cannot be NULL");
|
||||
|
||||
// // Update velocity.
|
||||
// vec2 dir = {
|
||||
// inputAxis(INPUT_ACTION_LEFT, INPUT_ACTION_RIGHT),
|
||||
// inputAxis(INPUT_ACTION_DOWN, INPUT_ACTION_UP)
|
||||
// };
|
||||
// if(dir[0] == 0 && dir[1] == 0) return;
|
||||
// Get movement angle as 0-> normalized vector.
|
||||
{
|
||||
vec2 dir = {
|
||||
inputAxis(INPUT_ACTION_LEFT, INPUT_ACTION_RIGHT),
|
||||
inputAxis(INPUT_ACTION_DOWN, INPUT_ACTION_UP)
|
||||
};
|
||||
if(dir[0] == 0 && dir[1] == 0) return;
|
||||
glm_vec2_normalize(dir);
|
||||
|
||||
entity->velocity[0] += (worldsubtile_t)(PLAYER_SPEED * dir[0]);
|
||||
entity->velocity[1] += (worldsubtile_t)(PLAYER_SPEED * dir[1]);
|
||||
}
|
||||
|
||||
|
||||
// glm_vec2_normalize(dir);
|
||||
// entity->velocity[0] += PLAYER_SPEED * dir[0];
|
||||
// entity->velocity[1] += PLAYER_SPEED * dir[1];
|
||||
|
||||
// // Update direction.
|
||||
// if(dir[0] > 0) {
|
||||
// if(entity->direction == DIRECTION_RIGHT) {
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#pragma once
|
||||
#include "dusk.h"
|
||||
|
||||
#define PLAYER_SPEED 64.0f
|
||||
#define PLAYER_SPEED 4
|
||||
#define PLAYER_INTERACTION_RANGE 1.0f
|
||||
#define PLAYER_INTERACTION_SIZE 0.5f
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
#include "rpg.h"
|
||||
#include "entity/entity.h"
|
||||
#include "time/time.h"
|
||||
|
||||
errorret_t rpgInit(void) {
|
||||
// TEST
|
||||
@@ -20,6 +21,8 @@ errorret_t rpgInit(void) {
|
||||
}
|
||||
|
||||
void rpgUpdate(void) {
|
||||
if(!TIME.fixedUpdate) return;
|
||||
|
||||
entity_t *ent = &ENTITIES[0];
|
||||
do {
|
||||
if(ent->type == ENTITY_TYPE_NULL) continue;
|
||||
|
||||
Reference in New Issue
Block a user