forked from raydelto/GeometryWars
/
Entity.cpp
71 lines (57 loc) · 1.29 KB
/
Entity.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
//#include "Utility/package.hpp"
#include "Entity.hpp"
//---------------------------------------------------------------------------------
// Written by Terence J. Grant - tjgrant [at] tatewake [dot] com
// Find the full tutorial at: http://gamedev.tutsplus.com/series/
//----------------------------------------------------------------------------------
Entity::Entity()
: mImage(NULL),
mColor(1,1,1,1),
mPosition(0,0),
mVelocity(0,0),
mOrientation(0),
mRadius(20),
mIsExpired(false),
mKind(kDontCare)
{
}
Entity::~Entity()
{
}
tDimension2f Entity::getSize() const
{
return (mImage == NULL) ? tDimension2f(0,0) : mImage->getSurfaceSize();
}
void Entity::draw(tSpriteBatch* spriteBatch)
{
spriteBatch->draw(1, mImage, tPoint2f((int32_t)mPosition.x, (int32_t)mPosition.y), tOptional<tRectf>(), mColor,
mOrientation, getSize() / 2, tVector2f(1,1));
}
tPoint2f Entity::getPosition() const
{
return mPosition;
}
tVector2f Entity::getVelocity() const
{
return mVelocity;
}
void Entity::setVelocity(const tVector2f& nv)
{
mVelocity = nv;
}
float Entity::getRadius() const
{
return mRadius;
}
bool Entity::isExpired() const
{
return mIsExpired;
}
Entity::Kind Entity::getKind() const
{
return mKind;
}
void Entity::setExpired()
{
mIsExpired = true;
}