8 void MapObject::StartMovement()
11 Map::transformM2S( mapX
, mapY
, sx
, sy
);
12 movementX
= (float)sx
;
13 movementY
= (float)sy
;
15 if( isWalkable( mapX
+vX
, mapY
+vY
) )
19 if( isBitSet( Game::getMap()->tileAt( mapX
, mapY
)->typeMask
, Tile::TILE_SLOW
) )
20 speed
= SPEED() * 0.5f
;
28 bool MapObject::isWalkable( Uint8 X
, Uint8 Y
)
30 Tile
*t
= Game::getMap()->tileAt(X
, Y
);
32 if( isBitSet( t
->typeMask
, Tile::TILE_WALKABLE
) )
40 MapObject::MapObject( Uint8 X
, Uint8 Y
) :
41 mapX(0), mapY(0), vX(0), vY(0), movementX(0), movementY(0), speed(0), walking(false), moving(false), tile(0)
46 MapObject::~MapObject() {}
48 void MapObject::UpdatePosition()
51 Map::transformM2S( mapX
, mapY
, sx
, sy
);
52 if( dst( movementX
, movementY
, (float)sx
, (float)sy
) < 0.5 )
59 OnTile( Game::getMap()->tileAt( mapX
, mapY
) );
65 dirX
= sign( sx
- movementX
) * speed
;
66 dirY
= sign( sy
- movementY
) * speed
;
74 void MapObject::Initialize() {}
75 void MapObject::DeInitialize() {}
77 void MapObject::Update()
85 void MapObject::Draw()
89 Game::getTileset()->Draw( (Sint16
)movementX
, (Sint16
)movementY
, tile
);
94 Map::transformM2S( mapX
, mapY
, sx
, sy
);
95 Game::getTileset()->Draw( sx
, sy
, tile
);
99 void MapObject::OnTile( Tile
*t
) {}
102 void MapObject::Teleport( Uint8 mapX
, Uint8 mapY
, Uint16 room
)
109 Uint8
MapObject::getMapX() { return mapX
; }
110 Uint8
MapObject::getMapY() { return mapY
; }