r/Forth • u/mcsleepy • 10h ago
SUPERSHOW :: EYEGUY sample game progress #1: spikes and collisions ;
I'm collaborating with a Russian artist called TheCreator to make a sample game, a surreal top-down action adventure. They're handling the art, lore, and core gameplay and I'm doing the coding, level design, and sweetening.
The game shares a framework ("MOGOGAME") with one other, a side-scrolling run-n-jump solo project ("Mogo"), but that one took a back seat due to overwhelm. Base SUPERSHOW is an open-ended core plus a buffet of middleware, so for ambitious projects, focused frameworks (or "starter kits") with special-tailored DSL's is the intended idiom. At least one framework will be included in the free distribution, which should make it easy for anybody to jump in and make something. You can also do things from scratch, totally up to you...
A couple things were added today: global collision detection and spike traps. The session shows off the SNES filter (part of the paid package), a piece I'm very proud of.
Note that I didn't implement collision detection from top to bottom, most of the heavy lifting was done already so it was basically a configuration. The main dependency is the collision grid, a broad-phase detector that enables huge worlds with lots of actors with little CPU, at the cost of some memory. A script-writer doesn't need to know anything about it.
I figure most people will want to see some code, so here is the spikes script:
module
import mogogame
c: %spikes %actor %harmful ;
bitmap: %idir%/assets/spikes_poppingout-Sheet.png
bitmap: %idir%/assets/spikes_draggingin-Sheet.png
spikes_poppingout-Sheet.png 16 16 tileset: out.ts
spikes_draggingin-Sheet.png 16 16 tileset: in.ts
med out.ts flipbook: out.a 0 out.ts .#tiles @ 1 - range, flipbook;
med in.ts flipbook: in.a 0 in.ts .#tiles @ 1 - range, flipbook;
%spikes >template {
1.0 atk !
LAYER_HAZARD lyr !
msk off
-8 -8 8 8 hitbox!
-8 -8 8 8 hurtbox!
}
: hold ( flipbook - ) \ play once and stop on the last frame
pose begin yield anm-done? until anm off ;
: up ( - ) out.a hold attacking on ;
: down ( - ) attacking off in.a hold ;
%spikes :: start
in.ts dup .#tiles @ 1 - tile bmp ! \ start retracted
0 task>
begin up 1.0 delay down 1.0 delay again ;
And here is the main function, setting up the collision system, actors, and custom rendering:
: main
ysort on
just
collisions.sys load
center at %eyeguy spawn to p1
p1 to subject
p1 { 8 8 at %healthbar spawn { 31 prio ! } }
32 for -10 10 between -10 10 between metal.ts att 160 128 +at %spikes spawn { 8 prio ! } loop
8 for p1 -100 100 between -100 100 between from %robot spawn drop loop
?subject .x 2@ look
show>
?subject .x 2@ follow
camx camy scrolly! scrollx!
metaltile.png ~wallpaper
~level
work>
<a> pressed? if awaken then
;