DOOMY a tiny FPS in 1024 bytes

0
0
Published 2023-06-12


DOOMY, a tiny first person shooter in 1024 bytes, with collision detection, arbitrary walls, texture w. fog, sound effects, a couple of baddies and a death screen 👹👺💥

Move around with the Left, Right and Up arrow keys. Shoot with X or C.
You start with 10 health points, and need to shoot as many baddies until they get you good!

Seeing great and cute entries closing Pico-1k jam was inspiring. That's when I got an idea: "all things SSPR" to balance this cuteness with DOOMY pointless violence and big pixels.

In a nutshell DOOMY is a rotozoom (the effect you get when rotating and zooming an image) laid down flat and rendered with scaled sprites.

The textures, sprites, and the base of the level are rendered as a group of rectfill and text in the first 3 lines of code, with first two textures of 8x8 for the walls, then 2 baddies, and finally the base of the level.

In the following 4 lines, the base of the level is expanded and some diagonal walls are added.

Every "thing" in DOOMY goes in the ▥ object which contains the x,y,t,w properties for the x,y position of the thing, it's texture index t and width w (nil or 1 for walls, 8 for the baddies)

In the game loop the things in ▥ are rotated and moved into another object, 🐱, if they are in the visibility fustrum. The baddies move erratically towards the player.

The things in 🐱 are then sorted and rendered back to front, if one of these thing is large, it means it's a baddy and we render a shadow with an ovalfill

For the collision detection, we check the distance of the last thing we drew. Blocking the way forward if it's very close.

We check the color of the pixel under the crosshair to know if it's a baddy. If you shoot we play a noise, increase the score and respawn it at a random location. Otherwise there is a 10% chance it will shoot you with a red flash and some noise.

You know the baddies are bad because they keep shooting you even when you're down!

Hope you enjoy this tiny showdown