refactor: re-organize code
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdlib>
|
||||
#include <SFML/Graphics.hpp>
|
||||
#include "Player.h"
|
||||
#include "Laser.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace sf;
|
||||
|
||||
class GameManager
|
||||
{
|
||||
public:
|
||||
GameManager();
|
||||
|
||||
void run();
|
||||
void handleInputs();
|
||||
|
||||
private:
|
||||
Clock _clock;
|
||||
|
||||
RenderWindow _window{ VideoMode::getFullscreenModes()[0], "Space Invader", Style::Fullscreen };
|
||||
|
||||
Player _player = { _window.getSize() };
|
||||
|
||||
vector<Laser *> _lasers;
|
||||
};
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
|
||||
#include <iostream>
|
||||
#include <SFML/Graphics.hpp>
|
||||
|
||||
using namespace std;
|
||||
using namespace sf;
|
||||
|
||||
class Laser
|
||||
{
|
||||
public:
|
||||
Laser();
|
||||
|
||||
RectangleShape& getShape() { return _laser; }
|
||||
|
||||
void setInitialPosition(Vector2f position);
|
||||
|
||||
private:
|
||||
RectangleShape _laser;
|
||||
};
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
#pragma once
|
||||
|
||||
#include <SFML/Graphics.hpp>
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
using namespace sf;
|
||||
|
||||
class Player
|
||||
{
|
||||
public:
|
||||
Player(Vector2u screenSize);
|
||||
|
||||
CircleShape getShape() { return _shape; };
|
||||
void move(int direction);
|
||||
|
||||
private:
|
||||
CircleShape _shape;
|
||||
|
||||
int _screenWidth;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user