Mana
Loading...
Searching...
No Matches
actor.cpp
Go to the documentation of this file.
1/*
2 * The Mana Client
3 * Copyright (C) 2010-2012 The Mana Developers
4 *
5 * This file is part of The Mana Client.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#include "actor.h"
22
23#include "map.h"
24
25Actor::Actor() = default;
26
28{
29 Actor::setMap(nullptr);
30}
31
33{
34 // Remove Actor from potential previous map
35 if (mMap)
37
38 mMap = map;
39
40 // Add Actor to potential new map
41 if (mMap)
42 mMapActor = mMap->addActor(this);
43}
44
45int Actor::getTileX() const
46{
47 return getPixelX() / mMap->getTileWidth();
48}
49
50int Actor::getTileY() const
51{
52 return getPixelY() / mMap->getTileHeight();
53}
virtual void setMap(Map *map)
Definition actor.cpp:32
int getPixelX() const
Returns the pixels X coordinate of the actor.
Definition actor.h:65
virtual int getTileY() const
Returns the y coordinate in tiles of the actor.
Definition actor.cpp:50
int getPixelY() const
Returns the pixel Y coordinate of the actor.
Definition actor.h:71
virtual int getTileX() const
Returns the x coordinate in tiles of the actor.
Definition actor.cpp:45
Actors::iterator mMapActor
Definition actor.h:117
Map * mMap
Definition actor.h:113
virtual ~Actor()
Definition actor.cpp:27
A tile map.
Definition map.h:147
int getTileHeight() const
Returns the tile height used by this map.
Definition map.h:271
void removeActor(Actors::iterator iterator)
Removes an actor from the map.
Definition map.cpp:588
int getTileWidth() const
Returns the tile width of this map.
Definition map.h:265
Actors::iterator addActor(Actor *actor)
Adds an actor to the map.
Definition map.cpp:582