Added GameState and cleaned up unused code
This commit is contained in:
parent
e812588200
commit
1a90a4601a
24
src/GameState.cpp
Normal file
24
src/GameState.cpp
Normal file
@ -0,0 +1,24 @@
|
||||
#include <iostream>
|
||||
#include <SFML\Graphics.hpp>
|
||||
#include <SFML\System.hpp>
|
||||
#include "GameState.h"
|
||||
|
||||
GameState::GameState()
|
||||
{
|
||||
videoSizeHorizontal = 1024;
|
||||
videoSizeVertical = 725;
|
||||
sf::Vector2u newVideoSize(videoSizeHorizontal, videoSizeVertical);
|
||||
window.setSize(newVideoSize);
|
||||
window.setTitle("SnakePlusPlus");
|
||||
return;
|
||||
}
|
||||
|
||||
GameState::GameState(int newHorizontal, int newVertical)
|
||||
{
|
||||
videoSizeHorizontal = newHorizontal;
|
||||
videoSizeVertical = newVertical;
|
||||
sf::Vector2u newVideoSize(videoSizeHorizontal, videoSizeVertical);
|
||||
window.setSize(newVideoSize);
|
||||
window.setTitle("SnakePlusPlus");
|
||||
return;
|
||||
}
|
16
src/GameState.h
Normal file
16
src/GameState.h
Normal file
@ -0,0 +1,16 @@
|
||||
// GameState.h
|
||||
#ifndef GAMESTATE_H
|
||||
#define GAMESTATE_H
|
||||
|
||||
class GameState
|
||||
{
|
||||
private:
|
||||
int videoSizeHorizontal;
|
||||
int videoSizeVertical;
|
||||
sf::RenderWindow window;
|
||||
public:
|
||||
GameState();
|
||||
GameState(int newHorizontal, int newVertical);
|
||||
};
|
||||
|
||||
#endif
|
@ -67,8 +67,6 @@ sf::Vector2f CalculateNewPosition(int direction, sf::Vector2f position)
|
||||
// Move snake based on direction and test for eating food
|
||||
void Snake::MoveSnake(sf::RectangleShape& snakeFood)
|
||||
{
|
||||
// Create a new deque RectangleShape and pop old
|
||||
// Todo: Depreciate ExtendSnake and just add a collision test
|
||||
CheckDirection();
|
||||
sf::Vector2f newHeadPosition;
|
||||
newHeadPosition = GetSnakeHeadPosition();
|
||||
@ -151,5 +149,3 @@ Snake::Snake(sf::Vector2f head)
|
||||
snakeBody.push_back(newBodyPart);
|
||||
return;
|
||||
}
|
||||
// SnakeNode::SnakeNode();
|
||||
// SnakeNode::SnakeNode(sf::Vector2f addBodyPiece);
|
||||
|
@ -1,4 +1,4 @@
|
||||
//Snake.h
|
||||
// Snake.h
|
||||
#ifndef SNAKE_H
|
||||
#define SNAKE_H
|
||||
#include <queue>
|
||||
|
12
src/main.cpp
12
src/main.cpp
@ -3,18 +3,6 @@
|
||||
#include <SFML\System.hpp>
|
||||
#include "Snake.h"
|
||||
|
||||
|
||||
/*
|
||||
|
||||
TODO:
|
||||
Add ability for body to extend when eating food
|
||||
Each piece of queue has coordinates
|
||||
If head touches food, just add to queue, don't pop
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
int videoSizeHorizontal, videoSizeVertical;
|
||||
|
Loading…
Reference in New Issue
Block a user