Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
f471c7d
feat(gui/quickMenu): add quickMenu class, included in game scene, whe…
eiffis Jun 16, 2026
2acfd47
feat(gui/quickMenu): add shader frag and vert, plus the asset for qui…
eiffis Jun 16, 2026
5b38755
fix(gui/quickMenu): change the png of the quickMenu
eiffis Jun 17, 2026
540ddcd
feat(gui/Buttons): add button interface and button class for implemen…
eiffis Jun 17, 2026
05bbb2e
feat(gui/assets): add speedButton for the speed of the game, and fix …
eiffis Jun 17, 2026
fba40eb
fix(gui/quickMenu): fix the size of the button for the quickMenu
eiffis Jun 18, 2026
3cb0959
feat(gui/quickMenu): add buttons for game speed in QM
eiffis Jun 18, 2026
6697904
feat(gui/Game): add reference of networkManager in GameClass for the …
eiffis Jun 18, 2026
67e3ca0
feat(gui/quickMenu): add decrease and increase lambda func for the bu…
eiffis Jun 18, 2026
60c4a4f
feat(gui/network): add sendSst and sendSgt methods in networkManager …
eiffis Jun 18, 2026
1e03010
feat(gui/SceneManager): add networkManager in the constructor of MENU…
eiffis Jun 18, 2026
4e0db7f
feat(gui/tileinventory): add tileinventory class
eiffis Jun 23, 2026
dfa75f7
feat(gui/assets): new versions of resources 0 and 3 and tile inventor…
eiffis Jun 24, 2026
d74e365
feat(gui/tileinventory): add the sprite of the assets on the left sid…
eiffis Jun 24, 2026
2e85bed
feat(gui/sprite): add setScale method
eiffis Jun 24, 2026
e0d3b00
feat(gui/game): add tile inventory unique ptr iscene, and when t is p…
eiffis Jun 24, 2026
0c60f92
feat(gui/tileinventory): add tileinventory class
eiffis Jun 23, 2026
bec66fb
feat(gui/assets): new versions of resources 0 and 3 and tile inventor…
eiffis Jun 24, 2026
9466225
feat(gui/tileinventory): add the sprite of the assets on the left sid…
eiffis Jun 24, 2026
ea105b3
feat(gui/sprite): add setScale method
eiffis Jun 24, 2026
a7bb523
feat(gui/game): add tile inventory unique ptr iscene, and when t is p…
eiffis Jun 24, 2026
86f3fad
Merge branch 'gui-inventory' of github.com:Savapitech/Zappy into gui-…
Arthur-gtr Jun 24, 2026
4c1d989
fix(gui/game): fix draw of the tile inventory
eiffis Jun 24, 2026
660f61b
fix(gui/tileinventory): add font to the tile inventory now the amount…
eiffis Jun 24, 2026
6a069c2
feat(gui/event): add mouse wheel move and wheel delta for the tile in…
eiffis Jun 24, 2026
7952618
feat(gui/window): add the handling of the mouse wheel for x11 linux
eiffis Jun 24, 2026
e8c318e
feat(gui/game): add logic for the mouse wheel, now we can move tile p…
eiffis Jun 24, 2026
db19ee5
feat(gui/playerinventory): add in the same way as the tile inventory …
eiffis Jun 25, 2026
a08b78e
feat(gui/tileinventory): handle the clic for the tile inventory thank…
eiffis Jun 25, 2026
a0f7225
feat(window/resize): scalable window
Arthur-gtr Jun 26, 2026
91e28df
feat(window): resize
Arthur-gtr Jun 26, 2026
9195a0f
feat(Network): add network argument
Arthur-gtr Jun 26, 2026
b73d251
feat(gui/raycasting): fix radian degre
Arthur-gtr Jun 26, 2026
0ff5d2f
feat(gui/quickmenu): resize quickmenu for dynamic size, fix button se…
eiffis Jun 26, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified gui/assets/resource_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gui/assets/tileInventory.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 5 additions & 2 deletions gui/src/Buttons/Button.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <iostream>
namespace Zappy
{
Button::Button(Texture &texture, float x, float y, float width, float height, std::function<void()> function) : _function(function), _width(width), _height(height), _x(x), _y(y), _hovered(false)
Button::Button(Texture &texture, float x, float y, float width, float height, std::function<void()> function, WindowSize &ws) : _function(function), _width(width), _height(height), _x(x), _y(y), _hovered(false), _ws(ws)
{
_sprite = std::make_unique<Sprite>(texture);
_sprite->setPosition(x, y);
Expand All @@ -14,7 +14,7 @@ Button::Button(Texture &texture, float x, float y, float width, float height, st
void Button::draw(Shader &shader)
{
if (_sprite) {
Zappy::Math::mat4 orthoProjection = Zappy::Math::ortho(0.0f, WIDTH, HEIGHT, 0.0f, -1.0f, 1.0f);
Zappy::Math::mat4 orthoProjection = Zappy::Math::ortho(0.0f, _ws.width, _ws.height, 0.0f, -1.0f, 1.0f);
Zappy::Math::mat4 view;
_sprite->draw(shader, view, orthoProjection);
}
Expand All @@ -24,6 +24,9 @@ void Button::setPosition(float x, float y)
{
_x = x;
_y = y;
if (_sprite) {
_sprite->setPosition(x, y);
}
}

void Button::update(const std::vector<Zappy::Event> &events)
Expand Down
3 changes: 2 additions & 1 deletion gui/src/Buttons/Button.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ namespace Zappy
float _x;
float _y;
bool _hovered;
WindowSize &_ws;
public:
Button(Texture& texture, float x, float y, float width, float height, std::function<void()> function);
Button(Texture& texture, float x, float y, float width, float height, std::function<void()> function, WindowSize &ws);
void draw(Shader &shader);
void setPosition(float x, float y);
void update(const std::vector<Zappy::Event> &events);
Expand Down
9 changes: 7 additions & 2 deletions gui/src/Core/Core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <chrono>
#include <thread>


namespace Zappy {

Core::Core() : _isRunning(true) {}
Expand All @@ -34,7 +35,7 @@ void Core::init(const std::string &ip, int port) {
if (!isConnected)
LOG_WARN("Failed to connect to the server.");

_networkManager = std::make_unique<Zappy::NetworkManager>(*_networkClient);
_networkManager = std::make_unique<Zappy::NetworkManager>(*_networkClient, ip, port);
_sceneManager.changeScene(std::make_unique<IntroScene>(
_sceneManager.getTextureManager(), _sceneManager.getAudioManager()));
}
Expand All @@ -43,6 +44,9 @@ void Core::run() {
const std::chrono::microseconds frameDelay(16666);

auto lastTime = std::chrono::steady_clock::now();

static WindowSize windowSize;

while (_isRunning) {

auto timeStart = std::chrono::steady_clock::now();
Expand All @@ -59,13 +63,14 @@ void Core::run() {
if (_networkManager)
_networkManager->update();

_window.getSize(windowSize.width, windowSize.height);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

if (_networkManager)
_sceneManager.update(events, *_networkManager, deltaTime);

_defaultShader->bind();
_sceneManager.draw(*_defaultShader);
_sceneManager.draw(*_defaultShader, windowSize);
_window.swapBuffers();

auto timeEnd = std::chrono::steady_clock::now();
Expand Down
4 changes: 3 additions & 1 deletion gui/src/Event.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ enum class EventType {
KeyReleased,
MousePressed,
MouseReleased,
MouseMoved
MouseMoved,
MouseWheelMove
};

enum class Key {
Expand Down Expand Up @@ -67,5 +68,6 @@ struct Event {
int mouseY = 0;
int button = 0;
Key keyCode = Key::NONE;
int wheelDelta = 0;
};
} // namespace Zappy
8 changes: 7 additions & 1 deletion gui/src/IScene/IScene.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@
#define WIDTH 1920.0f
#define HEIGHT 1080.0f

struct WindowSize
{
unsigned int width = 1;
unsigned int height = 1;
};

namespace Zappy {
enum class SceneState { NONE, INTRO, TITLE, MENU, LOAD_NETWORK, GAME };

Expand All @@ -21,7 +27,7 @@ class IScene {
const Zappy::GameState &gameState,
const std::vector<Zappy::NetworkEvent> &netEvents,
float deltaTime) = 0;
virtual void draw(Shader &shader) = 0;
virtual void draw(Shader &shader, WindowSize &windowSize) = 0;
virtual void onExit() = 0;
};
} // namespace Zappy
14 changes: 12 additions & 2 deletions gui/src/Network/NetworkManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

namespace Zappy {

NetworkManager::NetworkManager(INetworkClient &client) : _netClient(client) {
NetworkManager::NetworkManager(INetworkClient &client, std::string ip, int port) : _netClient(client), _ip(ip), _port(port)
{
initCommandHandlers();
}

Expand Down Expand Up @@ -38,7 +39,16 @@ void NetworkManager::initCommandHandlers() {
_commandHandlers["suc"] = [this](const auto &args) { handleSuc(args); };
_commandHandlers["sbp"] = [this](const auto &args) { handleSbp(args); };
}
bool NetworkManager::connectToServer(const std::string &host, int port) {


bool NetworkManager::connectToServer()
{
std::cout << "IP:" << _ip << " Port:" << _port << std::endl;
return _netClient.connectToServer(_ip, _port);
}

bool NetworkManager::connectToServer(const std::string &host, int port)
{
return _netClient.connectToServer(host, port);
}
void NetworkManager::update() {
Expand Down
5 changes: 4 additions & 1 deletion gui/src/Network/NetworkManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ namespace Zappy {

class NetworkManager {
public:
NetworkManager(INetworkClient &client);
NetworkManager(INetworkClient &client, std::string ip, int port);
~NetworkManager();

bool connectToServer();
bool connectToServer(const std::string &host, int port);
void update();
void sendCommand(const std::string &cmd);
Expand All @@ -33,6 +34,8 @@ class NetworkManager {
std::vector<NetworkEvent> _eventQueue;
INetworkClient &_netClient;

std::string _ip;
int _port;
std::unordered_map<std::string,
std::function<void(const std::vector<std::string> &)>>
_commandHandlers;
Expand Down
26 changes: 21 additions & 5 deletions gui/src/Render/Render.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,25 @@ class Renderer {
_skybox->draw();
glDepthFunc(GL_LESS);
}

void
render(const Camera &camera, InstancedGrid &floor,
const std::vector<std::unique_ptr<Sprite>> &players,
const std::vector<std::reference_wrapper<Sprite>> &resources = {}) {
const std::vector<std::reference_wrapper<Sprite>> &resources = {},
const WindowSize &windowSize = {}){


if (windowSize.width != _width || windowSize.height != _height) {
_width = windowSize.width;
_height = windowSize.height;

glBindTexture(GL_TEXTURE_2D, sceneColorTex);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, _width, _height, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL);

glBindTexture(GL_TEXTURE_2D, sceneDepthTex);
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, _width, _height, 0, GL_DEPTH_COMPONENT, GL_FLOAT, NULL);
}

glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, 0);

Expand All @@ -174,13 +189,14 @@ class Renderer {
Zappy::Math::mat4 lightSpaceMatrix = lightProjection * lightView;

Zappy::Math::mat4 projection = Zappy::Math::perspective(
Zappy::Math::radians(45.0f),
static_cast<float>(_width) / static_cast<float>(_height), 0.1f,
1000.0f);
Zappy::Math::radians(45.0f),
static_cast<float>(_width) / static_cast<float>(_height),
0.1f,
1000.0f);
Zappy::Math::mat4 view = camera.getViewMatrix();
Zappy::Math::mat4 viewProj = projection * view;

glViewport(0, 0, 2048, 2048);
glViewport(0, 0, _width, _height);
glBindFramebuffer(GL_FRAMEBUFFER, depthMapFBO);
glClear(GL_DEPTH_BUFFER_BIT);
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
Expand Down
Loading
Loading