-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBlueJet.cpp
78 lines (64 loc) · 1.98 KB
/
BlueJet.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
72
73
74
75
76
77
78
#include "BlueJet.h"
#include "Application.h"
#include "ModuleCollisions.h"
#include "ModuleParticles.h"
#include "ModuleAudio.h"
#include "ModulePlayer.h"
#include "ModuleLevel2.h"
#include "SetBulletDirection.h"
BlueJet::BlueJet(int x, int y,bool spawnRight) : Enemy(x, y, spawnRight)
{
flyRight.PushBack({ 308, 131, 30, 9 });
flyLeft.PushBack({ 207, 131, 30, 9 });
// Have the blue jet describe a path in the screen
if (spawnRight) {
if (spawnPos.y < SCREEN_HEIGHT / 2)
{
path.PushBack({ -3.0f, 0.0f }, 20,&flyLeft);
path.PushBack({ -3.0f, 1.0f }, 40, &flyLeft);
path.PushBack({ -3.0f, 0.0f }, 60, &flyLeft);
}else if(spawnPos.y == SCREEN_HEIGHT/2) {
path.PushBack({ -3.0f, 0.0f }, 20, &flyLeft);
path.PushBack({ -3.0f, 0.0f }, 40, &flyLeft);
path.PushBack({ -3.0f, 0.0f }, 60, &flyLeft);
}
else
{
path.PushBack({ -3.0f, 0.0f }, 20, &flyLeft);
path.PushBack({ -3.0f, -1.0f }, 40, &flyLeft);
path.PushBack({ -3.0f, 0.0f }, 60, &flyLeft);
}
}else {
if (spawnPos.y < SCREEN_HEIGHT / 2)
{
path.PushBack({ 3.0f, 0.0f }, 20, &flyRight);
path.PushBack({ 3.0f, 1.0f }, 40, &flyRight);
path.PushBack({ 3.0f, 0.0f }, 60, &flyRight);
}
else
{
path.PushBack({ 3.0f, 0.0f }, 20, &flyRight);
path.PushBack({ 3.0f, -1.0f }, 40, &flyRight);
path.PushBack({ 3.0f, 0.0f }, 60, &flyRight);
}
}
collider = App->collisions->AddCollider({ position.x, position.y, 30, 9 }, Collider::Type::ENEMY, (Module*)App->enemies);
scoreGiven = 100;
moneyGiven = 300;
}
void BlueJet::Update()
{
path.Update();
position = spawnPos + path.GetRelativePosition();
currentAnim = path.GetCurrentAnimation();
// Call to the base class. It must be called at the end
// It will update the collider depending on the position
Enemy::Update();
shootingFrequency++;
if (shootingFrequency > 120)
{
shootingFrequency = 0;
SetBulletDirection(this);
App->particles->AddParticle(App->particles->enemyBullet, position.x + 32, position.y, Collider::Type::ENEMY_SHOT);
}
}