-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInvader.cpp
39 lines (33 loc) · 830 Bytes
/
Invader.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
#include "pch.h"
#include "Invader.h"
#include "Math.h"
#include "World.h"
#include "Sounds.h"
#include "Game.h"
void Invader::Advance(float delta)
{
ai.Advance(delta, *this);
base::Advance(delta);
}
void Invader::Collide(const Entity& other)
{
if (other.GetType() == EntityType::PlayerProjectile )
{
auto score = 100 * (1 + ((Projectile&)other).GetGeneration());
auto points_added = GetGame().AddScore(score);
auto score_str = std::to_string(points_added);
auto score_fx = SoundEffect{ score_str, GetProjection(), Vector2{0, 0}, 100.f };
score_fx.spread = 0.05f;
score_fx.spacing = 10.0f;
score_fx.fade_start = 50.0f;
SoundEffect::Play(score_fx);
Life() -= 100.f;
Destroy();
}
ai.OnCollide(*this, other);
}
void Invader::Destroy()
{
SoundEffect::Play("pow", GetProjection());
base::Destroy();
}