Get basic setup working for demo.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
c4007cd873
commit
4b4cacdd82
|
@ -195,7 +195,8 @@
|
|||
$GODOT_HEAD_INCLUDE
|
||||
</head>
|
||||
<body>
|
||||
<div id="game_box">
|
||||
<div id="game_box" class="game_frame hidden">
|
||||
<h1>Click to Victory!</h1>
|
||||
<div id="container">
|
||||
<canvas id="canvas" width="640" height="480">
|
||||
HTML5 canvas appears to be unsupported in the current browser.<br />
|
||||
|
@ -390,19 +391,44 @@ $GODOT_HEAD_INCLUDE
|
|||
|
||||
<!-- Start of Custom Game block -->
|
||||
<script type="application/javascript">
|
||||
const get_user_name = () => {
|
||||
const current_url = new URL(document.URL);
|
||||
return current_url.searchParams.get('FirstName') || document.body.dataset.memberName;
|
||||
const setPlayerName = () => {
|
||||
const playerName = document.querySelector("#gameLauncher input[name=playerName]");
|
||||
window.game = {playerName: playerName.text};
|
||||
}
|
||||
|
||||
const hide_game_show_score_list = (playerName, score) => {
|
||||
const showGame = () => {
|
||||
const gameLauncher = document.querySelector("#gameLauncher");
|
||||
gameLauncher.remove();
|
||||
|
||||
const gameFrame = document.querySelector("#game_box");
|
||||
gameFrame.className = "game_frame";
|
||||
}
|
||||
|
||||
window.addEventListener("load", () => {
|
||||
// Prevent the game launcher form from redirect on submit.
|
||||
const launcherForm = document.querySelector("#gameLauncher form");
|
||||
launcherForm.addEventListener("submit", (event) => {
|
||||
event.preventDefault();
|
||||
setPlayerName();
|
||||
showGame();
|
||||
});
|
||||
})
|
||||
|
||||
const finishGame = (playerName, score) => {
|
||||
showScoresAfterGameEnd();
|
||||
updateScores(playerName, score);
|
||||
}
|
||||
|
||||
const showScoresAfterGameEnd = () => {
|
||||
const game_box = document.querySelector('#game_box');
|
||||
game_box.remove();
|
||||
const score_list = document.querySelector('#score_list');
|
||||
score_list.className = "";
|
||||
const score_list = document.querySelector('#scoreList');
|
||||
score_list.className = "game_frame";
|
||||
}
|
||||
|
||||
const updateScores = (playerName, score) => {
|
||||
// Update the score
|
||||
const title = document.querySelector('#score_title');
|
||||
const title = document.querySelector('#scoreMessage');
|
||||
title.textContent = `${playerName}'s score is ${score}!`;
|
||||
}
|
||||
|
||||
|
@ -413,10 +439,30 @@ $GODOT_HEAD_INCLUDE
|
|||
visibility: collapse;
|
||||
height: 0px;
|
||||
}
|
||||
|
||||
.game_frame {
|
||||
background-color: #383838;
|
||||
color: #f0f0f0;
|
||||
width: 85%;
|
||||
margin: auto;
|
||||
margin-top: 20px;
|
||||
padding: 25px;
|
||||
border-radius: 25px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div id="score_list" class="">
|
||||
<h1 id="score_title">Buy Points and Redeem Your Bonus!</h1>
|
||||
<div id="gameLauncher" class="game_frame">
|
||||
<h1>Click to Victory!</h1>
|
||||
<form>
|
||||
<label for="playerName">Player Name</label>
|
||||
<input name="playerName" type="text" value="Player 1" />
|
||||
<input type="submit" value="Start the Game!" />
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div id="scoreList" class="game_frame hidden">
|
||||
<h1>Click to Victory High Scores</h1>
|
||||
<h2 id="scoreMessage">Your Score Here</h2>
|
||||
<h2>High Scores</h2>
|
||||
<ul>
|
||||
<li>Player: 1000</li>
|
||||
|
|
Loading…
Reference in New Issue