Log In  

DOOMY (overdue Pico-1k jam)

by p01
Cart #doomy-1 | 2021-10-13 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
14

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 πŸ‘ΉπŸ‘ΊπŸ’₯

Controls & Goal

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!

Inspiration

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.

Technical details

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.

Setup

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)

Game loop

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

Collisions and baddies hit

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!

Source code

u=.2v=1.5a=0p=0h=10β–₯={}r=rectfill f=add
cls()r(0,0,15,7,13)f(β–₯,{x=3,y=4,t=24,w=8})?"#%$3ᢜ9μ›ƒαΆœ8][βŒ‚",r(0,1,15,6,5),3,3
β—†=pget?"β˜…%=  ᢜ8🐱z}",f(β–₯,{x=4,y=5,t=16,w=8}),1,6
memcpy(0,6^13,β§—)for y=0,9,1/8do
for x=0,9,1/8do
if(β—†(x+32,y)!=β—†(x+31.9,y-.1))f(β–₯,{x=x;y=y;t=(x+y)%2*8})end
if(y<2)f(β–₯,{x=2.5+y/2;y=4-y%1+y\1*2;t=y%2*8})end
function _draw()cls(1)r(0,60,127,68,5)l=rnd
local 🐱,c,s,q,d,w,x,y={},cos(a)*8,sin(a)*8,64
for z in all(β–₯)do
x=z.x-u
y=z.y-v
if(z.w)z.x-=(x/q+l()-β–ˆ)/9z.y-=(y/q+l()-β–ˆ)/9
z.u=y*c-x*s
z.v=y*s+x*c
if(z.v<48and abs(z.u)<z.v)f(🐱,z)end
for i=2,#🐱 do for j=1,i do
if(🐱[i].v>🐱[j].v)🐱[i],🐱[j]=🐱[j],🐱[i]end
end
e=6-2*min(1,h)pal(6,13)for d in all(🐱)do
z=80/d.v
if(z>4)pal()
w=d.w or 1x=q+z*(d.u-w/2)y=q-z*e
if(w>1)ovalfill(x,y+z*9,x+z*w*.9,y+z*7,0)
sspr(d.t,0,w,8,x,y,z*w+4,z*8)end
b=btn()*min(1,h)a+=(b%2-b\2%2)/q
if(b&4>0and z<40)u+=c/q v+=s/q
?"ᢜe⁢w⁢tdoomy",44,4
?"♥"..h.."  β˜…"..p,44,119
c=β—†(q,q)w="\ai60"?"+",q,q
if(c>7and c<13)then
if(b>15)p+=1d=β–₯[c-7]d.x=l(8)d.y=l(8)?w
if(l()<.1)pal(1,8,1)h=max(h-1)?w
end
end

That's all folks

Hope you enjoy this tiny showdown

P#98580 2021-10-13 14:55 ( Edited 2021-10-13 14:59)

Neat! This works surprisingly well, and the fact that you technically have depth-based lighting and shadows is kind of amazing. If you could find a way to squeeze in backwards movement, that would be cool, but impressive job anyway.

My high score so far is 29.

P#98585 2021-10-13 15:56 ( Edited 2021-10-13 15:57)

Pretty cool how little you really need to make an FPS, but not having a gun is a little bit strange. Great job overall!

P#98586 2021-10-13 15:57

This is such a great 1k game!
Plays really well too, considering the limitations.
Thanks for the technical write-up also, very interesting.
Congrats again on squeezing it all in! πŸ€“πŸ‘

P#98619 2021-10-14 04:13

This is amazing. Do you have the "clean and commented" version anywhere?

P#98670 2021-10-15 01:56

This is awesome

P#98672 2021-10-15 03:26

[Please log in to post a comment]

Follow Lexaloffle:        
Generated 2021-10-20 13:42:11 | 0.013s | Q:22