-
Notifications
You must be signed in to change notification settings - Fork 0
/
Laser.cpp
37 lines (33 loc) · 830 Bytes
/
Laser.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
#include "Laser.h"
#include "SpriteComponent.h"
#include "MoveComponent.h"
#include "CircleComponent.h"
#include "Game.h"
#include "Asteroid.h"
Laser::Laser(Game* game) :
Actor(game)
, mDeathTimer(1.0f)
{
// Create a sprite component
SpriteComponent* sc = new SpriteComponent(this);
sc->SetTexture(game->GetTexture("Assets/Laser.png"));
// Create a move component and set forward speed
MoveComponent* mc = new MoveComponent(this);
mc->SetForwardSpeed(800.0f);
// Create a circle component (for collision)
mCircle = new CircleComponent(this);
mCircle->SetRadius(11.0f);
}
void Laser::UpdateActor(float deltaTime)
{
// Do you intersect with an asteroid?
for (auto ast : GetGame()->GetAsteroids())
{
if (Intersect(*mCircle, *(ast->GetCircle())))
{
SetState(EDead);
ast->SetState(EDead);
break;
}
}
}