Skip to main content

On Sale: GamesAssetsToolsTabletopComics
Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines
(4 edits)

There is more human friendly/readable version of code

::__::
--init game
obj,time_from_start,p={{x=64,y=64,s='🐱',c=12}},0,function(p)print(p.s,p.x,p.y,p.c)end
character,r,max_obj_count,enemy_start_index,w=obj[1],rnd,200,190,128
for i=2,max_obj_count do
 obj[i] =
     {
         x=-r(w),
         y=r(w),
         s='.',
         vy=r(5)+1,
         vx=0,
         c=i%3+5
     }
 
 if i>enemy_start_index then      s=obj[i]
     s.vy=r(3)+1
     s.vx-=1-r(3)
     s.s='✽'
     s.c=r(3)+8
 end end
--game loop
::_::
cls()
time_from_start+=1
?'score:'..time_from_start
--control
if(btn(⬅️))character.x-=1 
if(btn(➡️))character.x+=1 
if(btn(⬆️))character.y-=1 
if(btn(⬇️))character.y+=1 
p(character)
for i=2,max_obj_count do
    --check for collision with enemy
    if i>enemy_start_index and abs(character.x-3-s.x+3)<3 and abs(character.y-2-s.y+2)<3 then
        for k=1,99 do
            circ(s.x+3,s.y+2,k,8+k%3)
            flip()
        end
    goto __
    end
    s=obj[i]
    s.x+=s.vx
    s.y+=s.vy
    if s.y>w then
        s.y=-r(w)
        s.x=r(w)
    end
    p(s)
end
flip()
goto _