So I am trying to build a video game based on js. However I encountered an issue: how do I make a background-image as Game Area?
PS: The backgroundImage has specified CSS conditions:
body {
background-image: url(bg.jpg);
background-repeat: no-repeat;
background-attachment: fixed;
background-size: cover;
}
Here is the code:
<body onload="startGame()">
<script>
var myGamePiece;
function startGame() {
myGameArea.start();
myGamePiece = new component(30, 30, "red", 10, 120)}
</script>
Source: https://www.w3schools.com/graphics/tryit.asp?filename=trygame_controllers_keys