HTML Elements


This week I implemented a couple of html/CSS ui-overlays onto my game. I’ve also been working on organising my code into Game states. Using switch statements to set cases for each state and switch to the next when needed.  There Is a picture example of my code below. As you can see, I grabbed the element using the id’s and called them at the initialize (game begin) and tally (game over) game states. This is nice, so when the game starts, I can give instructions and when the game is over it is easy to see that you’ve died.

Other html elements that I have added in are the health percentage and km counters at the top, this will measure the about of hit damage taken by objects and allow your player to see how far they make It in the game. The km – is incremented by a counter. I used ‘. fixed() ‘ to turn it into a string. You can learn more about it here: https://www.w3schools.com/jsref/jsref_tofixed.asp

Ui examples

all html elements on screen