I'm currently in the process of developing a new online game. With just a simple click of a button, my goal is to have the red square move horizontally by 50 pixels. Here's a snippet of the HTML code:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Cake (2D Singleplayer Adventure)</title>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<script>
function moveright() {
document.getElementById("master-cube").style.transform = "translateX(50px)";
}
</script>
<div id="master-cube"></div><img src="arrows/rightarrow.png" alt=h"Right Arrow" height="60vh" width="60vw" onclick="moveright()" class="arrowcontrols">
<img src="arrows/middlejumpsquare.png" alt="Jump Square" height="60vh" width="60vw" onclick="movejump()" class="arrowcontrols">
<img src="arrows/leftarrow.png" alt="Left Arrow" height="60vh" width="60vw" onclick="moveright()" class="arrowcontrols">
</body>
</html>
It's important to note that the images may not load properly. For more details and live demonstration, you can find this project on Repl.it below.
Here's a glimpse at the CSS styles used for this project:
html {margin: none;}
body {margin: none; width: 100vw; height: 100vh;}
.arrowcontrols {float: right; margin-right: 5px; margin-top: 90%; margin-bottom: 10%;}
#master-cube {background-color: #FF0000; height: 40px; width: 40px;}
If you're interested in exploring the interactive version of this game on Repl.it, follow this link: https://repl.it/@ritzcrackerz201/cake