Skip to content

Instantly share code, notes, and snippets.

@Woflox
Last active September 17, 2024 15:28
Show Gist options
  • Save Woflox/ebfc0fee67e30ea54500ecd1c6409556 to your computer and use it in GitHub Desktop.
Save Woflox/ebfc0fee67e30ea54500ecd1c6409556 to your computer and use it in GitHub Desktop.
The Seed Wanderer commented source code
--Created by Eric Billingsley. This code is licensed under the Attribution-NonCommercial-ShareAlike 4.0 International license (CC BY-NC-SA 4.0): https://creativecommons.org/licenses/by-nc-sa/4.0/
g=1--goal tile
pl=-600--palette seed
found=0
px=76py=77
ldx=0ldy=0
ccol=6
tcol=3
pcol=4
gcol=10
poke(0x5f2c,1)--wide mode
srand(51)for i=0,0x7fff do
--fill memory with junk
v=rnd(256)\1
if(i<17151)poke(i,v)
--generate map at 0x8000
poke(i+0x8000,v&((i\1620*20&i%180\9)*1337|i)==v and v%128)
end
poke2(13820,rnd(-1))--fix that one loud sound
::r::
--generate palette
srand(pl)
cols={}
pcols={}
for i=0,15 do
add(cols,i)
add(cols,i+128)
end
for i=0,15 do
pcols[i]=del(cols,rnd(cols))
end
pal(pcols,1)
::l::
--main loop
t=tonum
b=btnp
dx=t(b(➡️))-t(b(⬅️))
dy=t(b(⬇️))-t(b(⬆️))
function getaddr(x,y,nowr)
if(not nowr)y%=182
return 0x8000+(x%180)+y*180
end
function mv(x1,y1,x2,y2,dx,dy,isp)
local addrs=
{getaddr(x1,y1),
getaddr(x2,y2),
getaddr(x2+dx,y2+dy)}
local val1,val2,val3,order=
@addrs[1],
@addrs[2],
@addrs[3],
{0,1,3}
if val2!=0 then
--do a thing based on the
--tile's type
srand(%val2)
if isp and val2%128==g and not plnt then
--get goal tile
found+=1
if found==5 then
plnt=true
end
end
ind1=rnd{1,2,3}
threes=0
for i=1,3 do
if i==ind1 then
order[i]=1
else
rval=rnd{0,2,3,4}
if rval==3 then
threes+=1
end
order[i]=rval
end
--propagate to next tile
--if we need its space
--POST-JAM NOTE:
--there are multiple things wrong with this code.
--see if you can spot them all.
if val3!=0 and threes==0 and (order[2]==1 or order[3]==2) then
if not mv(x2+dx,y2+dy,x2+dx*2,y2+dy*2,dx,dy) then
return
end
end
end
--play random sound as music
--so we can do a quick fade
poke(0x3100,255,255,255,(%val2+98)%64)
music(0)
music(-1,300)
end
--update the map based on move
for i=1,3 do
r=order[i]
if r==0 then
poke(addrs[i],0)
elseif r==1 then
poke(addrs[i],val1)
if isp then
px,py=(addrs[i]-0x8000)%180,(addrs[i]-0x8000)\180
poke(addrs[i],0)
end
elseif r==2 then
poke(addrs[i],val2)
elseif r==3 then
poke(addrs[i],@addrs[3])
elseif r==4 then
poke(addrs[i],@val2)
end
end
return @addrs[1]==0
end
cls(ccol)
--draw map
for rx=0,12 do
for ry=0,12 do
x=px+rx-6
y=py+ry-6
t=@(getaddr(x,y,1))
if t!=0 then
fillp(%(t%128*2)+.5)
cx=rx*4+6
cy=ry*8+12
rectfill(cx,cy,cx+3,cy+3,((g==t and not plnt) or t>127) and gcol or tcol)
end
end
end
--draw player
fillp(-6938.5)
rectfill(30,60,33,63,pcol)
fillp(%(g*2)+.5)
--draw goal counter
if(not plnt)rectfill(22,116,41,119,tcol)
if found>0 then
st=nil
if plnt then
a=getaddr(px+ldx,py+ldy)
if @a==0 then
st=time()%1>.5
if @a==0 and btnp(❎) then
poke(a,g+128)
found-=1
sfx"25"
if found==0 then
g,plnt=g%127+1
end
end
end
end
if st then
?"𝘱𝘳𝘦𝘴𝘴 \-e𝘹",19,116,gcol
else
rectfill(22,116,21+4*found,119,gcol)
end
end
flip()
--move player
if dx!=0 or dy!=0 then
ldx=dx
ldy=dy
ly=py
mv(px,py,px+dx,py+dy,dx,dy,1)
sfx(47)
if abs(ly-py)>99 then
--update palette when
--we wrap vertically
pl+=sgn(ly-py)
goto r
end
end
goto l
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment