Many issues restructuring the program, needs cleaning
This commit is contained in:
Regular → Executable
+16
-18
@@ -1,18 +1,16 @@
|
||||
#ifndef COMMON_H
|
||||
#define COMMON_H
|
||||
|
||||
#include <SFML\Graphics.hpp>
|
||||
|
||||
const int kGridSize = 25;
|
||||
|
||||
enum PlayerDirection
|
||||
{
|
||||
kLeft = 1,
|
||||
kUp = 2,
|
||||
kDown = 3,
|
||||
kRight = 4
|
||||
};
|
||||
|
||||
bool GlobalCollision(sf::Vector2f object1Position, sf::Vector2f object2Position);
|
||||
|
||||
#endif
|
||||
#ifndef COMMON_H
|
||||
#define COMMON_H
|
||||
|
||||
#include <SFML/Graphics.hpp>
|
||||
|
||||
enum PlayerDirection
|
||||
{
|
||||
kLeft = 1,
|
||||
kUp = 2,
|
||||
kDown = 3,
|
||||
kRight = 4
|
||||
};
|
||||
|
||||
bool GlobalCollision(sf::Vector2f object1Position, sf::Vector2f object2Position);
|
||||
|
||||
#endif
|
||||
|
||||
Regular → Executable
+50
-36
@@ -1,36 +1,50 @@
|
||||
#ifndef DISPLAY_H
|
||||
#define DISPLAY_H
|
||||
|
||||
class DisplayInterface
|
||||
{
|
||||
public:
|
||||
DisplayInterface(void);
|
||||
protected:
|
||||
virtual void DisplayGameState(void) = 0;
|
||||
private:
|
||||
;
|
||||
};
|
||||
|
||||
class CommandLine : public DisplayInterface
|
||||
{
|
||||
public:
|
||||
CommandLine(void) = default;
|
||||
void DisplayGameState(void);
|
||||
protected:
|
||||
;
|
||||
private:
|
||||
;
|
||||
};
|
||||
|
||||
class GameWindow : public DisplayInterface
|
||||
{
|
||||
public:
|
||||
GameWindow(void) = default;
|
||||
void DisplayGameState(void);
|
||||
protected:
|
||||
;
|
||||
private:
|
||||
;
|
||||
};
|
||||
|
||||
#endif
|
||||
#ifndef DISPLAY_H
|
||||
#define DISPLAY_H
|
||||
|
||||
#include <SFML/Graphics.hpp>
|
||||
|
||||
class DisplayInterface
|
||||
{
|
||||
public:
|
||||
sf::Vector2f gameBoundaries;
|
||||
DisplayInterface(void);
|
||||
bool IsOpen(void);
|
||||
protected:
|
||||
bool isGameStillRunning;
|
||||
virtual void DisplayGameState(void) = 0;
|
||||
virtual void DisplayEndScreen(void) = 0;
|
||||
virtual void StartGame(void) = 0;
|
||||
private:
|
||||
;
|
||||
};
|
||||
|
||||
class CommandLine : public DisplayInterface
|
||||
{
|
||||
public:
|
||||
CommandLine(void);
|
||||
void DisplayGameState(void);
|
||||
void DisplayEndScreen(void);
|
||||
void StartGame(void);
|
||||
protected:
|
||||
;
|
||||
private:
|
||||
const int kGridSize = 25;
|
||||
};
|
||||
|
||||
class SFML : public DisplayInterface
|
||||
{
|
||||
public:
|
||||
SFML(void);
|
||||
void DisplayGameState(void);
|
||||
void DisplayEndScreen(void);
|
||||
void StartGame(void);
|
||||
void UpdateResolution(sf::Vector2i newResolution);
|
||||
protected:
|
||||
;
|
||||
private:
|
||||
sf::Time delay;
|
||||
sf::RenderWindow gameWindow;
|
||||
sf::VideoMode gameVideoSettings;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Regular → Executable
+14
@@ -0,0 +1,14 @@
|
||||
#ifndef GAME_H
|
||||
#define GAME_H
|
||||
|
||||
class Game
|
||||
{
|
||||
public:
|
||||
;
|
||||
protected:
|
||||
;
|
||||
private:
|
||||
;
|
||||
};
|
||||
|
||||
#endif
|
||||
Regular → Executable
+2
-5
@@ -3,7 +3,7 @@
|
||||
#define GAMESTATE_H
|
||||
|
||||
#include <memory>
|
||||
#include <SFML\Graphics.hpp>
|
||||
#include <SFML/Graphics.hpp>
|
||||
#include "snake.h"
|
||||
#include "display.h"
|
||||
|
||||
@@ -13,22 +13,19 @@ public:
|
||||
std::vector< std::vector<char> > gameBoard;
|
||||
bool useSFML = 1;
|
||||
GameState();
|
||||
GameState(int newHorizontal, int newVertical);
|
||||
void StartGame(void);
|
||||
sf::Vector2f GetGameBoundaries(void);
|
||||
protected:
|
||||
;
|
||||
private:
|
||||
std::unique_ptr<DisplayInterface> graphics;
|
||||
sf::RenderWindow gameWindow;
|
||||
sf::VideoMode gameVideoSettings;
|
||||
SnakeFood playerFood;
|
||||
Snake player;
|
||||
sf::Time delay;
|
||||
void DisplayEndScreen(void);
|
||||
void GetKeyboardInput(void);
|
||||
bool PlayerWantsToContinue(void);
|
||||
void RegenerateFood(void);
|
||||
void ResetGameBoard(void);
|
||||
void RunGameLoop(void);
|
||||
void RenderWindow(void);
|
||||
};
|
||||
|
||||
Regular → Executable
+1
-1
@@ -3,7 +3,7 @@
|
||||
#define SNAKE_H
|
||||
|
||||
#include <deque>
|
||||
#include <SFML\Graphics.hpp>
|
||||
#include <SFML/Graphics.hpp>
|
||||
#include "snakefood.h"
|
||||
|
||||
|
||||
|
||||
Regular → Executable
+1
-1
@@ -2,7 +2,7 @@
|
||||
#ifndef SNAKEFOOD_H
|
||||
#define SNAKEFOOD_H
|
||||
|
||||
#include <SFML\Graphics.hpp>
|
||||
#include <SFML/Graphics.hpp>
|
||||
#include <random>
|
||||
|
||||
class SnakeFood
|
||||
|
||||
Reference in New Issue
Block a user