2020-08-11
981
#vanilla javascript
Shawn Beaton
23194
Aug 11, 2020 â‹… 3 min read

How to build a game with HTML, CSS, and JavaScript

Shawn Beaton I create 2D games with HTML divs, CSS animations, and JavaScript.

Recent posts:

Rxjs Adoption Guide: Overview, Examples, And Alternatives

RxJS adoption guide: Overview, examples, and alternatives

Get to know RxJS features, benefits, and more to help you understand what it is, how it works, and why you should use it.

Emmanuel Odioko
Jul 26, 2024 â‹… 13 min read
Decoupling Monoliths Into Microservices With Feature Flags

Decoupling monoliths into microservices with feature flags

Explore how to effectively break down a monolithic application into microservices using feature flags and Flagsmith.

Kayode Adeniyi
Jul 25, 2024 â‹… 10 min read
Lots of multi-colored blue and purplish rectangles.

Animating dialog and popover elements with CSS @starting-style

Native dialog and popover elements have their own well-defined roles in modern-day frontend web development. Dialog elements are known to […]

Rahul Chhodde
Jul 24, 2024 â‹… 10 min read
Using Llama Index To Add Personal Data To Large Language Models

Using LlamaIndex to add personal data to LLMs

LlamaIndex provides tools for ingesting, processing, and implementing complex query workflows that combine data access with LLM prompting.

Ukeje Goodness
Jul 23, 2024 â‹… 5 min read
View all posts

11 Replies to "How to build a game with HTML, CSS, and JavaScript"

  1. Why do you have different lines of code in your github? I`m new at programming and i`m trying to run these instructions you gave for about 2 days, i`m mixing parts of the code you have here in the page and the ones which are missing I get it from GitHub, nevertheless I didn`t succeeded in running it.

  2. Hey it’s same as made by knife circus.
    Please friends check that video on YouTube.
    This is exact copy of that game. Not a single difference.

  3. MY DINO ISNT JUMPING ON TOUCH HELP!!

    code:
    var character = document.getElementById(“character”);
    document.addEventListener(“click”,jump);
    function jump(){
    character.classList.add(“animate”);
    setTimeout(removeJump,300); //300ms = length of animation
    };
    function removeJump(){
    character.classList.remove(“animate”);
    }

    HELP ASAP

  4. btw i found that you need to put

    var block = document.getElementById(“block”);
    function checkDead(){
    let characterTop = parseInt(window.getComputedStyle(character).getPropertyValue(“top”));
    let blockLeft = parseInt(window.getComputedStyle(block).getPropertyValue(“left”));
    if(blockLeft-20 && characterTop>=130){
    alert(“Game over”);
    }
    }

    setInterval(checkDead, 10);

    in your .js folder not your .css

  5. I didn’t know that it’s going to be that simple
    this is the first time I came to know that there are certain JavaScript libraries that are pre-made for game developments. Although they are easy to create, but these games crash a lot.

  6. so, I have been learning to code JavaScript in Kahn academy, I just don’t know what place to type it in. like do I open up a google doc and start typing in code? the article didn’t really explain that in depth. for example, what does this mean “To begin coding the game, create a new folder in your documents. Use your favorite text editor to open that folder, then create three new files and name them: index.html, style.css, and script.js. It’s possible to do everything in one file with HTML5, but it’s more organized to keep everything separate. Our index.html file is going to be very simple: once you have a basic HTML layout,” what does any of that stuff mean? Also, turns out I have been using some sort of Kahn academy JavaScript dialect, and I have to type something in first to use my code that I have learned, but every time I go into visual studio or something like that there is already a load of shit typed in, what does any of that do? should I just delete it? also, what is CSS or HTML, I know a little bit of JavaScript, I don’t know any of those coding languages. somebody please explain to me how I can get to the point where I can start typing in code (in the specific Kahn academy dialect that I learned) and it will run it for me. please explain EVERYTHING. I NEED HELP!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

    1. I would recommend you use a code editor, such as VS Code, https://code.visualstudio.com. Create a folder on your computer. Open VSCode and then open that folder, within that folder create your three files.
      Most websites are made up of 3 parts, the HTML File (the Markup or the structure of the Website), the .CSS file used to style the page (formats, colours, text size etc) and the .JS (Javascript) which is used on the client side (your browser) to provide a more interactive experience.
      Hope this helps you get started.

Leave a Reply