9 void MapObject::StartMovement()
12 Map::transformM2S( mapX
, mapY
, sx
, sy
);
13 movementX
= (float)sx
;
14 movementY
= (float)sy
;
16 if( isWalkable( mapX
+vX
, mapY
+vY
) )
20 if( isBitSet( Game::getMap()->tileAt( mapX
, mapY
)->typeMask
, Tile::TILE_SLOW
) )
21 speed
= SPEED() * 0.5f
;
29 bool MapObject::isWalkable( Uint8 X
, Uint8 Y
)
31 Tile
*t
= Game::getMap()->tileAt(X
, Y
);
33 if( isBitSet( t
->typeMask
, Tile::TILE_WALKABLE
) )
41 MapObject::MapObject( Uint8 X
, Uint8 Y
, Drawable
*graphic
) :
42 mapX(0), mapY(0), vX(0), vY(0), movementX(0), movementY(0), speed(0), walking(false), moving(false)
44 this->graphic
= graphic
;
48 MapObject::~MapObject()
53 void MapObject::UpdatePosition()
56 Map::transformM2S( mapX
, mapY
, sx
, sy
);
57 if( dst( movementX
, movementY
, (float)sx
, (float)sy
) < 0.5 )
59 OnTile( Game::getMap()->tileAt( mapX
, mapY
) );
71 dirX
= sign( sx
- movementX
) * speed
;
72 dirY
= sign( sy
- movementY
) * speed
;
80 void MapObject::Initialize() {}
81 void MapObject::DeInitialize() {}
83 void MapObject::Update()
91 void MapObject::Draw()
99 sx
= (Sint16
)movementX
;
100 sy
= (Sint16
)movementY
;
104 Map::transformM2S( mapX
, mapY
, sx
, sy
);
107 graphic
->Draw( sx
, sy
);
110 void MapObject::OnTile( Tile
*t
) {}
113 void MapObject::Teleport( Uint8 mapX
, Uint8 mapY
, Uint16 room
)
120 Uint8
MapObject::getMapX() { return mapX
; }
121 Uint8
MapObject::getMapY() { return mapY
; }
123 bool MapObject::Walking() { return walking
; }
125 void MapObject::setGraphic( Drawable
*graphic
)
127 this->graphic
= graphic
;
130 Drawable
*MapObject::getGraphic( )