-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLaserBeam.cpp
More file actions
41 lines (38 loc) · 831 Bytes
/
LaserBeam.cpp
File metadata and controls
41 lines (38 loc) · 831 Bytes
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
#include "LaserBeam.h"
#include "GameEngine.h"
namespace ge{
LaserBeam::~LaserBeam()
{
}
LaserBeam::LaserBeam(int posX, int posY, bool bUp) :
MovingSprite(posX, posY, 20, 20, "LaserBeam.png"),
laserSpeed(0.3f)
{
if (bUp)
{
velocity.setY(-laserSpeed);
}
else
{
velocity.setY(laserSpeed);
}
std::cout << "LaserBeam Spawned" << std::endl;
}
bool LaserBeam::outsideBounce() {
if (position.getY() < 0 || position.getY() > * GameEngine::getInstance()->getScreenHeight())
{
std::cout << "LaserBeam Outside Bounce and will be removed" << std::endl;
return true;
}
else {
return false;
}
}
void LaserBeam::update(float delta) {
position += velocity * delta;
}
LaserBeam* LaserBeam::getInstance(int posX, int posY, bool bUp)
{
return new LaserBeam(posX, posY, bUp);
}
}