feat(shield): added shields

This commit is contained in:
2024-01-23 11:40:46 +01:00
parent 15c745d7c0
commit d67394aaec
10 changed files with 127 additions and 10 deletions
+6 -2
View File
@@ -4,6 +4,7 @@
#include <SFML/Graphics.hpp>
#include "Player.h"
#include "Laser.h"
#include "Shield.h"
using namespace std;
using namespace sf;
@@ -15,14 +16,17 @@ public:
void run();
void handleInputs();
void handleLasersCollision();
private:
Clock _clock;
RenderWindow _window{ VideoMode::getFullscreenModes()[0], "Space Invader", Style::Fullscreen };
//RenderWindow _window{ VideoMode::getFullscreenModes()[0], "Space Invader", Style::Fullscreen };
RenderWindow _window{ VideoMode(1024, 800), "Space Invader", Style::Close | Style::Titlebar};
Player _player = { _window.getSize() };
vector<Laser *> _lasers;
vector<Laser*> _lasers;
vector<Shield*> _shields;
};
+2 -1
View File
@@ -9,7 +9,8 @@ using namespace sf;
class Laser
{
public:
Laser();
Laser() {};
Laser(Window& window);
RectangleShape& getShape() { return _laser; }
+4 -1
View File
@@ -1,7 +1,10 @@
#pragma once
#define _USE_MATH_DEFINES
#include <SFML/Graphics.hpp>
#include <iostream>
#include <cmath>
using namespace std;
using namespace sf;
@@ -11,7 +14,7 @@ class Player
public:
Player(Vector2u screenSize);
CircleShape getShape() { return _shape; };
CircleShape& getShape() { return _shape; };
void move(int direction);
private:
+26
View File
@@ -0,0 +1,26 @@
#pragma once
#include <iostream>
#include <string>
#include <SFML/Graphics.hpp>
using namespace sf;
using namespace std;
class Shield
{
public:
Shield() {};
Shield(Window& window);
void setPosition(Vector2f position);
RectangleShape& getShape() { return _shape; };
int getLife() const { return _life; };
void decreaseLife() { _life -= 1; };
private:
int _life = 10;
RectangleShape _shape;
};