48 lines
1.5 KiB
C
48 lines
1.5 KiB
C
/**
|
|
* Copyright (c) 2021 Dominic Masters
|
|
*
|
|
* This software is released under the MIT License.
|
|
* https://opensource.org/licenses/MIT
|
|
*/
|
|
|
|
#include "player.h"
|
|
|
|
void playerInit(entityid_t id, entity_t *entity) {
|
|
}
|
|
|
|
void playerUpdate(entityid_t id, entity_t *entity) {
|
|
// Movement
|
|
if(entity->state & ENTITY_STATE_WALKING) {
|
|
entityCommonMoveUpdate(id, entity);
|
|
} else {
|
|
if(inputIsPressed(INPUT_UP)) {
|
|
entityCommonTurn(id, entity, ENTITY_DIRECTION_NORTH);
|
|
} else if(inputIsPressed(INPUT_DOWN)) {
|
|
entityCommonTurn(id, entity, ENTITY_DIRECTION_SOUTH);
|
|
} else if(inputIsPressed(INPUT_LEFT)) {
|
|
entityCommonTurn(id, entity, ENTITY_DIRECTION_WEST);
|
|
} else if(inputIsPressed(INPUT_RIGHT)) {
|
|
entityCommonTurn(id, entity, ENTITY_DIRECTION_EAST);
|
|
|
|
} else if(inputIsDown(INPUT_UP)) {
|
|
entityCommonTurn(id, entity, ENTITY_DIRECTION_NORTH);
|
|
entityCommonMove(id, entity, 0, 1, 0);
|
|
} else if(inputIsDown(INPUT_DOWN)) {
|
|
entityCommonTurn(id, entity, ENTITY_DIRECTION_SOUTH);
|
|
entityCommonMove(id, entity, 0, -1, 0);
|
|
} else if(inputIsDown(INPUT_LEFT)) {
|
|
entityCommonTurn(id, entity, ENTITY_DIRECTION_WEST);
|
|
entityCommonMove(id, entity, -1, 0, 0);
|
|
} else if(inputIsDown(INPUT_RIGHT)) {
|
|
entityCommonTurn(id, entity, ENTITY_DIRECTION_EAST);
|
|
entityCommonMove(id, entity, 1, 0, 0);
|
|
}
|
|
}
|
|
}
|
|
|
|
void playerRender(entityid_t id, entity_t *entity) {
|
|
entityCommonRender(id, entity);
|
|
}
|
|
|
|
void playerDispose(entityid_t id, entity_t *entity) {
|
|
} |