-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
71d6bff
commit c57d937
Showing
2 changed files
with
65 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,70 @@ | ||
<html> | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<title>An other bevy 2D game</title> | ||
<style> | ||
body { | ||
background: linear-gradient( | ||
45deg, | ||
#4b0082 0%, | ||
#8a2be2 100% | ||
); | ||
background: linear-gradient(45deg, #4b0082 0%, #8a2be2 100%); | ||
background-repeat: no-repeat; | ||
background-size: cover; | ||
height: 100vh; | ||
margin: 0; | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
justify-content: center; | ||
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; | ||
font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; | ||
color: #ffffff; | ||
} | ||
|
||
h1 { | ||
font-size: 2.5em; | ||
text-align: center; | ||
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5); | ||
padding: 2em; | ||
margin: 0; /* Remove default margin for better alignment */ | ||
} | ||
canvas { | ||
box-shadow: 0 0 20px rgba(0, 0, 0, 0.5); | ||
outline: none; | ||
|
||
button { | ||
background-color: #ff8c00; | ||
color: #ffffff; | ||
font-size: 1.5em; | ||
padding: 0.5em 1em; | ||
border: none; | ||
border-radius: 5px; | ||
cursor: pointer; | ||
transition: background-color 0.3s ease; | ||
} | ||
|
||
button:hover { | ||
background-color: #ffa500; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<h1>An other bevy 2D game</h1> | ||
<button onclick="play()">Play</button> | ||
<script type="module"> | ||
import init from './wasm_game.js' | ||
init() | ||
</script> | ||
<script> | ||
interval = setInterval(function () { | ||
let canvas = document.getElementsByTagName("canvas")[0] | ||
import init from "./wasm_game.js"; | ||
|
||
window.play = function () { | ||
// Hide header and button | ||
document.querySelector("h1").style.display = "none"; | ||
document.querySelector("button").style.display = "none"; | ||
|
||
// Call your initialization function | ||
init(); | ||
|
||
// Focus on the canvas | ||
let interval = setInterval(function () { | ||
let canvas = document.getElementsByTagName("canvas")[0]; | ||
if (canvas) { | ||
canvas.focus() | ||
clearInterval(interval) | ||
canvas.focus(); | ||
clearInterval(interval); | ||
} | ||
}, 100) | ||
}, 100); | ||
}; | ||
</script> | ||
</body> | ||
</html> |