Prepping map stuff
This commit is contained in:
@@ -81,9 +81,11 @@ void entityWalk(entity_t *entity, const entitydir_t direction) {
|
||||
// Check one level down for walkable tile (stairs down)
|
||||
worldpos_t belowPos = newPos;
|
||||
belowPos.z -= 1;
|
||||
tile = mapGetTile(belowPos);
|
||||
|
||||
if(tile != TILE_NULL) newPos.z -= 1;
|
||||
tile_t belowTile = mapGetTile(belowPos);
|
||||
|
||||
if(belowTile == TILE_STAIRS_UP) {
|
||||
tile = TILE_STAIRS_DOWN;// Mark current as stairs down
|
||||
}
|
||||
}
|
||||
|
||||
// Tile walkable?
|
||||
@@ -98,11 +100,19 @@ void entityWalk(entity_t *entity, const entitydir_t direction) {
|
||||
return;// Blocked
|
||||
} while(++other, other < &ENTITIES[ENTITY_COUNT]);
|
||||
|
||||
entity->lastPosition = entity->position;
|
||||
entity->position = newPos;
|
||||
entity->animation = ENTITY_ANIM_WALK;
|
||||
entity->animTime = ENTITY_ANIM_WALK_DURATION;// TODO: Running vs walking
|
||||
|
||||
// We are comitting, we can run effects here.
|
||||
if(tile == TILE_STAIRS_DOWN) {
|
||||
// Moving down a level
|
||||
entity->position.z -= 1;
|
||||
} else if(tile == TILE_STAIRS_UP) {
|
||||
// Moving up a level
|
||||
entity->position.z += 1;
|
||||
}
|
||||
}
|
||||
|
||||
entity_t * entityGetAt(const worldpos_t position) {
|
||||
|
||||
@@ -23,6 +23,7 @@ typedef struct entity_s {
|
||||
// Movement
|
||||
entitydir_t direction;
|
||||
worldpos_t position;
|
||||
worldpos_t lastPosition;
|
||||
|
||||
entityanim_t animation;
|
||||
float_t animTime;
|
||||
|
||||
Reference in New Issue
Block a user