↓ Skip to main content

Bubble Game — a small JavaScript game

·110 words·1 min
Cédric VERVOORD
Author
Cédric VERVOORD
Learning DevOps and security in public, one homelab phase at a time.

Practice exercise, 2023.

A tiny game in about thirty lines of JavaScript: pop the bubbles before they disappear.

The exercise
#

Bubbles of random size and direction float up the screen. Each click pops a bubble and adds to the score.

What I practised
#

  • creating elements on the fly in the DOM, at regular intervals;
  • events: a click pops the bubble and updates the counter;
  • clean-up: each bubble is removed from the page after a few seconds;
  • a CSS animation whose direction is set from JavaScript through a CSS variable.

Tech stack
#

JavaScript · DOM · events · CSS animations · CSS variables