-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathShip.cpp
57 lines (48 loc) · 1.09 KB
/
Ship.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
#include "Ship.h"
Ship::Ship()
{
active = true;
}
void Ship::SetKeys(int aUp, int aDown, int aLeft, int aRight, int aFire)
{
bUp = aUp;
bDown = aDown;
bLeft = aLeft;
bRight = aRight;
bFire = aFire;
}
void Ship::Update(KeyStater &aKeys, float aWidth, float aHeight)
{
if (aKeys.IsPressed(bUp)) //HANDLING DIRECTIONAL INPUT
dir.y = 1;
if (aKeys.IsPressed(bDown))
dir.y = -1;
if (aKeys.IsPressed(bLeft))
dir.x = -1;
if (aKeys.IsPressed(bRight))
dir.x = 1;
if (aKeys.IsReleased(bUp) && aKeys.IsDown(bDown))
dir.y = -1;
if (aKeys.IsReleased(bDown) && aKeys.IsDown(bUp))
dir.y = 1;
if (aKeys.IsReleased(bRight) && aKeys.IsDown(bLeft))
dir.x = -1;
if (aKeys.IsReleased(bLeft) && aKeys.IsDown(bRight))
dir.x = 1;
if (aKeys.IsUp(bUp) && aKeys.IsUp(bDown))
dir.y = 0;
if (aKeys.IsUp(bLeft) && aKeys.IsUp(bRight))
dir.x = 0;
//X AND Y DIRECTION LIMITS
if (!CheckPointBox(ForwardMove(), Box(0, (0.1 * aHeight), aWidth, (0.6 * aHeight))))
{
dir.y = 0;
}
if (!CheckPointBox(ForwardMove(), Box((0.05 * aWidth), 0, (0.95 * aWidth), aHeight)))
{
dir.x = 0;
}
}
Ship::~Ship()
{
}