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AAAAAAAAFGGQQQQQR GG@@@@@@@@@@@BIGG@GAAAAAAEFGGQQQQRSSdGGdGG@@RSP@@@RSPGDEEF DEEEF DEEEF DEEEFCIGG7@GCCCCdGGddSSdSdGGGG@R DEFdGdSSddIGGc@AAAAGCGGB Sd GGGGd GC 7YGGDEFPQQQQGDAAAAGGDEEEEEEEEEEEEEEEEEEEAGGDAAAAAAF GG GDEEEF 77 AAAAAFDAAAAAAAGGd@GdDAAAAAFGGCCCCCCCdPGGGGGDEEEEEEEEEEEF9d98GGd@GSSdGGGGGG 9YcIHGGDEEEF@GSSGGGGGGT IDABFAAAAAAdIXGGd@GSSGG@T GGGGYSSTD@@@@F QAAAAA@@@@@@@@@@@@I@7GGDEF@GDAAAAAFGGDEF@AAAAAAAAGGDEEEEF GGDGAAAFCGGSSd@BD@@@@@@F9SSSS8IGG@GSSSSSSGG@R PGSSSSSSdGGFGdGGSS@BD@BABBBBBBBISdccSSSSSSSHIGGT@d@GTSSSSSTGGT GTSSSSSSGG GT GG SSST @ BT BTYSSSSSXY ;GGAAAAAAAAAAAAAAAAAAAAAAAAAAAA@GAAAAAAAAAAAAAAAAAAAAAAAAAAAAGGAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGBBBBBBBBBBBBBBBBBBBBAABBBBBBG????????????+/////////////////////////////   ?"  "  " "!"""" "!"""" "!"/,""""" ,""""" ,""z/"""," """," """"" """" """"fu "" "" "fu  fufu"z@CCCC"BBB!2gVgVgVgV!2!2 gVgVgVgV/?#!2# !2!2!2gVgVgVgVgVgVgVgVgVgVgVgV!2!2!2  !2!2!2gVgVgVgVgVgVgVgVgV2gVgVgV!2!2!2 /""" DDe4  pe 4 33pe 4 03pew 4" pew 4" fffpew 4" `Pfpew 4" P`epew!2!2!2 4" 0`V0pewgVgVgV 4" pegVgVgV 4 pegVgVgV 4 egVgVgV4 !2!2!2  C-- title: Soda Adventure V1.0 -- author: Archargelod -- desc: platformer game -- site: archargelod.itch.io -- license: MIT License -- version: 1.0 -- script: lua w,h=240,136 tick=0 level_id=1 level={} levels={ {0 ,30 ,17,33}, --1 intro {30 ,60 ,17,33}, --2 intro2 {60 ,90 ,17,33}, --3 spiders {90 ,120,17,33}, --4 hi-jump tutorial {150,210,34,50}, --5 doors intro {210,240,34,50}, --6 castle {120,240,17,33}, --7 big level {30 ,90 ,34,50}, --8 pit {30 ,60 ,51,67}, --9 maze {90 ,150,34,50}, --10 boulder puzzle {0 ,30 ,34,50}, --11 end level(for now) {0 ,30 ,51,67} -- test(delete later) } --transition vars bkp_pal={} for i=0,15 do for j=0,2 do table.insert(bkp_pal,peek(0x03fc0+i*3+j)) end end t_trans=0 o={x=0,y=0} --origin c={x=0,y=0} --camera p={x=0,y=0,vx=0,vy=0,spd=0.6,t_spd=1,j_spd=1,hflip=0,standing=false,invinc=0,hp=5,alive=true} keyStore={false,false,false} t_shake=0 i_shake=0 t_msg=0 t_type_s=0 cur_msg=0 coin_count=0 all_coins=0 t_step=0 t_coy=0 particles={} msgs={ "What? You lost all your precious soda cans while you were falling in the hole? Don't waste any time, go get them all. No thing should be left behind!", "Be careful, next room has spiders and me. and soda.", "If you get yourself stuck - press R.%Whatever it means. %Or you could just die. %Won't recommend.", "HaHah AahahahhHA, that was funny. %Maybe get a running start before the jump?", "Oh no, did someone locked your soda in there? There should be a way to open these strange glowing doors.", "", "Isn't that a HuUuuUUUUuuUUUuuge room? %Oh, you can't find the blue keycard? %I have a spare...... %But I lost it somewhere in this room. NO, NOT IN THE WELL, DUH.", "", "", "Do you need a hint? These heavy boulders can be very useful if used together.", "I'll add more levels in the future. The other me isn't real.", } --debug hit=false poke(0x3ff8,15) function addEnemy(type,x,y,sprite,spd) local e={} if type==1 then e.flying=false elseif type==2 then e.flying=true end e.x=x e.y=y e.spd=spd+math.random()*0.1 e.hflip=1 e.vx=0 e.vy=0 e.active=false e.sprite=sprite e.state=state or 1 enemies[#enemies+1]=e end function addNpc(x,y,sprid,msgid,active,alive,hflip) local n={} n.x=x n.y=y n.sprid=sprid or 1 n.msgid=msgid or 1 n.active=active or false n.alive=alive or true n.hflip=hflip or 1 npcs[#npcs+1]=n end function addParticle(x,y,t,size,flip) local p={} p.x=x-math.random(0,2) p.y=y-math.random(0,2) p.t=t-math.random(0,6) p.size=size p.spd=math.random()+0.1 local j={-1,1} p.vx=j[flip+1] p.vy=-0.3-math.random() particles[#particles+1]=p end function addShiny(x,y,id) local s={} s.x=x s.y=y s.id=id shinies[#shinies+1]=s end function addRock(x,y) local r={} r.x=x r.y=y r.vx=0 r.vy=0 r.active=false rocks[#rocks+1]=r end for i=0,239 do for j=0,135 do local tile=mget(i,j) local new_tile=tile if tile==144 then new_tile=160 end --player if tile==145 then new_tile=161 end --npc if tile==192 then new_tile=208 end --coin if tile==10 then new_tile=26 end --spider if tile==12 then new_tile=28 end --bat if tile==85 then new_tile=101 end --rock for k=1,3 do if tile==58+k then new_tile=74+k end end --keys if new_tile~=tile then mset(i,j,new_tile) end end end function loadTiles() shinies={} npcs={} enemies={} rocks={} for i=level.startx,level.endx do for j=level.starty,level.endy do local tile=mget(i,j) if tile==160 then p.x=i*8 p.y=j*8 end --player if tile==161 then addNpc(i*8,j*8,1,level_id,true) end --npc if tile==208 then addShiny(i*8,j*8,7) coin_count=coin_count+1 end --coin if tile==26 then addEnemy(1,i*8,j*8,10,0.1,10,true) end --spider if tile==28 then addEnemy(2,i*8,j*8,12,0.1,12,false) end --bat if tile==101 then addRock(i*8,j*8) end --rock for k=1,3 do if tile==74+k then addShiny(i*8,j*8,k) end end --keys for dx=0,2 do for dy=0,2 do if tile==104+dy*16+dx then mset(i,j,tile-48) end end end --reload doors end end end function loadLevel(i) local l=levels[i] level={startx=l[1],endx=l[2],starty=l[3],endy=l[4]} p.alive=true p.hp=5 p.vx=0 p.vy=0 o={x=0,y=0} coin_count=0 keyStore={false,false,false} loadTiles() all_coins=coin_count end loadLevel(level_id) game_state=1 --0 menu --1 game --2 transition function TIC() if game_state==0 then elseif game_state==1 then moveRocks() movePlayer() moveParticles() moveEnemies() moveCamera() shakeScreen() drawBg() drawShinies() drawEnemies() drawNpcs() drawPlayer() drawRocks() drawParticles() drawUi() showMsg() elseif game_state==2 then moveCamera() shakeScreen() drawBg() drawShinies() drawEnemies() drawNpcs() drawPlayer() drawRocks() drawParticles() drawUi() transition() end --debug() tick=tick+1 end function shakeScreen() local offset={x=0,y=0} local r={-1,1} if t_shake>0 then t_shake=t_shake-1 offset.x=math.random(1,i_shake)*r[math.random(1,2)] offset.y=math.random(1,i_shake)*r[math.random(1,2)] else i_shake=0 end poke(0x3ff9 ,offset.x) poke(0x3ff9+1,offset.y) end function addShake(t,int) t_shake=t_shake+t i_shake=i_shake+int end function CtM(v) v=math.floor(v/8)%240 return v end function addMsg(ind) cur_msg=ind if t_msg==0 then t_msg=1 end end function showMsg() if t_msg==0 then return end local msg=msgs[cur_msg] local arr={} local row,col=0,0 --convert string to array for i=1,#msg do table.insert(arr,string.sub(msg,i,i)) end --box local height=40 local o={x=4,y=4} if c.y<68 then o={x=4,y=h-height-4} end rect (o.x,o.y,w-9,height,0) rectb(o.x,o.y,w-9,height,12) for i=1,t_msg do if o.x+6*col>w-12 then row=row+1 col=0 end --linebreak if arr[i]=="%" then row=row+1 col=-1 end print(arr[i],o.x+2+6*col,o.y+2+6*row,12,true) col=col+1 end if t_msg<#msg and arr[math.floor(t_msg)]~=" " then typeSound() end if t_msg<#msg then t_msg=t_msg+0.3 end end function drawUi() --HP for i=1,p.hp do spr(193,1+(i-1)*9,0,0,1) end --keys for i=1,3 do if keyStore[i] then spr(58+i,(i-1)*8,9,0,1) end end --coins local off=0 local col=12 if coin_count==0 then col=6 end if all_coins-coin_count>9 then off=8 else off=0 end --if tick%2==0 then rect(w-16,1,28,12,0) end --backdrop print(all_coins-coin_count.."/"..all_coins,w-40-off,2,col,true,2,true) spr(192,w-9,3,0,1) --death message if not(p.alive) then print("You Died!",35,20,2 ,true,3) print("Try Again",55,40,12,true,2) print("Press Z to restart.",10,h/5+80,12,true,2) end end function drawBg() cls(0) --map((math.floor(p.x/240)-1)*30+14,level.starty,16,17,112+o.x+((math.floor(p.x/240)-1)*240),0) --map( math.floor(p.x/240) *30,level.starty,30,17,o.x+( math.floor(p.x/240) *240),0) --map((math.floor(p.x/240)+1)*30,level.starty,16,17,o.x+((math.floor(p.x/240)+1)*240),0) local i=-1 local mapx=math.floor(p.x/240) if p.x>math.floor(p.x/240)*240+120 then i=1 end map( mapx *30,level.starty,30,17,o.x+( mapx *240),0) map((mapx+i)*30,level.starty,30,17,o.x+((mapx+i)*240),0) end function drawPlayer() local anim={1,3,5,3} --dead sprite if not(p.alive) then spr(35,c.x,c.y,0,1,p.hflip,0,2,2) return end if p.standing~=true then spr(33,c.x,c.y,0,1,p.hflip,0,2,2) elseif (btn(2) or btn(3)) and game_state==1 then spr(anim[math.floor(tick/4)%3+1],c.x,c.y,0,1,p.hflip,0,2,2) else spr(7,c.x,c.y,0,1,p.hflip,0,2,2) end end function movePlayer() local acc={x=0,y=0} if p.hp<1 then p.alive=false if btn(4) then loadLevel(level_id) end end --reload level on "R" key if keyp(18) then loadLevel(level_id) end --DOWN collision if checkFlag(p.x+5 ,p.y+16,0) or checkFlag(p.x+12,p.y+16,0) then p.vy=0 p.y=CtM(p.y)*8 p.standing=true t_coy=5 else acc.y=acc.y+p.spd/3 p.standing=false t_coy=t_coy-1 end if p.alive and btn(2) then acc.x=-p.spd*p.t_spd/40 end if p.alive and btn(3) then acc.x=p.spd*p.t_spd/40 end if btn(2) or btn(3) then if p.standing then p.t_spd=p.t_spd+0.9 else p.t_spd=p.t_spd+0.5 end else p.t_spd=p.t_spd-2 end --if p.standing and (btn(2) or btn(3)) then p.t_spd=p.t_spd+0.5 end if p.t_spd>40 then p.t_spd=40 end if p.t_spd<10 then p.t_spd=10 end if (btn(2) or btn(3)) and p.standing and p.alive then if p.t_spd > 20 then stepSound() addParticle(p.x+8,p.y+16,p.t_spd/6,1,p.hflip) end end --jump if (btnp(5) or btnp(0)) and t_coy>0 and p.alive then p.j_spd=30+p.t_spd/15 sfx(0,30,30,1) for i=1,4 do addParticle(p.x+8,p.y+16,16,1,i%2) end end if (btn(5) or btn(0)) then p.j_spd=p.j_spd-1.1 else p.j_spd=p.j_spd-3 end if p.j_spd<0 then p.j_spd=0 end if p.j_spd>0 then acc.y=acc.y-p.spd*p.j_spd/30 end --LEFT collision if checkFlag(p.x+2,p.y+12,0) or checkFlag(p.x+2,p.y+5 ,0) then p.vx=0 p.x=CtM(p.x+2)*8+6 end --RIGHT collision if checkFlag(p.x+14,p.y+12,0) or checkFlag(p.x+14,p.y+5 ,0) then p.vx=0 p.x=CtM(p.x+14)*8-14 end --UP collision if checkFlag(p.x+12,p.y,0) or checkFlag(p.x+5 ,p.y,0) then p.vy=0 p.y=CtM(p.y)*8+8 end --collision with rocks for i=1,#rocks do local this=rocks[i] if coll(p.x+6,p.y+10,4,6,this.x,this.y,8,8) then if this.y>p.y-16 then p.y=this.y-16 p.vy=0 p.standing=true t_coy=5 end end if coll(p.x+8,p.y,5,10,this.x,this.y,8,8) then p.vx=0 --acc.x=0 p.x=this.x-13 end if coll(p.x+3,p.y,5,10,this.x,this.y,8,8) then p.vx=0 --acc.x=0 p.x=this.x+8-3 end end --collision with enemies hit=false if p.invinc>0 then p.invinc=p.invinc-1 goto skip end for i=#enemies,1,-1 do this=enemies[i] if this.active then if coll(this.x,this.y,8,8,p.x+3,p.y+3,10,10) then hit=true local j={1,-1} acc.x=5*j[this.hflip+1] acc.y=-1 addShake(8,2) sfx(3) p.hp=p.hp-1 p.invinc=30 end end end ::skip:: --flip sprite if p.hflip==1 and btn(3) and p.alive then p.hflip=0 if p.t_spd>30 then p.t_spd=30 end elseif p.hflip==0 and btn(2) and p.alive then p.hflip=1 if p.t_spd>30 then p.t_spd=30 end end p.vx=p.vx*0.7 p.vy=p.vy*0.9 p.vx=p.vx+acc.x p.vy=p.vy+acc.y p.x=p.x+p.vx p.y=p.y+p.vy if p.vx<0.001 and p.vx>-0.001 then p.vx=0 end if p.vy<0.001 and p.vy>-0.001 then p.vy=0 end --collect shinies for i=#shinies,1,-1 do local this=shinies[i] if coll(p.x+2,p.y,12,16,this.x,this.y,8,8) then table.remove(shinies,i) if this.id~=7 then keyStore[this.id]=true else coin_count=coin_count-1 end sfx(2,70,20,2) end end --open doors for i=1,3 do if checkFlag(p.x ,p.y,i) and keyStore[i] then openDoor(p.x ,p.y,i) sfx(5,40,30,2) end if checkFlag(p.x+16,p.y,i) and keyStore[i] then openDoor(p.x+16,p.y,i) sfx(5,40,30.2) end end --exit level if coin_count<1 then if checkFlag(p.x+8,p.y,7) and p.standing then level_id=level_id+1 t_trans=60 game_state=2 end -- if checkFlag(p.x+8,p.y,7) and p.standing then level_id=level_id+1 t_trans=100 game_state=2 end end --show dialogs for i=1,#npcs do local this=npcs[i] if coll(p.x+2,p.y,12,16,this.x-8,this.y,24,16) and p.standing and p.vx==0 then addMsg(this.msgid) goto skipmsg end end t_msg=0 ::skipmsg:: end function openDoor(cx,cy,id) x,y=CtM(cx),CtM(cy) while fget(mget(x,y),id) do y=y+1 end while fget(mget(x,y-1),id) do y=y-1 mset(x,y,(mget(x,y)+48)) end end function stepSound() if t_step<=0 and p.standing then t_step=6 sfx(1,10+math.floor(p.t_spd/2),6) else t_step=t_step-1 end end function typeSound() if t_type_s<0 then t_type_s=5 sfx(6,70,2) else t_type_s=t_type_s-1 end end function moveCamera() c.x=p.x+o.x c.y=p.y+o.y if c.x>130 then o.x=o.x-2 end if c.x<110 then o.x=o.x+2 end if c.x>250 then o.x=o.x-c.x+120 end if c.x<-10 then o.x=o.x+c.x-120 end if -o.xlevel.endx*8 then o.x=-level.endx*8+w end --left limit if -o.ylevel.endy*8 then o.y=-level.endy*8-h end --down limit end function drawEnemies() for i=1,#enemies do local this=enemies[i] local anim={this.sprite,this.sprite+1} if this.active then spr(anim[math.floor(tick/6)%2+1],this.x+o.x,this.y+o.y,0,1,this.hflip) end end end function drawNpcs() local sprites={227} local sizes={{w=2,h=2}} for i=1,#npcs do local this=npcs[i] if this.active then spr(sprites[this.sprid],this.x+o.x,this.y+o.y,0,1,this.hflip,0,sizes[this.sprid].w,sizes[this.sprid].h) end end end function drawParticles() for i=#particles,1,-1 do local this=particles[i] if this.t>0 then rect(o.x+this.x,o.y+this.y,this.size,1,15) --this.size=this.size+0.1 this.t=this.t-1 else table.remove(particles,i) end end end function moveParticles() for i=#particles,1,-1 do local this=particles[i] local acc={x=0,y=0} acc.y=acc.y+p.spd/3 if checkFlag(this.x,this.y,0) then this.vy=-this.vy end this.vy=this.vy+acc.y this.x=this.x+this.vx this.y=this.y+this.vy end end function drawRocks() for i=#rocks,1,-1 do local this=rocks[i] spr(85,o.x+this.x,o.y+this.y,0) end end function moveRocks() for i=1,#rocks do local this=rocks[i] local acc={x=0,y=0} local left=false local right=false local down=false for j=1,#rocks do if j==i then goto skipr end local r=rocks[j] --down if coll(this.x,this.y+5+this.vy,8,4,r.x,r.y,8,4) then down=true this.vy=0 this.y=r.y-8 end --left if coll(this.x-2,this.y+1,4,6,r.x,r.y,8,8) then --this.x=r.x+8 left=true end --right if coll(this.x+4,this.y+1,4,6,r.x,r.y,8,8) then this.x=r.x-8 right=true end ::skipr:: end --down collision if down then -- elseif checkFlag(this.x ,this.y+8,0) or checkFlag(this.x+8,this.y+8,0) then this.vy=0 this.y=CtM(this.y)*8 else acc.y=acc.y+0.2 end local dir=2 if p.vx>0 then dir=8 end if coll(p.x+dir,p.y,6,9,this.x,this.y,8,8) and not( right or left ) then acc.x=p.vx end if checkFlag(this.x-1,this.y+4,0) then this.vx=0 acc.x=0 this.x=CtM(this.x+1)*8 end if checkFlag(this.x+8,this.y+4,0) then this.vx=0 acc.x=0 this.x=CtM(this.x)*8 end this.vx=this.vx*0.1 this.vy=this.vy*0.9 this.vx=this.vx+acc.x this.vy=this.vy+acc.y this.x=this.x+this.vx this.y=this.y+this.vy end end function drawShinies() for i=1,#shinies do local this=shinies[i] if this.id==7 then spr(192,o.x+this.x,o.y+this.y,0) else spr(58+this.id,o.x+this.x,o.y+this.y,0) end end end function moveEnemies() for i=1,#enemies do local this=enemies[i] --disable if offscreen if o.x+this.x>-120 and o.x+this.x-0.001 then this.vx=0 end if this.vy<0.001 and this.vy>-0.001 then this.vy=0 end end end end function checkFlag(x,y,f) if fget(mget(CtM(x )%240,CtM(y)%136),f) then return true end return false end function debug() if keyp(37) then level_id=level_id-1 loadLevel(level_id) end if keyp(38) then level_id=level_id+1 loadLevel(level_id) end local mx,my,lmk=mouse() if lmk then p.x=mx-o.x p.y=my-o.y end circ(CtM(c.x)*8,CtM(p.y)*8,1,5) circ(c.x,p.y,1,6) circ(c.x+5 ,p.y+16,1,2) --down circ(c.x+12,p.y+16,1,2) circ(c.x+2 ,p.y+12,1,2) --left circ(c.x+2 ,p.y+5 ,1,2) circ(c.x+14,p.y+12,1,2) --right circ(c.x+14,p.y+5 ,1,2) circ(c.x+5 ,p.y,1,2) --up circ(c.x+12,p.y,1,2) --enemies for i=1,#enemies do local this=enemies[i] circ(o.x+this.x+8,this.y+7,1,2) circ(o.x+this.x-1,this.y+7,1,2) end if hit==true then rect(c.x+3,p.y+3,10,10,2) end end function coll(x1,y1,w1,h1,x2,y2,w2,h2) if x1x2 and y1y2 then return true end return false end function transition() if t_trans<1 then game_state=1 return end if t_trans==31 then loadLevel(level_id) end for i=0,15 do for j=0,2 do local val=bkp_pal[i*3+j+1] if t_trans>30 then val=val-7 else val=val+7 end bkp_pal[i*3+j+1]=val if val<0 then val=0 end poke(0x03fc0+i*3+j,val) end end --restore colors if t_trans==1000 then for i=0,15 do for j=0,2 do poke(0x03fc0+i*3+j,bkp_pal[i*3+j+1]) end end end t_trans=t_trans-1 end