-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlayerBullet.cpp
More file actions
44 lines (39 loc) · 938 Bytes
/
PlayerBullet.cpp
File metadata and controls
44 lines (39 loc) · 938 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
42
#include "PlayerBullet.h"
PlayerBullet::PlayerBullet()
{
bulletColor = sf::Color::Yellow;
bulletSpeed = 15.f;
resolutionHeight = 0.f;
collidedEnemy = false;
}
PlayerBullet::PlayerBullet(int windowHeight, sf::Vector2f playerPosition)
: Bullet(windowHeight, playerPosition)
{
initVariables(windowHeight);
initShape(playerPosition);
}
PlayerBullet::~PlayerBullet()
{
}
void PlayerBullet::initVariables(int windowHeight)
{
bulletColor = sf::Color::Yellow;
bulletSpeed = 15;
this->resolutionHeight = windowHeight;
collidedEnemy = false;
}
void PlayerBullet::initShape(sf::Vector2f playerPosition)
{
line.setFillColor(bulletColor);
line.setSize(sf::Vector2<float>(bulletSizeX, bulletSizeY));
line.setOrigin(line.getSize().x / 2, 0.f);
line.setPosition(playerPosition.x, playerPosition.y);
}
void PlayerBullet::moveBullet()
{
line.move(0.0f, -bulletSpeed);
}
void PlayerBullet::enemyCollision()
{
collidedEnemy = true;
}