-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHero.cpp
More file actions
52 lines (46 loc) · 1.01 KB
/
Hero.cpp
File metadata and controls
52 lines (46 loc) · 1.01 KB
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
/**
* @file Hero.cpp
* @date 2012-05-24
*
*/
#include "Hero.h"
void Hero::OnCreate ()
{
// Get movement speed from config value
m_movementSpeed = orxConfig_GetFloat ("MovementSpeed");
}
void Hero::OnDelete ()
{
// Do nothing when deleted
}
void Hero::Update(const orxCLOCK_INFO &_rstInfo)
{
// Always initialize thy variables
orxVECTOR speed = orxVECTOR_0;
if (orxInput_IsActive ("MoveLeft"))
{
speed.fX = -m_movementSpeed;
}
else if (orxInput_IsActive ("MoveUp"))
{
speed.fY = -m_movementSpeed;
}
else if (orxInput_IsActive ("MoveRight"))
{
speed.fX = m_movementSpeed;
}
else if (orxInput_IsActive ("MoveDown"))
{
speed.fY = m_movementSpeed;
}
SetSpeed (speed, false);
}
orxBOOL Hero::OnCollide(ScrollObject *_poCollider,
const orxSTRING _zPartName,
const orxVECTOR &_rvPosition,
const orxVECTOR &_rvNormal)
{
// Add flash effect
AddFX ("FX-Flash");
return true;
}