Lowest price ever! Learn Generative AI for 48% less!
Get my discount0
Making a 2d javascript game is no easy feat, but our good friend WebGL sort of simplifies it for us. You can check out a pong example I made here so you can see what's involved: https://code.sololearn.com/W3idZd5slSdG/#html
WebGL utilizes the <canvas> element in html. What appears on this canvas can be manipulated by using javascript. You will want to pass an id to your canvas like <canvas id='gameCanvas'></canvas>. Then, you can pass document.getElementById("gameCanvas"); into a variable to refer to your canvas in your code. Once that's done, you can grab the 2d context to draw images. You will also want to add event listeners after initializing the canvas to check for mouse movements, keypresses, etc.
Link to a very well-explained tutorial here: https://code.tutsplus.com/articles/learn-html5-with-this-simple-avoider-game-tutorial--active-9653