-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbullet.h
More file actions
31 lines (26 loc) · 919 Bytes
/
bullet.h
File metadata and controls
31 lines (26 loc) · 919 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
#pragma once
#include <SFML/Graphics.hpp>
class Bullet : private sf::Sprite
{
private:
int speedy_; // Vertical speed
public:
// bool alive = true; // If bullet is in screen and has not collided. In case of rapid bullet implementation. when alive bullet may be fired or not
bool fired = false; // If bullet has been fired or not
public:
// Constructor
Bullet(sf::Texture &bullet_texture, sf::Vector2f playerposition);
// Setter for speed
void setSpeed(int speedy);
// Draw on window
void drawBullet(sf::RenderWindow &window);
// Bullet movement
void animate(sf::Time elapsed, sf::Vector2f playerposition);
// Get bullet globalbounds to check for collision
sf::FloatRect getGbounds();
private:
// Set position for bullet
void setBulletPosition(sf::Vector2f playerposition);
// Check if bullet is still in bounds and not collided
void isAlive();
};