, partyLayout(0)
, monsters(0)
, numMonsters(0)
+, direction(ORIENTATION_NORTH)
, orientation(ORIENTATION_NORTH)
, speed(0)
, flags(0) {
void Entity::SetOrientation(Orientation o) {
orientation = o;
- UpdateVelocity();
if (CanTurn()) {
- runner.SetColOffset(orientation);
+ runner.SetColOffset(o);
}
}
+void Entity::SetDirection(Orientation o) {
+ direction = o;
+ UpdateVelocity();
+ SetOrientation(o);
+}
+
void Entity::SetSpeed(Fixed<8> s) {
speed = s;
UpdateVelocity();
velocity = Vector<Fixed<8> >();
return;
}
- switch (orientation) {
+ switch (direction) {
case ORIENTATION_NORTH:
velocity = Vector<Fixed<8> >(0, -speed);
break;
/// west sprites at offsets (0,0), (1,0), (2,0), and (3,0) respectively.
void SetSprite(const graphics::Sprite *s) { sprite = s; }
- /// Change the entity's orientation to given one.
- /// If the entity is moving, velocity is changed accordingly.
+ /// Change the entity's facing direction.
+ /// If the entity is moving, velocity is untouched.
void SetOrientation(Orientation);
Orientation GetOrientation() const { return orientation; }
+ /// Change the entity's orientation to given one.
+ /// If the entity is moving, velocity is changed accordingly.
+ /// Also changes the orientation to given direction.
+ void SetDirection(Orientation);
+ Orientation GetDirection() const { return direction; }
/// Set the entity's speed in pixels per second.
- /// This speed is then combined with the orientation to form a velocity.
+ /// This speed is then combined with the direction to form a velocity.
void SetSpeed(math::Fixed<8>);
/// Change to a natural, relaxed animation state (row offset 0).
math::Vector<int> tilePosition;
math::Vector<math::Fixed<8> > position;
math::Vector<math::Fixed<8> > velocity;
+ Orientation direction;
Orientation orientation;
math::Fixed<8> speed;
int flags;
return;
}
+ const Tile *tile(map->TileAt(nowLock));
+
if (nextDirection >= 0) {
if (afterLock) {
bool blocked(CheckBlocking());
OnMove(!blocked);
- controlled->SetOrientation(Entity::Orientation(nextDirection));
+ controlled->SetDirection(Entity::Orientation(nextDirection));
if (!blocked) {
afterLock = false;
controlled->SetSpeed(walkingSpeed);
moveTimer.Clear();
if (pushed) {
- pushed->SetOrientation(Entity::Orientation(nextDirection));
+ pushed->SetDirection(Entity::Orientation(nextDirection));
pushed->SetSpeed(walkingSpeed);
controlled->SetPushing();
} else {
controlled->SetSpeed(0);
StopFollowers(*controlled);
if (!moveTimer.Running()) {
- int tileSize((controlled->GetOrientation() % 2) ? map->Tileset()->Width() : map->Tileset()->Height());
+ int tileSize((controlled->GetDirection() % 2) ? map->Tileset()->Width() : map->Tileset()->Height());
Fixed<8> walkingInterval(tileSize);
walkingInterval /= walkingSpeed;
moveTimer = PhysicsTimers().StartInterval(walkingInterval.Int());
}
}
+ if (controlled->GetDirection() == Entity::ORIENTATION_SOUTH
+ && tile && tile->IsLadder()) {
+ controlled->SetOrientation(Entity::ORIENTATION_NORTH);
+ }
+
lastLock = nowLock;
}
Vector<int> direction(coords - fCoords);
if (direction.Y() < 0) {
- f.SetOrientation(Entity::ORIENTATION_NORTH);
+ f.SetDirection(Entity::ORIENTATION_NORTH);
f.SetSpeed(walkingSpeed);
f.StartAnimation(*this);
} else if (direction.X() > 0) {
- f.SetOrientation(Entity::ORIENTATION_EAST);
+ f.SetDirection(Entity::ORIENTATION_EAST);
f.SetSpeed(walkingSpeed);
f.StartAnimation(*this);
} else if (direction.Y() > 0) {
- f.SetOrientation(Entity::ORIENTATION_SOUTH);
+ f.SetDirection(Entity::ORIENTATION_SOUTH);
f.SetSpeed(walkingSpeed);
f.StartAnimation(*this);
} else if (direction.X() < 0) {
- f.SetOrientation(Entity::ORIENTATION_WEST);
+ f.SetDirection(Entity::ORIENTATION_WEST);
f.SetSpeed(walkingSpeed);
f.StartAnimation(*this);
} else {
Vector<int> position(coordinates * map->Tileset()->Size());
for (Entity *e(controlled); e; e = e->Follower()) {
e->Position() = position;
- e->SetOrientation(controlled->GetOrientation());
+ e->SetDirection(controlled->GetDirection());
}
LoadMap(newMap);
skipLock = true;
BLOCK_EAST = 0x02,
BLOCK_SOUTH = 0x04,
BLOCK_WEST = 0x08,
+ LADDER = 0x10,
};
SDL_Surface *BattleBackground() { return battlebg; }
bool BlocksSouth() const { return flags & BLOCK_SOUTH; }
bool BlocksWest() const { return flags & BLOCK_WEST; }
+ bool IsLadder() const { return flags & LADDER; }
+
static void CreateTypeDescription();
static void Construct(void *);