Lego Building Blocks — It’s a game!
When I first started to learn Javascript, I was (and still am) overwhelmed with the scope of possibilities you can create. Where do you start? How do you know what you don’t know? What is worth taking the time to learn in the short term versus long term?
After clicking around for hours, I had heard that you can build full games just using Javascript, so I decided that would be a fun thing to learn. If I am going to learn a new language, might as well make it as fun as possible right?
So I found a Youtube tutorial of how to build simple games in Javascript.
I’ll be honest, I have not made all 7 games yet. I wanted to take the time to write out the code myself, even though she does make the code available on Github free for download.
In this video, she teaches the fundamentals of Javascript, and I was able to take write the code step by step and refresh my page to see how it changed the website. I focused on the Whack-a-mole tutorial after doing the simple Matching Game tutorial, and added a bit of Simpson’s flare to the page to make it more interesting.
I present Whack-a-Burns, a Whack-a-Mole game where you smash Mr. Burns with a Hammer, instead of a poor, innocent gopher.
The HTML and CSS are limited for this game. Captured below is the full HTML coding I input. I only stylized the text and added a background image here. One thing I learned in this exercise was making a 3x3 grid in html with my “square” class.
The CSS is also limited, but I did learn about the flex-flow which enabled the squares I created in the HTML file to be transformed into a 3x3 grid over 618x618 pixels. This is also where I added the 100x100 pixel image of Montgomery Burns. I also added a hammer icon as the mouse cursor for added effect within the CSS.
The Javascript is where the magic happens for this simple game. This is where I practiced with querySelector, addEvenlistener(), setInterval(), classList, forEach() and Arrow functions. I also learned by doing a lot with the ‘const’ versus ‘let’ functions, in which the ‘let’ function changes over time, whereas the ‘const’ is, well, constant.
I am very excited to continue with learning other simple Javascript games, and maybe I can make a whole series of Simpson’s mini games by just changing the iconography instead of the standard shapes and colors. I will keep you posted!
Here are my Github files if you want to try it out for yourself! Have fun and keep building.