Mana
Loading...
Searching...
No Matches
actor.h
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#pragma once
22
23#include "vector.h"
24
25#include <list>
26
27class Actor;
28class Graphics;
29class Image;
30class Map;
31
32using Actors = std::list<Actor *>;
33
34class Actor
35{
36public:
38
39 virtual ~Actor();
40
48 virtual bool draw(Graphics *graphics, int offsetX, int offsetY) const = 0;
49
53 const Vector &getPosition() const
54 { return mPos; }
55
59 virtual void setPosition(const Vector &pos)
60 { mPos = pos; }
61
65 int getPixelX() const
66 { return (int) mPos.x; }
67
71 int getPixelY() const
72 { return (int) mPos.y; }
73
77 virtual int getDrawOrder() const
78 { return getPixelY(); }
79
84 virtual bool drawnWhenBehind() const
85 { return false; }
86
90 virtual int getTileX() const;
91
95 virtual int getTileY() const;
96
100 virtual float getAlpha() const = 0;
101
105 virtual void setAlpha(float alpha) = 0;
106
107 virtual void setMap(Map *map);
108
109 Map* getMap() const
110 { return mMap; }
111
112protected:
113 Map *mMap = nullptr;
116private:
117 Actors::iterator mMapActor;
118};
std::list< Actor * > Actors
Definition actor.h:32
Definition actor.h:35
Map * getMap() const
Definition actor.h:109
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 getDrawOrder() const
Returns the pixel Y coordinate that the actor should be drawn at.
Definition actor.h:77
virtual int getTileX() const
Returns the x coordinate in tiles of the actor.
Definition actor.cpp:45
Actors::iterator mMapActor
Definition actor.h:117
virtual void setPosition(const Vector &pos)
Sets the pixel position of this actor.
Definition actor.h:59
virtual bool draw(Graphics *graphics, int offsetX, int offsetY) const =0
Draws the Actor to the given graphics context.
Vector mPos
Position in pixels relative to map.
Definition actor.h:114
const Vector & getPosition() const
Returns the pixel position of this actor.
Definition actor.h:53
Map * mMap
Definition actor.h:113
virtual ~Actor()
Definition actor.cpp:27
virtual void setAlpha(float alpha)=0
Sets the alpha value used to draw the actor.
virtual float getAlpha() const =0
Returns the current alpha value used to draw the actor.
virtual bool drawnWhenBehind() const
Determines wether the actor should be drawn translucent when behind another object.
Definition actor.h:84
A central point of control for graphics.
Definition graphics.h:78
Defines a class for loading and storing images.
Definition image.h:45
A tile map.
Definition map.h:147
Vector class.
Definition vector.h:33
float y
Definition vector.h:172
float x
Definition vector.h:171
Graphics * graphics
Definition client.cpp:104