75 lines
946 B
C++
75 lines
946 B
C++
#pragma once
|
|
|
|
#include <vector>
|
|
|
|
#include <Util.h>
|
|
|
|
#include <SFML/Graphics.hpp>
|
|
#include <SFML/Audio.hpp>
|
|
#include <imgui-SFML.h>
|
|
#include <imgui.h>
|
|
|
|
|
|
class SnakeNode
|
|
{
|
|
|
|
};
|
|
|
|
struct Player
|
|
{
|
|
Player() = default;
|
|
Player(sf::Vector2i gridPos_in);
|
|
|
|
sf::Vector2i gridPos{};
|
|
sf::Vector2i previousGridPos{};
|
|
sf::Vector2f windowPos{};
|
|
int score{};
|
|
int lives{3};
|
|
bool left{false};
|
|
bool right{false};
|
|
bool up{false};
|
|
bool down{false};
|
|
};
|
|
|
|
class Game
|
|
{
|
|
public:
|
|
Game(bool useImgui_in);
|
|
|
|
void run();
|
|
|
|
private:
|
|
void imgui();
|
|
|
|
void render();
|
|
|
|
void input();
|
|
|
|
void collision();
|
|
|
|
void movement();
|
|
|
|
void resetGame();
|
|
|
|
bool parseConfigFile();
|
|
|
|
void soundSystem();
|
|
|
|
void scoreSystem();
|
|
|
|
|
|
private:
|
|
sf::Clock clock;
|
|
sf::RenderWindow window;
|
|
sf::Font font;
|
|
sf::Text lives;
|
|
sf::Text score;
|
|
|
|
Player player;
|
|
|
|
// mostly used for imgui
|
|
int framerate{};
|
|
float volume{};
|
|
bool useImgui;
|
|
static constexpr unsigned int numPhysicsUpdates{4};
|
|
}; |