DEV Community

Cover image for Build a Simple Arcade Game With Vanilla JavaScript - DOM Manipulation🚀

Build a Simple Arcade Game With Vanilla JavaScript - DOM Manipulation🚀

Roberto Hernandez on February 26, 2020

Originally published on my blog MullinStack Today’s a special day for those who just are starting out in the JavaScript world. The only way to mas...
Collapse
 
scrabill profile image
Shannon Crabill

Fun! This is a good example of what seems complex, is relatively straightforward when the concept/requirements are broken down into individual functions.

Collapse
 
aleksandrhovhannisyan profile image
Aleksandr Hovhannisyan

I think you have a bug in your game. The duck will sometimes spawn under the image. Your counter is also positioned incorrectly and overlaps partially with the background.

Collapse
 
blindfish3 profile image
Ben Calder

Fun. My only suggestion would be to store the score as a variable in the code rather than in the DOM. Once an application grows, storing values in the DOM is a surefire way to generate hard to trace bugs.

Collapse
 
blarzhernandez profile image
Roberto Hernandez

Yes you're right. The idea is playing with the DOM at first. Thanks for sharing!

Collapse
 
devpato profile image
Pato

The cover image is such a click bait lol

Collapse
 
blarzhernandez profile image
Roberto Hernandez

Sorry, I had any intention.😀 thanks for reading! 😀

Collapse
 
sjellen profile image
SJellen

Here's my mine

I'm fidgeting with the lines: duck.style.top/left by adding a multiplier to keep the duck in bounds

Collapse
 
blarzhernandez profile image
Roberto Hernandez

Love it. Thanks for sharing

Collapse
 
zaimazhar profile image
zaimazhar

Hi.

Cool post but any more further explanation on why not using data attributes when working with data instead of id?

Thanks.

Collapse
 
jlrxt profile image
Jose Luis Ramos T.

Gracias

Collapse
 
johndavemanuel profile image
John Dave Manuel

It would be better if the duck is "moving" inside the background only :)

Collapse
 
blindfish3 profile image
Ben Calder

I think you just set yourself a challenge :P