The context behind this is I wanted to make a game in 100 lines of code or less in Pico-8. Was fun if a little tedious, mostly near the end of the project. Audio and sprites were allowed for my self-assigned rules, and direct downloads are at the bottom of the page under the sourcecode. 

This was originally somewhat related to the Pico-1k Challenge but I figured I didn't quite like it, hence went my own route and just did it in "Under a hundred lines of code" (The code overlaps on itself sometimes so I barely even qualify for that lol)

Yeah some bits of it got stacked (such as in the draw function) and I didn't want to stack them but I was pretty short on options. Either way, hope you enjoy!

Sourcecode:
--apple catch, by atacomans.
function _init()
pt={px=60,py=104,ps=0,pw=8,ph=6,pl=3} --player table
at={aptime=30} ht={hotime=60}
end
function appledrop() --this drops the apples
add(at,{x=rnd(120),y=8,s=1.5,w=6,h=6,xs,ys,xd,yd,life=120,
ad=function(self) spr(1,self.x,self.y) end,
uad=function(self)
self.y+=self.s --this is the colition code below. if the xd is lower than the xs (same with yd & yx) then they are considered to be colliding
self.xs=pt.pw*0.5+self.w*0.5
self.ys=pt.ph*0.5+self.h*0.5
self.xd=abs((pt.px+(pt.pw/2))-(self.x+(self.w/2)))
self.yd=abs((pt.py+(pt.ph/2))-(self.y+(self.h/2)))
if self.xd<self.xs and self.yd<self.xs and self.y<100 then
pt.ps+=1
sfx(0)
del(at,self)
end
self.life-=1
if self.life<0 then
del(at,self)
end
end})
end
function hostiledrop()
add(ht,{hx=rnd(120),hy=8,hs=2,hw=6,hh=6,hxs,hys,hxd,hyd,hlife=48,
hd=function(self) spr(8,self.hx,self.hy) end,
uhd=function(self)
self.hy+=self.hs
--this is the colition code. if the xd is lower than the xs (same with yd & yx) then they are considered to be colliding
self.hxs=pt.pw*0.5+self.hw*0.5
self.hys=pt.ph*0.5+self.hh*0.5
self.hxd=abs((pt.px+(pt.pw/2))-(self.hx+(self.hw/2)))
self.hyd=abs((pt.py+(pt.ph/2))-(self.hy+(self.hh/2)))
if self.hxd<self.hxs and self.hyd<self.hxs and self.hy<100 then
pt.pl-=1
sfx(1)
del(ht,self)
end
self.hlife-=1
if self.hlife<0 then
del(ht,self)
end
end})
end
function _update() --player movement
if btn(0) then
pt.px-=2
end
if btn(1) then
pt.px+=2
end
if pt.px>120 then
pt.px-=2
end
if pt.px<0 then
pt.px+=2
end
at.aptime-=1 --this decreases until it hits zero, new apple spawned, timer reset
if at.aptime<1 then
appledrop()
at.aptime=60
end
for a in all(at) do
a:uad()
end
ht.hotime-=1 --this drops dangerous stuff on the player
if ht.hotime<1 then
hostiledrop()
ht.hotime=60
end
for h in all(ht) do
h:uhd()
end
if pt.pl<1 then
print("game over ;(",40,60,8)
stop()
end
end
function _draw()
cls() map() line(0,8,127,8,5)
print("playerscore:",1,1,10) print(pt.ps,49,1,10) print("stick no",60,1,8)
spr(2,pt.px,pt.py) --player
if pt.pl>2 then
spr(7,99,0)
end
if pt.pl>1 then
spr(7,108,0)
end
if pt.pl>0 then
spr(7,117,0)
end
for a in all(at) do
a:ad()
end
for h in all(ht) do
h:hd()
end
end


Download

Download
appledropv1_linux.zip 735 kB
Download
appledropv1_osx.zip 3.2 MB
Download
appledropv1_windows.zip 975 kB

Leave a comment

Log in with itch.io to leave a comment.