Cleaned up file structure and added Makefile

This commit is contained in:
2023-02-26 18:18:45 -06:00
parent 2c4537eda7
commit c67178450d
5 changed files with 23 additions and 0 deletions
+22
View File
@@ -0,0 +1,22 @@
// GameState.h
#ifndef GAMESTATE_H
#define GAMESTATE_H
#include <SFML\Graphics.hpp>
class GameState
{
private:
public:
sf::VideoMode gameVideoMode;
sf::RenderWindow gameWindow;
GameState();
GameState(int newHorizontal, int newVertical);
void startNewGame();
/*
gameGridHorizontal = (videoSizeHorizontal // 25) * 25;
gameGridVertical = (videoSizeVertical // 25) * 25;
*/
// sf::Vector2f GetGameBoundaries();
};
#endif
+31
View File
@@ -0,0 +1,31 @@
// Snake.h
#ifndef SNAKE_H
#define SNAKE_H
#include <deque>
#include <SFML\Graphics.hpp>
#include "SnakeFood.h"
sf::Vector2f CalculateNewPosition(int direction, sf::Vector2f position);
bool GlobalCollision(sf::Vector2f object1Position, sf::Vector2f object2Position);
class Snake
{
private:
std::deque<sf::RectangleShape> snakeBody;
int snakeDirection = 0;
public:
Snake();
Snake(sf::Vector2f head);
sf::Vector2f GetSnakeHeadPosition();
sf::RectangleShape GetSnakeHead();
void DisplaySnake(sf::RenderWindow& window);
void MoveSnake(SnakeFood& playerFood, sf::VideoMode gameVideoMode);
void SnakeFoodCollision(SnakeFood& snakeFood, sf::VideoMode gameVideoMode);
void CheckDirection();
bool CheckBoundaries();
bool IsSelfCollision(sf::RectangleShape testRectangle);
};
#endif
+19
View File
@@ -0,0 +1,19 @@
// SnakeFood.h
#ifndef SNAKEFOOD_H
#define SNAKEFOOD_H
#include <random>
#include <SFML\Graphics.hpp>
class SnakeFood
{
private:
public:
sf::RectangleShape snakeFoodObject;
std::default_random_engine generator;
SnakeFood();
SnakeFood(sf::Vector2f snakeFoodSize);
void GenerateNewLocation(int horizontalLocation, int verticalLocation);
int GenerateRandomNumber(int generationLimit);
};
#endif