-
Notifications
You must be signed in to change notification settings - Fork 0
/
Entity.cpp
43 lines (36 loc) · 835 Bytes
/
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
#include <iostream>
using std::cout;
using std::endl;
#include "Entity.h"
Entity::Entity(const Sprite &_sprite, float2 _position, float _orientation)
:sprite(_sprite)
,position(_position)
,orientation(_orientation)
,velocity(float2())
,radius(.45f)
//,hp(100)
{
cout<<"Entity::Entity()"<<endl;
}
Entity::~Entity()
{
cout<<"Entity::~Entity()"<<endl;
}
void Entity::update()
{
}
void Entity::draw()
{
sprite.draw(position, orientation);
}
float2 Entity::collisionSeparate(Entity *e, float2 pos, float2 v, float o)
{
float2 r;
if ((position - e->position).len() < radius + e->radius)
r = (position - e->position).normalized()
* (radius + e->radius - (position - e->position).len());
e->position = pos;
e->orientation = o;
e->velocity = v;
return r;
}