Adapt for web

This commit is contained in:
Vladislav Khorev 2026-02-22 20:04:18 +03:00
parent b59a10b7e6
commit d883b58260
4 changed files with 10 additions and 6 deletions

View File

@ -71,6 +71,10 @@ set(SOURCES
../src/network/WebSocketClientEmscripten.cpp ../src/network/WebSocketClientEmscripten.cpp
../src/render/TextRenderer.h ../src/render/TextRenderer.h
../src/render/TextRenderer.cpp ../src/render/TextRenderer.cpp
../src/MenuManager.h
../src/MenuManager.cpp
../src/Space.h
../src/Space.cpp
) )
add_executable(space-game001 ${SOURCES}) add_executable(space-game001 ${SOURCES})

BIN
resources/gameover.png (Stored with Git LFS)

Binary file not shown.

View File

@ -95,10 +95,10 @@ namespace ZL
#ifdef NETWORK #ifdef NETWORK
#ifdef EMSCRIPTEN #ifdef EMSCRIPTEN
networkClient = std::make_unique<WebSocketClientEmscripten>(); networkClient = std::make_unique<WebSocketClientEmscripten>();
networkClient->Connect("192.168.131.143", 8081); networkClient->Connect("localhost", 8081);
#else #else
networkClient = std::make_unique<WebSocketClient>(taskManager.getIOContext()); networkClient = std::make_unique<WebSocketClient>(taskManager.getIOContext());
networkClient->Connect("127.0.0.1", 8081); networkClient->Connect("localhost", 8081);
#endif #endif
#endif #endif
lastTickCount = 0; lastTickCount = 0;

View File

@ -7,8 +7,8 @@
namespace ZL { namespace ZL {
void WebSocketClientEmscripten::Connect(const std::string& host, uint16_t port) { void WebSocketClientEmscripten::Connect(const std::string& host, uint16_t port) {
// Формируем URL. Обратите внимание, что в Web часто лучше использовать ws://localhost // Формируем URL. Обратите внимание, что в Web часто лучше использовать ws://localhost
//std::string url = "ws://" + host + ":" + std::to_string(port); std::string url = "ws://" + host + ":" + std::to_string(port);
std::string url = "wss://api.spacegame.fishrungames.com"; //std::string url = "wss://api.spacegame.fishrungames.com";
EmscriptenWebSocketCreateAttributes attr = { EmscriptenWebSocketCreateAttributes attr = {
url.c_str(), url.c_str(),