diff --git a/proj-web/space-game001plain.html b/proj-web/space-game001plain.html index d3c1953..aae27f4 100644 --- a/proj-web/space-game001plain.html +++ b/proj-web/space-game001plain.html @@ -8,7 +8,7 @@ body, html { margin: 0; padding: 0; width: 100%; height: 100%; overflow: hidden; background-color: #000; - position: fixed; /* Предотвращает pull-to-refresh на Android */ + position: fixed; } #canvas { display: block; @@ -17,10 +17,23 @@ width: 100vw; height: 100vh; border: none; } + + #fs-button { + position: absolute; + top: 10px; right: 10px; + padding: 10px; + z-index: 10; + background: rgba(255,255,255,0.3); + color: white; border: 1px solid white; + cursor: pointer; + font-family: sans-serif; + border-radius: 5px; + } #status { color: white; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); } +
Downloading...
@@ -36,12 +49,18 @@ } }; - // Обработка ориентации + document.getElementById('fs-button').addEventListener('click', function() { + if (!document.fullscreenElement) { + document.documentElement.requestFullscreen().catch(e => { + console.error(`Error attempting to enable full-screen mode: ${e.message}`); + }); + } else { + document.exitFullscreen(); + } + }); + window.addEventListener("orientationchange", function() { - // Chrome на Android обновляет innerWidth/Height не мгновенно. - // Ждем завершения анимации поворота. setTimeout(() => { - // В Emscripten это вызовет ваш onWindowResized в C++ window.dispatchEvent(new Event('resize')); }, 200); }); diff --git a/resources/config/ui.json b/resources/config/ui.json index dcd4df6..c5ebf78 100644 --- a/resources/config/ui.json +++ b/resources/config/ui.json @@ -8,16 +8,21 @@ "children": [ { "type": "TextView", - "name": "velocityText", - "x": 10, - "y": 10, - "width": 200, + "name": "gameScoreText", + "x": 0, + "y": 30, + "width": 80, "height": 40, "horizontal_gravity": "left", "vertical_gravity": "top", - "text": "Velocity: 0", - "fontSize": 24, - "color": [1.0, 1.0, 1.0, 1.0], + "text": "Score: 0", + "fontSize": 36, + "color": [ + 0, + 217, + 255, + 1 + ], "centered": false }, { diff --git a/src/MenuManager.cpp b/src/MenuManager.cpp index bf928ad..a634803 100644 --- a/src/MenuManager.cpp +++ b/src/MenuManager.cpp @@ -139,11 +139,12 @@ namespace ZL { if (auto btn = uiManager.findButton("takeButton")) btn->state = ButtonState::Disabled; + /* auto velocityTv = uiManager.findTextView("velocityText"); if (velocityTv) { velocityTv->rect.x = 10.0f; velocityTv->rect.y = static_cast(Environment::height) - velocityTv->rect.h - 10.0f; - } + }*/ uiManager.setButtonPressCallback("shootButton", [this](const std::string&) { if (onFirePressed) onFirePressed(); diff --git a/src/Space.cpp b/src/Space.cpp index cde5e60..6bfb7d4 100644 --- a/src/Space.cpp +++ b/src/Space.cpp @@ -349,6 +349,7 @@ namespace ZL } if (bestIdx >= 0) { networkClient->Send("BOX_PICKUP:" + std::to_string(bestIdx)); + this->playerScore += 1; } }; @@ -1837,6 +1838,11 @@ namespace ZL } } + if (playerScore != prevPlayerScore) + { + prevPlayerScore = playerScore; + menuManager.uiManager.setText("gameScoreText", "Score: " + std::to_string(playerScore)); + } } void Space::fireProjectiles() { @@ -1845,6 +1851,7 @@ namespace ZL Vector3f{ 1.5f, 0.9f - 6.f, 5.0f } }; + const float projectileSpeed = PROJECTILE_VELOCITY; const float lifeMs = PROJECTILE_LIFE; const float size = 0.5f; diff --git a/src/Space.h b/src/Space.h index f94d839..a7006c5 100644 --- a/src/Space.h +++ b/src/Space.h @@ -126,6 +126,7 @@ namespace ZL { std::unordered_set deadRemotePlayers; int playerScore = 0; + int prevPlayerScore = 0; bool wasConnectedToServer = false; static constexpr float TARGET_MAX_DIST = 50000.0f;