Sitemap
Better Programming

Advice for programmers.

Member-only story

Improving Item Collection in a JavaScript Game

8 min readAug 22, 2022

--

Image by pch.vector on freepik

Over the past few months, I have been gradually building a JavaScript dungeon crawler that features a player moves through an auto-generated maze of caverns. While contending with enemies, the player can collect health potions and weapons — and with danger afoot, the player must grab them fast.

Helping the player grab an item as quickly as possible depends on effective collision detection. In an early version, the player had to be right on top of an item before collecting it.

After improving the code, I finally got the game to the point where the player could collect an item simply by touching a small part of it.

--

--

Nevin Katz
Nevin Katz

Written by Nevin Katz

Developer at EDC. I write about web development and biology. Subscribe at https://buttondown.email/nevkatz for article roundups.

No responses yet