HTML6 GamesFree Web Games / devlog

No install. Just play.

Free mini games right in your browser. Sign in to save your records to your account and pick up on any device.

All games
All games
All dev log posts

The cloud that looks touched but isn't stepped on

Oct 25, 2026 Β· Art and sound Β· ν•œκ΅­μ–΄

Cloud Hop's clouds have a flat top and a bumpy underside. When the chick lands on one, it bounces. If the top edge of the art and the top edge of the hitbox disagree, trouble starts. The chick's feet appear to rest on the cloud but it isn't stepped on, or the chick is floating above the cloud and still lands.

The game's hit detection is computed by JavaScript as numbers, while the art is an image file (an atlas that packs many pictures into one) drawn onto the canvas. The tool below is a script written in Swift. Swift is Apple's programming language, and once the developer tools are installed on a Mac you can run a file with swift file.swift. Reading images uses what already comes with macOS.

The two know nothing about each other. When the art changes, the position of the top edge moves, but the hitbox numbers stay the same, so they drift apart. I had to match the top edge again when I replaced the cloud shapes drawn in code with generated art. The rule for these games is that the hitbox and the art must be the same.

Instead of deciding where the top of the art is by eye, I made a tool that measures it. For each pixel column it finds the height of the topmost opaque pixel (alpha above 128). Over the middle 60% and 80% of the width it reports the median, highest and lowest top edge.

swift tools/games/cloudhop/measure.swift cloud.png

Because it only looks at the middle section, the position of the flat top comes out stable.

It had already gone wrong once, on the storm cloud

I had run into this mismatch in Cloud Hop before. The storm cloud's hitbox ignored its bobbing height and only used a small box around the body. It didn't match the art, so touching the lightning was harmless and so was touching the edge of the body. I fixed it by using the bobbing height in the hitbox as well, fitting the body to the art's edge and adding the lightning to the hitbox. Later, when I replaced the shapes with generated art, the storm cloud's size changed, so I matched the vertical ranges of the body and the lightning again (body from +13 to +19, lightning from +12~+36 to +16~+42).

The top of the cloud art turned out to sit 3.5 down from the top of the cell (7px in the art file, which is at 2x). The art is drawn at 1.1 times the cell size, and to line up the hitbox's top edge (the cloud's y) with the art's top edge, the art is drawn shifted up by that amount.

const CLOUD_TOP = 3.5 * CS; // distance from the cell top to the top edge of the art

I matched the horizontal side too. So that the chick's feet stay above the cloud's edge even at the end of the landing range (Β±40px from the cloud's center), I set the art to 1.1 times the cell size (about 75px).

References

Games from this post

Cloud HopBounce from cloud to cloud and climb as high as you can. Gray clouds fall apart, and storm clouds must be stomped from above! Play

More posts

Add to Home Screen

  1. Tap the Share button at the bottom of the screen (top on iPad). It looks like a square with an arrow pointing up.
  2. Scroll down and tap "Add to Home Screen".
  3. Tap "Add" at the top right. The HTML6 Games icon appears on your home screen.

This works in Safari. Opened from the home screen, it runs without the address bar, like an app, and even offline.