Line |
Branch |
Exec |
Source |
1 |
|
|
/* |
2 |
|
|
** EPITECH PROJECT, 2024 |
3 |
|
|
** zappy |
4 |
|
|
** File description: |
5 |
|
|
** core |
6 |
|
|
*/ |
7 |
|
|
|
8 |
|
|
#ifndef CORE_HPP_ |
9 |
|
|
#define CORE_HPP_ |
10 |
|
|
|
11 |
|
|
#include <memory> |
12 |
|
|
|
13 |
|
|
#include "../scenes/IScene.hpp" |
14 |
|
|
#include "../../parser/ServerConnect.hpp" |
15 |
|
|
#include "../../parser/Parser.hpp" |
16 |
|
|
#include "../../parser/Data.hpp" |
17 |
|
|
#include "../../utils/CommandLineParser.hpp" |
18 |
|
|
|
19 |
|
|
#include <SFML/Graphics.hpp> |
20 |
|
|
#include <SFML/Audio.hpp> |
21 |
|
|
|
22 |
|
|
enum GameState { |
23 |
|
|
HOME, |
24 |
|
|
MENU, |
25 |
|
|
GAME, |
26 |
|
|
QUIT, |
27 |
|
|
END, |
28 |
|
|
WIN, |
29 |
|
|
DEFAULT, |
30 |
|
|
}; |
31 |
|
|
class Core { |
32 |
|
|
public: |
33 |
|
|
Core(int port, std::string ip); |
34 |
|
|
~Core() {}; |
35 |
|
|
|
36 |
|
|
void update(); |
37 |
|
|
void run(); |
38 |
|
|
void draw(); |
39 |
|
|
|
40 |
|
|
void newResolution(sf::Vector2f resolution); |
41 |
|
|
void switchFullscreen(); |
42 |
|
|
|
43 |
|
|
GameState _state; |
44 |
|
|
GameState _upperState; |
45 |
|
|
|
46 |
|
|
std::map<GameState, std::shared_ptr<IScene>> _scenes; |
47 |
|
✗ |
float getDeltaTime() { return _deltaTime; }; |
48 |
|
✗ |
sf::Font &getFont() { return _font; }; |
49 |
|
✗ |
sf::Vector2f getMousePos() { return _mousePos; }; |
50 |
|
|
sf::Vector2f getRealMousePos() { return _realMousePos; }; |
51 |
|
✗ |
sf::RenderWindow &getWindow() { return _window; }; |
52 |
|
|
|
53 |
|
|
bool connectToServer(int port, std::string ip); |
54 |
|
|
void backToHome(); |
55 |
|
|
Data _data; |
56 |
|
|
Parser _parser; |
57 |
|
|
ServerConnect _server; |
58 |
|
|
std::map<std::string, sf::Sound> _sounds; |
59 |
|
✗ |
bool isFullscreen() { return _fullscreen; } |
60 |
|
|
int _tickRate = 2; |
61 |
|
|
|
62 |
|
|
bool _funMode = false; |
63 |
|
|
std::string _winner = ""; |
64 |
|
|
private: |
65 |
|
|
sf::RenderWindow _window; |
66 |
|
|
sf::Event _event; |
67 |
|
|
sf::Clock _clock; |
68 |
|
|
float _deltaTime; |
69 |
|
|
sf::Vector2f _mousePos; |
70 |
|
|
sf::Vector2f _realMousePos; |
71 |
|
|
|
72 |
|
|
|
73 |
|
|
sf::Font _font; |
74 |
|
|
sf::Vector2f _resolution = sf::Vector2f(1280, 720); |
75 |
|
|
bool _fullscreen = false; |
76 |
|
|
sf::RectangleShape _shade; |
77 |
|
|
|
78 |
|
|
sf::Music _music; |
79 |
|
|
sf::Texture _cursorTexture; |
80 |
|
|
sf::Sprite _cursor; |
81 |
|
|
|
82 |
|
|
void initSounds(); |
83 |
|
|
void initCursor(); |
84 |
|
|
void initIcon(); |
85 |
|
|
}; |
86 |
|
|
|
87 |
|
|
#endif /* !CORE_HPP_ */ |
88 |
|
|
|