namespace WorldMapNS
{
-static const float TUXSPEED = 200;
+static const float TUXSPEED = 200;
static const float map_message_TIME = 2.8;
Tux::Tux(WorldMap* worldmap_)
: worldmap(worldmap_)
{
sprite.reset(sprite_manager->create("images/worldmap/common/tux.sprite"));
-
+
offset = 0;
moving = false;
direction = D_NONE;
case D_NONE:
break;
}
-
+
return Vector(x, y);
}
input_direction = dir;
}
-void
-Tux::tryStartWalking()
+void
+Tux::tryStartWalking()
{
if (moving)
- return;
+ return;
if (input_direction == D_NONE)
return;
}
}
-bool
+bool
Tux::canWalk(const Tile* tile, Direction dir)
{
return ((tile->getData() & Tile::WORLDMAP_NORTH && dir == D_NORTH) ||
(tile->getData() & Tile::WORLDMAP_WEST && dir == D_WEST));
}
-void
+void
Tux::tryContinueWalking(float elapsed_time)
{
if (!moving)
// if this is a special_tile with passive_message, display it
SpecialTile* special_tile = worldmap->at_special_tile();
if(special_tile)
- {
+ {
// direction and the apply_action_ are opposites, since they "see"
// directions in a different way
if((direction == D_NORTH && special_tile->apply_action_south) ||
// if user wants to change direction, try changing, else guess the direction in which to walk next
const Tile* tile = worldmap->at(tile_pos);
- if (direction != input_direction) {
- if(canWalk(tile, input_direction)) {
+ if (direction != input_direction) {
+ if(canWalk(tile, input_direction)) {
direction = input_direction;
back_direction = reverse_dir(direction);
}
// Walk automatically to the next tile
if(direction == D_NONE)
return;
-
+
Vector next_tile;
if (!worldmap->path_ok(direction, tile_pos, &next_tile)) {
log_warning << "Tilemap data is buggy" << std::endl;
void
Tux::update(float elapsed_time)
{
- updateInputDirection();
+ updateInputDirection();
if (moving)
tryContinueWalking(elapsed_time);
else