`˻`DDDDDDDDAA@@A$DADDNDDDBHDDDDDDDD""DDDD""DDDD!!"BA@@A$DADDN""DDDBH""DDDD""DD3333333311001#3133>333283333333333333333>>001#3133>3332833333333                 ```````````````````` ````````$L$,BM,BDLD"M",.,,/,/ollln[ 000000524<<:96310004077>:701??     !>>>=<;:98653100112346789:;<<=?/.+)' !!"""##$%&&&&&'(()*+,./ >>======<;;:944201357:;;;<<<=?"   aaaaaaaaaaaaaaaaaaaa\\\\\\z\j\Z\J\*\\\\\\\\v\f\\\\\\\x\h\\\\\\\z\j\Z\J\*\\\\\\\\v\f\\\\\\\z\j\fffffffffffffffffffffffffffffffffff       bbbbbbbbbbbbbbAAAAAAAAAAAAAAAAAAAAAAAAAAAa aa a?툈؈   ˻ ˻ ˻˻˻˻˻˻˻l̰ ̻̼̼̌˻˻Ȍ̌ ̈ ̈̈̈  ̌  ̌̀  l   ́ ́ȁĺ́́́̌a툈hl˻˻˻˻˻˻˻˻˻˻˻˻˻˻˻k˻˻̻˻˻˻˻˻˻˻˻ȟǎaa̙á툈h̩Ɍl˜̋˻˻˻˻˻˻˻˻˻˻˻˻˻˻˻k˻˜̋˻˻˻˻˻˻""h̘Ȍ!"""ȃ""""ȃ!"""""a!"""""a툈("""""hȌ̈+"""""lȼ̸˻˻+"""""˻˻˻˻˻˻˻˻˻[˻˻˻k˻̻˙˻̸˻˻˻˻ɻ""""XhȌ̈!"""a""ȃQȃȃ툈XhȜ̈Xl˜̋˻˻˻˻˻˻˻˻˻˻˻˻˻˻˻k˻̩ɼ˻˻˻˻˻˻˻hȜ̈a̙QaQǎXa툈ḧl˻˻˻˻˻˻˻˻˻˻˻˻˻˻˻k˻˻˻˻˻X˻X˻˻˻˻˻˻hXaQaaQa툈hXl˻˻˻˻˻˻˻˻˻˻˻˻˻˻˻k˻˻˻˻˻˻˻˻˻˻˻˻haaaa툈hl˻˻˻˻˻˻˻˻˻˻˻˻˻˻Żk˻˻˻˻˻˻˻˻˻˻˻˻haaQaaX툈XhXl˻˻˻˻˻˻˻˻˻˻˻˻˻˻˻k˻˻˻˻˻˻˻˻˻˻˻˻haaaa툈hXl˻˻˻˻˻˻˻˻˻˻˻˻˻˻˻k˻˻˻˻˻˻˻˻˻˻˻˻hQaaaQa툈hl˻˻˻˻˻˻˻˻˻˻˻˻˻˻˻k˻˻˻˻˻˻˻˻˻˻˻˻hXaaaa툈hlX˻˻˻˻˻˻˻˻˻˻˻˻˻˻˻k˻˻˻˻˻˻˻˻˻˻˻˻DDDDhDDDDaDDaVXDDaDDDDXa툈DDDDhl˻˻˻˻˻˻˻˻˻˻[˻˻k˻˻˻˻˻˻˻˻˻˻˻˻hXaQ݁aQ݁a<-- title: Butelnoid -- author: OdiStudio Games, odistudio4444@gmail.com -- desc: dodge the bubles and pierce them using the harpoons -- site: website link -- license: MIT License (change this to your license of choice) -- version: 0.1 -- script: lua rnd,sin,cos=math.random,math.sin,math.cos volume=9 -- camera cam={ cx=0, cy=0 } -- solid function solid(x,y) return solids[mget((x)/8,(y)/8)] end solids={ [1]=true; [3]=true; [5]=true; [4]=true } --if solid(p.x+p.vx,p.y+p.vy) -- or solid(p.x+7+p.vx,p.y+p.vy) -- or solid(p.x+p.vx,p.y+7+p.vy) -- or solid(p.x+7+p.vx,p.y+7+p.vy) --then p.vx=0 --end -- power up -- power up power={} function addPower(x,y) local po={} po.x=x po.y=y po.dy=1 po.mod=rnd(3) po.sprite=0 po.t=0 table.insert(power,po) end function ticPower() for k,po in pairs(power) do po.t=po.t+1 if po.mod==0 then po.mod=1 end if po.y<=103 then po.y=po.y+po.dy else end -- beahvior and graphism spr(po.sprite,po.x,po.y) -- power up speed player if po.mod==1 then po.sprite=384 -- collision witch player for s,p in ipairs(player) do if p.x<=po.x+8 and p.x>=po.x-16 and p.y<=po.y+8 and p.y>=po.y-16 then table.remove(power,k) Player.bullet=Player.bullet+1 score.sc=score.sc+100 sfx(2,"D-4",-1,1,volume) end end -- power up 2 speed bullet elseif po.mod==2 then po.sprite=385 -- collision witch player for s,p in ipairs(player) do if p.x<=po.x+8 and p.x>=po.x-16 and p.y<=po.y+8 and p.y>=po.y-16 then table.remove(power,k) Player.bulletGenre=0 score.sc=score.sc+100 sfx(2,"E-4",-1,1,volume) end end -- power up 3 speed spawn bullet elseif po.mod==3 then po.sprite=386 -- collision witch player for s,p in ipairs(player) do if p.x<=po.x+8 and p.x>=po.x-16 and p.y<=po.y+8 and p.y>=po.y-16 then table.remove(power,k) Player.bulletGenre=1 score.sc=score.sc+100 sfx(2,"F-4",-1,1,volume) end end end -- remove power up if po.t>=350 then table.remove(power,k) end end end function PowerUp() if Player.bullet>=Player.bulletMax then Player.bullet=Player.bulletMax end end -- bullet from player bullet={} function addBullet(x,y,g) local b={} b.x=x b.y=y b.ox=x+3 b.oy=124 b.genre=g b.vx=2 b.vy=2 b.sp=0 b.coli=0 table.insert(bullet,b) end function ticBullet() for k,b in ipairs(bullet) do if b.genre==0 then b.sp=344 line(b.ox,b.oy,b.ox,b.y+3,2) spr(b.sp,b.x,b.y,0) b.y=b.y-b.vy --print(b.genre,30,20,0) -- remove bullet if b.y<=6 then sfx(6,"G-3",-1,1,10) table.remove(bullet,k) end -- remove with collision buble for s,bu in ipairs(buble) do if bu.y>b.y-bu.r and bu.x>b.x-bu.r and bu.x=6 then b.y=b.y-b.vy else if b.coli==0 then sfx(6,"E-3",-1,1,10) b.coli=1 end end -- remove with collision buble for s,bu in ipairs(buble) do if bu.y>b.y-bu.r and bu.x>b.x-bu.r and bu.xPlayer.bullet then table.remove(bullet,k) end end end -- player Player={ bulletGenre=0; bullet=1; bulletMax=3; } player={} function addPlayer(x,y) local p={} p.x=x p.y=y p.vx=2 p.vy=1 p.sp=256 p.flip=0 p.t=0 p.jump=0 p.walk=0 table.insert(player,p) end function ticPlayer() ticBullet() for k,p in ipairs(player) do -- move player if btn(0) and p.jump==1 then p.vy=p.vy-3 p.sp=260 sfx(7,"D-2",-1,1,10) end if btn(1) then end if btn(2)and mget((p.x/8)-1,p.y/8)~=solids then p.vx=-2 p.flip=1 p.walk=1 elseif btn(3) and mget((p.x/8)+1,p.y/8)~=solids then p.vx=2 p.flip=0 p.walk=1 else p.vx=0 p.walk=0 end -- add bullet if btnp(4) then addBullet(p.x,p.y,Player.bulletGenre) sfx(5,"B-2",-1,1,10) end -- animation walk on the groud if p.vy==0 and p.walk==1 then p.sp=256+(p.t/10%2) elseif p.vy and p.walk==0 then p.sp=256 end -- gravity player if solid(p.x+p.vx,p.y+p.vy) or solid(p.x+14+p.vx,p.y+p.vy) or solid(p.x+p.vx,p.y+7+p.vy) or solid(p.x+14+p.vx,p.y+7+p.vy) then p.vx=0 end if solid(p.x,p.y+14+p.vy) or solid(p.x+14,p.y+16+p.vy) then p.vy=0 p.jump=1 else p.vy=p.vy+0.2 p.jump=0 end if p.vy<0 then p.sp=260 elseif p.vy>0 then p.sp=261 end -- print(p.vy,10,40,0) if p.vy<0 and (solid(p.x+p.vx,p.y+p.vy) or solid(p.x+14+p.vx,p.y+p.vy)) then p.vy=0 else end p.x=p.x+p.vx p.y=p.y+p.vy -- draw player spr(p.sp,p.x+cam.cx,p.y+cam.cy,1,2,p.flip,0) -- print("x "..p.x,50,20,4) -- print("y "..p.y,50,30,4) if mget(p.x/8,p.y/8)==1 then -- print("obstacle",10,70,0) end -- collision with buble for s,b in ipairs(buble) do if p.x<=b.x+(b.r) and p.x>=b.x-(b.r*2.4) and p.y<=b.y+(b.r*0.6) and p.y>=b.y-(b.r*1.5) then --print("collision",10,20,0) table.remove(player) die=1 m=0 end end p.t=p.t+1 end end -- explosion de particules explop={} function addExplop(x,y,c) local ep={} ep.s=s ep.c=c ep.x=x+rnd(-3.0,3.0) ep.y=y+rnd(-3.0,3.0) ep.dx=rnd(-60.0,60.0)/30 ep.dy=rnd(-60.0,60.0)/30 ep.vx=0 ep.vy=0 ep.t=0 table.insert(explop,ep) end function ticExplop() for k,ep in ipairs(explop) do ep.vy=ep.vy+0.08 -- direction des particules ep.x=ep.x+ep.dx ep.y=ep.y+ep.dy+ep.vy -- graphisme des explosion for s,e in ipairs(explo) do ep.c=e.c end pix(ep.x,ep.y,ep.c) -- suppression des explosion if ep.y>=120 then table.remove(explop,k) end end end -- explosion of bubles explo={} function addExplo(x,y,r,c) local e={} e.r=r -- spawn explo rnd e.sx=rnd(-e.r,e.r) e.sy=rnd(-e.r,e.r) -- e.x=x+e.sx e.y=y+e.sy e.c=c e.t=0.3 -- call down for explo e.ep=0 table.insert(explo,e) end function ticExplo() for k,e in ipairs(explo) do e.r=e.r-e.t if e.ep==0 then for i=0,10 do addExplop(e.x,e.y,e.c) end e.ep=1 end -- graphisme explo circ(e.x,e.y,e.r,e.c) circb(e.x,e.y,e.r,0) -- remove explo if e.r<=0 then table.remove(explo,k) end end end -- buble buble={} function addBuble(x,y,g,dxx) local b={} b.x=x b.y=y b.r=0 b.c=0 b.ct=0 b.rebond=0 b.gravity=2.48 b.ng=0 -- negate gravity allowed ? b.inverse=1 -- inverse gravity b.vx=0 b.vy=0 b.vyspeed=0.08 -- direction of buble b.dx=0 b.dy=0 -- stat of direction b.dxx=dxx b.maxdx=2.5 b.dyy=0 -- genre of buble b.g=g b.gg=0 -- for annimation of rebond b.anim=0 b.at=0 b.a=0 b.stase=0 -- life of buble b.life=1 b.boum=0 -- explo of bubles -- intro for the buble b.intro=0 b.its=0.2 -- for the collision with bullet b.collision=0 -- power up b.addPower=0 table.insert(buble,b) end function ticBuble() for k,b in ipairs(buble) do -- color b.ct=b.ct+0.2 -- remove buble if b.life<=0 then table.remove(buble,k) end -- gravite of the buble if b.intro==1 then b.vy=b.vy+b.vyspeed if b.vy>=b.gravity then b.vy=b.gravity end end --inaplication gravity for spec buble if b.ng==1 then if b.inverse==-1 then b.vy=-b.vy b.inverse=0 sfx(1,"E-2",-1,1,10) elseif b.inverse==1 then b.vy=-b.vy b.inverse=0 sfx(1,"E-2",-1,1,10) end end -- print(b.vy,10,10,12) -- print(b.inverse,10,20,12) -- print(b.ng,10,30,12) -- add vy if b.ng==0 then b.y=b.y+b.vy end --rebond buble with the groud and aeb if b.y>=114-b.r then b.y=114-b.r b.vy=-b.rebond b.anim=1 b.stase=1 b.inverse=-1 b.dyy=1 sfx(1,"E-2",-1,1,10) end -- intro for the bubles (aeb) if b.intro==0 and b.y=b.r+2 then b.intro=1 end -- rebond buble with the wall and aeb --print(b.x,20,20,12) --print(b.dx,20,30,12) --print(b.dxx,20,40,12) if b.intro==1 then if b.dxx==0 and b.x>=230-b.r then b.dxx=1 b.anim=1 b.x=230-b.r sfx(1,"E-2",-1,1,10) elseif b.dxx==1 and b.x<=b.r+6 then b.dxx=0 b.anim=1 b.x=b.r+6 sfx(1,"E-2",-1,1,10) end b.x=b.x+b.dx b.y=b.y+b.dy end -- animation for entering buble(aeb) if b.stase==1 then if b.y<=b.r then b.y=b.r b.vy=-b.vy b.inverse=1 b.dyy=0 end end -- animation of buble if b.anim==1 then b.at=b.at+1 end if b.anim==1 and b.a==0 then b.r=b.r-2 b.a=1 end if b.at>=5 then b.anim=0 b.at=0 b.a=0 b.r=b.r+2 end -- color of the bubles with life if b.life==1 and (b.g==1 or b.g==2 or b.g==3) then b.c=10 elseif b.life==2 and b.g==1 then b.c=6 elseif b.life==3 and b.g==1 then b.c=2 elseif b.life==4 and b.g==1 then b.c=0 elseif b.life==1 and b.g==4 then b.c=12 elseif b.life==1 and b.g==5 then b.c=2 elseif b.g==6 then b.c=5 elseif b.g==7 then b.c=8 end -- graphisme buble -- print(b.rebond,10,10) if b.g~=4 and b.g~=5 and b.g~=6 and b.g~=7 then circ(b.x,b.y,b.r,b.c) circb(b.x,b.y,b.r,b.c-1) -- graphism specific for buble 4 elseif b.g==4 then circb(b.x,b.y,b.r,b.c) circb(b.x,b.y,b.r-1,b.c) -- add the litlles buble in big buble -- 1 circ(b.x-6,b.y-6,5,10) circb(b.x-6,b.y-6,5,9) -- 2 circ(b.x-6,b.y+6,5,10) circb(b.x-6,b.y+6,5,9) -- 3 circ(b.x+6,b.y+6,5,10) circb(b.x+6,b.y+6,5,9) -- 4 circ(b.x+6,b.y-6,5,10) circb(b.x+6,b.y-6,5,9) -- graphism specific for buble 5 elseif b.g==5 then circ(b.x,b.y,b.r,b.c+b.ct/2%3) circb(b.x,b.y,b.r,b.c) elseif b.g==6 then circ(b.x,b.y,b.r,b.c+b.ct/2%3) circb(b.x,b.y,b.r,b.c) elseif b.g==7 then circ(b.x,b.y,b.r,b.c+b.ct/2%3) circb(b.x,b.y,b.r,b.c) end -- circ(b.x-(b.r/2),b.y-(b.r/2),b.r-(b.r/1.4),12) -- genre de buble -- genre de buble 1 if b.g==1 then if b.gg==0 then b.rebond=3.5 b.r=15 b.life=4 b.gg=1 end -- speed of the buble 1 if b.dxx==0 then b.dx=1 end if b.dxx==1 then b.dx=-1 end -- add children of buble 1 if b.life<=0 then b.boum=1 addBuble(b.x+b.r/2,b.y+b.r/2,2,0) addBuble(b.x+b.r/2,b.y+b.r/2,2,1) end -- genre de buble 2 elseif b.g==2 then if b.gg==0 then b.rebond=2 b.r=10 b.life=1 b.gg=1 end -- speed of the buble 2 if b.dxx==0 then b.dx=1 end if b.dxx==1 then b.dx=-1 end -- add children of buble 2 if b.life<=0 then b.boum=1 addBuble(b.x+b.r/2,b.y+b.r/2,3,0) addBuble(b.x+b.r/2,b.y+b.r/2,3,1) end -- genre de buble 3 elseif b.g==3 then if b.gg==0 then b.rebond=2.2 b.r=5 b.life=1 b.gg=1 end -- speed of the buble 3 if b.dxx==0 then b.dx=1 end if b.dxx==1 then b.dx=-1 end -- add children of buble 3 if b.life<=0 then b.boum=1 end -- genre de buble 4 elseif b.g==4 then if b.gg==0 then b.rebond=3.5 b.r=15 b.life=1 b.gg=1 end -- speed of the buble 4 if b.dxx==0 then b.dx=0.5 end if b.dxx==1 then b.dx=-0.5 end -- add children of buble 4 if b.life<=0 then b.boum=1 addBuble(b.x+b.r/2,b.y+b.r,3,0) addBuble(b.x-b.r/2,b.y+b.r,3,1) addBuble(b.x+b.r/2,b.y-b.r,3,0) addBuble(b.x-b.r/2,b.y-b.r,3,1) end -- genre de buble 5 elseif b.g==5 then if b.gg==0 then b.rebond=2 b.r=5 b.life=1 b.gg=1 b.ng=1 end -- speed of the buble 5 if b.dxx==0 then b.dx=0.7 end if b.dxx==1 then b.dx=-0.7 end if b.dyy==0 then b.dy=1 end if b.dyy==1 then b.dy=-1 end -- add children of buble 5 if b.life<=0 then b.boum=1 end -- genre de buble 6 elseif b.g==6 then if b.gg==0 then b.rebond=2 b.r=5 b.life=2 b.gg=1 b.ng=1 end -- speed of the buble 6 if b.dxx==0 then b.dx=0.7+sin(b.ct/10) end if b.dxx==1 then b.dx=-0.7-sin(b.ct/10) end if b.dyy==0 then b.dy=1 end if b.dyy==1 then b.dy=-1 end -- add children of buble 6 if b.life<=0 then b.boum=1 end -- genre de buble 7 elseif b.g==7 then if b.gg==0 then b.rebond=2 b.r=5 b.life=3 b.gg=1 b.ng=1 end -- speed of the buble 7 if b.dxx==0 then b.dx=0.7+cos(b.ct/10) end if b.dxx==1 then b.dx=-0.7-cos(b.ct/10) end if b.dyy==0 then b.dy=1+sin(b.ct/10) end if b.dyy==1 then b.dy=-1-sin(b.ct/10) end -- add children of buble 7 if b.life<=0 then b.boum=1 end end -- explosion of particles for the bb if b.collision==1 and b.boum==0 then for i=1,50 do addExplop(b.x,b.y,b.c) b.collision=0 end score.sc=score.sc+(b.g*10) sfx(4,"E-2",-1,1,10) end -- print(b.collision,10,80,0) -- explosion for the bubles b.addPower=rnd(5) if b.collision==1 and b.boum==1 then for i=1,10 do addExplo(b.x,b.y,b.r,b.c) sfx(0,"E-2",-1,1,10) end score.sc=score.sc+(b.g*10) if b.addPower==1 then addPower(b.x,b.y) end end if die==1 and b.boum==1 then for i=1,10 do addExplo(b.x,b.y,b.r,b.c) sfx(0,"E-2",-1,1,10) end end end end -- score score={ sc=0; high=2000 } function Score() if score.sc>=score.high then score.high=score.sc end -- save score if score.sc>pmem(0) then pmem(1,pmem(0)) pmem(0,score.high) end end -- save if pmem(0)==nil then pmem(0,0) end -- draw game o=0 omax=200 od=100 begin=0 t=0 die=0 diet=0 m=0 function draw_game() cls() Score() -- forward map(0,17,30,17,0,0,0) -- element of the game ticExplo() -- explosion ticExplop() -- particles explosion ticBuble() -- buble ticPlayer() -- player ticPower() PowerUp() -- print("Score: "..score.sc,10,10,0) print("Score: "..score.sc,11,12,12) print("High score: "..pmem(0),130,10,0) print("High score: "..pmem(0),131,11,12) -- if begin==1 then o=o+1 if o>=omax then o=0 omax=omax-0.2 addBuble(rnd(30,200),-30,rnd(7),0) end end if omax<=od then omax=od end if btnp(5) and begin==0 and die==0 then addPlayer(100,60) begin=1 m=0 if m==0 then m=1 music(3,-1,-1,false,true) end end if begin==0 and die==0 then if m==0 then m=1 music(0,-1,-1,true,true) end if t<50 then print("Press start (x) !!! ",10,100,0,2) print("Press start (x) !!! ",11,101,12,2) elseif t>100 then t=0 end elseif begin==0 and die==1 then print("GAME OVER",50,60,t,1,4,4) end -- print("pvg = "..Player.bulletGenre,20,20,12) if die==1 then if m==0 then m=1 music(1,-1,-1,false,false) end diet=diet+1 begin=0 omax=200 score.sc=0 Player.bullet=1 player.bulletGenre=0 table.remove(bullet) for s,b in ipairs(buble) do b.life=b.life-1 end end if diet>=300 then diet=0 die=0 m=0 end -- backgroud --if btnp(6) then mo=mo+140 y=y+100 end map(0,0,30,17,cam.cx,cam.cy,0) map(0,17,30,90,cam.cx,cam.cy+136,0) map(30,0,600,300,cam.cx+240,cam.cy,0) if begin==0 then rect(125,128,115,8,1) rectb(125,128,115,8,12) print("By OdiStudio Games",130,130,0,2,1) end -- print("cx "..cam.cx,10,50,12) -- print("cy "..cam.cy,10,60,12) t=t+1 end ---- function TIC() draw_game() end