Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- mine blast
- -- Use this function to perform your initial setup
- function setup()
- setInstructionLimit(0)
- print("Touch and hold mine until it deactivates")
- print("The quicker u get to the mine the more points you gain")
- print("bonus points awarded at end for deactivate mines")
- mylevel = 0
- mynewlevel = 1
- myradius = 11
- mycount = 1
- myxplaces={124,224,324,424,524,624}
- myyplaces={128,210,294,376,456,536}
- mylives=36
- mylifedecrease = 0
- mywall=""
- myground=""
- --get first real random number
- mynumber=math.random(1,6)
- mynumber2=math.random(1,6)
- myplace=myxplaces[mynumber]
- myplace2=myyplaces[mynumber2]
- mybackground = 1
- myscore=0
- myhits=0
- mymines=0
- mybonus=0
- mylevel=0
- mystate=1
- mylevelamount = .6
- z=1
- y=1
- x=1
- w=1
- v=1
- u=1
- -- populate 6 by 6 array with 6 rows numbered 1 to 6
- -- this is used as the mine grid
- myrow={}
- for c = 1,6 do
- myrow[c] = {}
- for d = 1,6 do
- myrow[c][d] = d
- end
- end
- myrow[mynumber][mynumber2]=0
- backingMode(RETAINED)
- end
- -- This function gets called once every frame
- function draw()
- if mystate==1 and mylives>0 then
- if mybackground < 2 then
- -- draw background blocks and initial grid of mines
- getgrid()
- mybackground = 2
- end
- if w<=31 and mynewlevel >1 then
- fill(1, 1, 1, 255)
- stroke(10, 11, 10, 255)
- rect(5,(HEIGHT-10)-100,WIDTH,HEIGHT -10)
- printword("BONUS "..mybonus,w)
- if w<=30.3 then
- w=w+.3
- else
- w=31
- fill(1, 1, 1, 255)
- stroke(10, 11, 10, 255)
- rect(5,(HEIGHT-10)-100,WIDTH,HEIGHT -10)
- w=32
- end
- else
- printword("LEVEL"..mynewlevel,v)
- if v<=30.3 then
- v=v+.3
- else
- v=31
- end
- end
- if v==31 then
- fill(1, 1, 1, 255)
- stroke(10, 11, 10, 255)
- rect(5,(HEIGHT-10)-100,WIDTH,HEIGHT -10)
- printword("ARE",z)
- if z<=30.3 then
- z=z+.3
- else
- z=31
- end
- end
- if z==31 then
- fill(1, 1, 1, 255)
- stroke(10, 11, 10, 255)
- rect(5,(HEIGHT-10)-100,WIDTH,HEIGHT -10)
- printword("YOU",y)
- if y<=30.3 then
- y=y+.3
- else
- y=31
- end
- end
- if y==31 then
- fill(1, 1, 1, 255)
- stroke(10, 11, 10, 255)
- rect(5,(HEIGHT-10)-100,WIDTH,HEIGHT -10)
- printword("READY",x)
- if x<=30.3 then
- x=x+.3
- else
- x=31
- end
- end
- if x==31 then
- fill(1, 1, 1, 255)
- stroke(10, 11, 10, 255)
- rect(5,(HEIGHT-10)-100,WIDTH,HEIGHT -10)
- printword("GO",u)
- if u<=30.3 then
- u=u+.3
- else
- u=31
- end
- end
- if u == 31 then
- fill(1, 1, 1, 255)
- stroke(10, 11, 10, 255)
- rect(5,(HEIGHT-10)-100,WIDTH,HEIGHT -10)
- mystate=0
- mylevel=mylevel+mynewlevel
- end
- end
- if mylevel >0 and mylives >0 then
- if mycount < 2 then -- new mine activated
- if myradius == 11 then
- stroke(5, 238, 252, 255)
- strokeWidth(8)
- number(10, HEIGHT -10, "SCORE "..myscore, 20)
- fill(1, 1, 1, 255)
- stroke(10, 11, 10, 255)
- strokeWidth(5)
- rect(5,HEIGHT -105,150,30)
- strokeWidth(5)
- stroke(5, 238, 252, 255)
- number(10, HEIGHT -80, "STRENGTH ", 10)
- stroke(255, 0, 212, 255)
- strokeWidth(5)
- rect(160,HEIGHT -105,360,30)
- stroke(4, 4, 4, 255)
- strokeWidth(0)
- if mylives <6 then
- fill(242, 50, 16, 255)
- elseif mylives > 6 and mylives < 24 then
- fill(242, 129, 16, 255)
- else
- fill(17, 242, 38, 255)
- end
- rect(163,HEIGHT -102,mylives*10-5,24)
- end
- -- expand active mine radius by level amount
- if myradius < 31 then
- fill(20, 244, 4, 255)
- myradius = myradius + mylevelamount
- else
- mycount = mycount + 1
- end
- else
- -- decrease active mine radius by 1
- fill(244, 10, 5, 255)
- myradius = myradius - mylevelamount
- end
- -- Draw active mine radius
- ellipseMode(3)
- ellipse(myplace,myplace2,myradius,myradius)
- sprite("Tyrian Remastered:Button Glow",myplace,myplace2)
- -- check if player is pressing on mine if so
- -- give player points and mark mine as deactivated
- checkforpoints()
- if myradius < 11 then -- active mine is at smallest radius
- markhitormiss() -- check if mine deactivated or explosion
- checkforlevel() -- check if end of level
- fill(1, 1, 1, 255)
- stroke(10, 11, 10, 255)
- strokeWidth(5)
- rect(5,HEIGHT -105,150,30)
- strokeWidth(5)
- stroke(5, 238, 252, 255)
- number(10, HEIGHT -80, "STRENGTH ", 10)
- stroke(255, 0, 212, 255)
- strokeWidth(5)
- rect(160,HEIGHT -105,360,30)
- stroke(4, 4, 4, 255)
- strokeWidth(0)
- if mylives <6 then
- fill(242, 50, 16, 255)
- elseif mylives > 6 and mylives < 24 then
- fill(242, 129, 16, 255)
- else
- fill(17, 242, 38, 255)
- end
- rect(163,HEIGHT -102,mylives*10-5,24)
- if mylevel>0 and mylives >0 then
- mycount = 1 -- get ready to expand activated mine
- repeat -- get new random mine to activate
- mynumber=math.random(1,6)
- mynumber2=math.random(1,6)
- until myrow[mynumber][mynumber2] ~= 0 and myrow[mynumber][mynumber2] ~= 7
- myrow[mynumber][mynumber2]=0 -- mark as activated
- myplace=myxplaces[mynumber]
- myplace2=myyplaces[mynumber2]
- end
- end
- end
- end
- function markhitormiss()
- -- if mine deactivated colour blue else blowup
- if myrow[mynumber][mynumber2]==7 then
- sprite("Tyrian Remastered:Eye Mecha",myplace,myplace2-4)
- mylifedecrease=0
- else
- sound(SOUND_EXPLODE,1000)
- sprite("Tyrian Remastered:Explosion Huge",myplace,myplace2-6)
- mylifedecrease=1
- end
- end
- function checkforlevel()
- myhits = 0
- mymines = 0
- for c = 1,6 do
- for d = 1,6 do
- if myrow[c][d] == 0 then
- mymines = mymines+1
- end
- if myrow[c][d] == 7 then
- myhits = myhits + 1
- end
- end
- end
- mylives = mylives - mylifedecrease
- -- if no mines left end level
- if mymines+myhits == 36 then
- -- calculate bonus based on deactivated mines
- -- and add to score
- stroke(10, 11, 10, 255)
- strokeWidth(10)
- number(10, HEIGHT -10, "SCORE "..myscore, 20)
- mybonus = 0
- mybonus = mybonus + (myhits * 10)
- if myhits > 6 and myhits <13 then
- mylives = mylives + 1
- elseif myhits > 12 and myhits < 19 then
- mylives = mylives + 2
- elseif myhits > 18 and myhits < 25 then
- mylives = mylives + 3
- elseif myhits > 24 and myhits < 31 then
- mylives = mylives + 4
- elseif myhits > 30 then
- mylives = mylives + 5
- end
- -- dont let bonus strength go over full strength
- if mylives > 36 then
- mylives = 36
- end
- fill(1, 1, 1, 255)
- stroke(10, 11, 10, 255)
- rect(5,(HEIGHT-10)-70,WIDTH,HEIGHT -10)
- myscore = myscore + mybonus
- mynewlevel=mynewlevel+1
- mylevelamount=mylevelamount+.2
- if mylives > 0 then
- resetvalues()
- end
- end
- if mylives<=0 then
- stroke(5, 238, 252, 255)
- strokeWidth(8)
- number(10, HEIGHT -10, "SCORE "..myscore, 20)
- number(450, HEIGHT -10, "GAME OVER ", 20)
- end
- end
- function checkforpoints()
- if CurrentTouch.state==BEGAN or CurrentTouch.state==MOVING then
- if CurrentTouch.x <= myplace + 30 and CurrentTouch.x >= myplace - 30 then
- if CurrentTouch.y <= myplace2 + 30 and CurrentTouch.y >= myplace2 - 30 then
- stroke(10, 11, 10, 255)
- strokeWidth(10)
- number(10, HEIGHT -10, "SCORE "..myscore, 20)
- myscore = myscore + 1
- stroke(5, 238, 252, 255)
- strokeWidth(8)
- number(10, HEIGHT -10, "SCORE "..myscore, 20)
- sound(SOUND_PICKUP,2000)
- myrow[mynumber][mynumber2] = 7
- end
- end
- end
- end
- function getgrid()
- if mystate==0 then
- stroke(5, 238, 252, 255)
- strokeWidth(8)
- number(10, HEIGHT -10, "SCORE "..myscore, 20)
- end
- -- render background sprites (bricks)
- for i = 0,7 do
- for a = 0,7 do
- -- sprite("Planet Cute:Stone Block",a * 100 -1,740)
- if a==0 or a==7 then
- --wall
- if mynewlevel==1 then
- sprite("Planet Cute:Dirt Block",(a * 100 -1)+25,620-(i*82))
- elseif mynewlevel==2 then
- sprite("Planet Cute:Stone Block",(a * 100 -1)+25,620-(i*82))
- elseif mynewlevel==3 then
- sprite("Planet Cute:Grass Block",(a * 100 -1)+25,620-(i*82))
- elseif mynewlevel==4 then
- sprite("Planet Cute:Plain Block",(a * 100 -1)+25,620-(i*82))
- else
- sprite("Planet Cute:Wall Block",(a * 100 -1)+25,620-(i*82))
- end
- else
- if i ==0 or i==7 then
- --wall
- if mynewlevel==1 then
- sprite("Planet Cute:Dirt Block",(a * 100 -1)+25,620-(i*82))
- elseif mynewlevel==2 then
- sprite("Planet Cute:Stone Block",(a * 100 -1)+25,620-(i*82))
- elseif mynewlevel==3 then
- sprite("Planet Cute:Grass Block",(a * 100 -1)+25,620-(i*82))
- elseif mynewlevel==4 then
- sprite("Planet Cute:Plain Block",(a * 100 -1)+25,620-(i*82))
- else
- sprite("Planet Cute:Wall Block",(a * 100 -1)+25,620-(i*82))
- end
- if (a==2 or a==5) then
- sprite("Planet Cute:Chest Open",(a * 100 -1)+25,620-(i*82))
- end
- else
- -- ground
- if mynewlevel==1 then
- sprite("Planet Cute:Stone Block",(a * 100 -1)+25,620-(i*82))
- elseif mynewlevel==2 then
- sprite("Planet Cute:Grass Block",(a * 100 -1)+25,620-(i*82))
- elseif mynewlevel==3 then
- sprite("Planet Cute:Brown Block",(a * 100 -1)+25,620-(i*82))
- elseif mynewlevel==4 then
- sprite("Planet Cute:Ramp South",(a * 100 -1)+25,620-(i*82))
- else
- sprite("Planet Cute:Water Block",(a * 100 -1)+25,620-(i*82))
- end
- end
- end
- -- sprite("Planet Cute:Dirt Block",a * 100 -1,60)
- end
- end
- for i = 1,6 do
- for a = 0,7 do
- if a > 0 and a < 7 then
- sprite("Tyrian Remastered:Orb 1",(a * 100 -1)+25,620-(i*82)) --place initial mines
- end
- end
- end
- end
- function printword(myword,z)
- stroke(10, 11, 10, 255)
- strokeWidth(12)
- number((WIDTH/2)-((#myword/2)*30), HEIGHT -10, myword, z)
- stroke(5, 238, 252, 255)
- strokeWidth(10)
- number((WIDTH/2)-((#myword/2)*30), HEIGHT -10, myword, z)
- end
- function resetvalues()
- myradius = 11
- mycount = 1
- myxplaces={124,224,324,424,524,624}
- myyplaces={128,210,294,376,456,536}
- --myyplaces={140,220,300,380,460,540}
- --get first real random number
- mynumber=math.random(1,6)
- mynumber2=math.random(1,6)
- myplace=myxplaces[mynumber]
- myplace2=myyplaces[mynumber2]
- mybackground = 1
- myhits=0
- mymines=0
- mylevel=0
- mystate=1
- mylifedecrease = 0
- z=1
- y=1
- x=1
- w=1
- u=1
- v=1
- -- populate 6 by 6 array with 6 rows numbered 1 to 6
- -- this is used as the mine grid
- myrow={}
- for c = 1,6 do
- myrow[c] = {}
- for d = 1,6 do
- myrow[c][d] = d
- end
- end
- myrow[mynumber][mynumber2]=0
- end
- -----------------------------------
- -- Functions for drawing numbers --
- -----------------------------------
- -- Draw a number. x, y is top left
- function number(x, y, n, w)
- l = string.len(n)
- for i = 1, l do
- drawDigit(x + ((i - 1) * (w * 1.5)), y, string.sub(n, i, i), w)
- end
- end
- -- Draw a single digit
- function drawDigit(x, y, n, w)
- h = 2 * w
- if string.match(n, "1") then
- line(x + (w / 2), y, x + (w / 2), y - h)
- elseif string.match(n, "2") then
- line(x, y, x + w, y)
- line(x + w, y, x + w, y - (h / 2))
- line(x + w, y - (h / 2), x, y - (h / 2))
- line(x, y - (h / 2), x, y - h)
- line(x, y - h, x + w, y - h)
- elseif string.match(n, "3") then
- line(x, y, x + w, y)
- line(x + w, y, x + w, y - h)
- line(x + w, y - h, x, y - h)
- line(x, y - (h / 2), x + w, y - (h / 2))
- elseif string.match(n, "4") then
- line(x, y, x, y - (h / 2))
- line(x, y - (h / 2), x + w, y - (h / 2))
- line(x + w, y, x + w, y - h)
- elseif string.match(n, "5") then
- line(x + w, y, x, y)
- line(x, y, x, y - (h / 2))
- line(x, y - (h / 2), x + w, y - (h / 2))
- line(x + w, y - (h / 2), x + w, y - h)
- line(x + w, y - h, x, y - h)
- elseif string.match(n, "6") then
- line(x + w, y, x, y)
- line(x, y, x, y - h)
- line(x, y - h, x + w, y - h)
- line(x + w, y - h, x + w, y - (h / 2))
- line(x + w, y - (h / 2), x, y - (h / 2))
- elseif string.match(n, "7") then
- line(x, y, x + w, y)
- line(x + w, y, x + w, y - h)
- elseif string.match(n, "8") then
- line(x, y, x + w, y)
- line(x + w, y, x + w, y - h)
- line(x + w, y - h, x, y - h)
- line(x, y - h, x, y)
- line(x, y - (h / 2), x + w, y - (h / 2))
- elseif string.match(n, "9") then
- line(x + w, y - (h / 2), x, y - (h / 2))
- line(x, y - (h / 2), x, y)
- line(x, y, x + w, y)
- line(x + w, y, x + w, y - h)
- line(x + w, y - h, x, y - h)
- elseif string.match(n, "0") then
- line(x, y, x + w, y)
- line(x + w, y, x + w, y - h)
- line(x + w, y - h, x, y - h)
- line(x, y - h, x, y)
- elseif string.match(n, "x") then
- line(x, y - (w / 3), x + w, y - (h + 1))
- line(x + w, y - (w / 3), x, y - (h + 1))
- elseif string.match(n, "A") then
- line(x, y, x + w, y) -- across top
- line(x, y - h, x, y) --down left
- line(x + w, y, x + w, y - h) -- down right
- line(x, y - (h / 2), x + w, y - (h / 2)) -- across mid
- elseif string.match(n, "B") then
- line(x, y, x + (w/2), y) --across top
- line(x + w, y-(h/4), x + w, y-h+(h/4))-- down right
- line(x, y - h, x + (w/2), y - h)-- across bottom
- line(x, y - h, x, y)-- down left
- line(x, y - (h / 2), x + w, y - (h / 2)) -- across mid
- line(x + (w/2), y - h,x + w, y-h+(h/4))-- bottom diag
- line(x + (w/2), y,x + w, y-(h/4)) --top diag
- elseif string.match(n, "C") then
- line(x, y - h, x, y) --down left
- line(x + w, y - h, x, y - h)-- across bottom
- line(x, y, x + w, y) --across top
- elseif string.match(n, "D") then
- line(x, y, x + (w/2), y) --across top
- line(x + w, y-(h/4), x + w, y-h+(h/4))-- down right
- line(x, y - h, x + (w/2), y - h)-- across bottom
- line(x, y - h, x, y)-- down left
- line(x + (w/2), y - h,x + w, y-h+(h/4))-- bottom diag
- line(x + (w/2), y,x + w, y-(h/4)) --top diag line(x, y, x + w, y) -- across top
- elseif string.match(n, "E") then
- line(x, y - h, x, y) --down left
- line(x + w, y - h, x, y - h)-- across bottom
- line(x, y - (h / 2), x + w, y - (h / 2)) -- across mid
- line(x, y, x + w, y) -- across top
- elseif string.match(n, "F") then
- line(x, y - h, x, y) --down left
- line(x, y - (h / 2), x + w, y - (h / 2)) -- across mid
- line(x, y, x + w, y) -- across top
- elseif string.match(n, "G") then
- line(x, y - h, x, y) --down left
- line(x + w, y - h, x, y - h)-- across bottom
- line(x, y, x + w, y) --across top
- line(x + w, y - h, x + w, y - (h / 2))
- line(x + w, y - (h / 2),x+(w/2),y - (h / 2))
- elseif string.match(n, "H") then
- line(x, y - h, x, y) --down left
- line(x + w, y, x + w, y - h) -- down right
- line(x, y - (h / 2), x + w, y - (h / 2)) -- across mid
- elseif string.match(n, "I") then
- line(x + (w / 2), y, x + (w / 2), y - h)
- line(x, y, x + w, y) -- across top
- line(x + w, y - h, x, y - h)-- across bottom
- elseif string.match(n, "J") then
- line(x + w, y, x + w, y - h) -- down right
- line(x + w, y - h, x, y - h)-- across bottom
- elseif string.match(n, "K") then
- line(x, y - h, x, y) --down left
- line(x, y - (h / 2),x+w,y) -- top diag
- line(x, y - (h / 2),x+w,y-h) -- bottom diag
- elseif string.match(n, "L") then
- line(x, y - h, x, y) --down left
- line(x + w, y - h, x, y - h)-- across bottom
- elseif string.match(n, "M") then
- line(x, y - h, x, y) --down left
- line(x + w, y, x + w, y - h) -- down right
- line(x + w, y,x+(w/2),y-(h/2)) -- right diag
- line(x+(w/2),y-(h/2),x,y) -- left diag
- elseif string.match(n, "N") then
- line(x, y - h, x, y) --down left
- line(x + w, y, x + w, y - h) -- down right
- line(x, y,x+w,y-h) -- diag
- elseif string.match(n, "O") then
- line(x, y, x + w, y)
- line(x + w, y, x + w, y - h)
- line(x + w, y - h, x, y - h)
- line(x, y - h, x, y)
- elseif string.match(n, "P") then
- line(x, y, x + w, y) -- across top
- line(x, y - h, x, y) --down left
- line(x + w, y, x + w, y - (h / 2)) -- down right
- line(x, y - (h / 2), x + w, y - (h / 2)) -- across mid
- elseif string.match(n, "Q") then
- line(x, y, x + w, y)
- line(x + w, y, x + w, y - h)
- line(x + w, y - h, x, y - h)
- line(x, y - h, x, y)
- line(x+(w/4), y - h + (h/4), x-(w/4), y-h-(h/4))
- elseif string.match(n, "R") then
- line(x, y, x + w, y) -- across top
- line(x, y - h, x, y) --down left
- line(x + w, y, x + w, y - (h / 2)) -- down right
- line(x, y - (h / 2), x + w, y - (h / 2)) -- across mid
- line(x, y - (h / 2),x+w,y-h) -- bottom diag
- elseif string.match(n, "S") then
- line(x, y, x + w, y) -- across top
- line(x, y - (h / 2), x + w, y - (h / 2)) -- across mid
- line(x + w, y - h, x, y - h)-- across bottom
- line(x, y - (h / 2), x, y) -- down left
- line(x + w, y - (h / 2), x+w, y - h) -- down right
- elseif string.match(n, "T") then
- line(x + (w / 2), y, x + (w / 2), y - h)
- line(x, y, x + w, y) -- across top
- elseif string.match(n, "U") then
- line(x, y - h, x, y) --down left
- line(x + w, y, x + w, y - h) -- down right
- line(x + w, y - h, x, y - h)-- across bottom
- elseif string.match(n, "V") then
- line(x, y, x+(w/2), y-h) --down left
- line(x + w, y, x+(w/2), y - h) -- down right
- elseif string.match(n, "W") then
- line(x, y - h, x, y) --down left
- line(x + w, y, x + w, y - h) -- down right
- line(x + w, y - h, x+(w/2),y-(h/2)) --right diag
- line(x, y - h, x+(w/2),y-(h/2)) --right diag
- elseif string.match(n, "X") then
- line(x, y, x+w, y-h) --diag left
- line(x + w, y, x, y - h) -- diag right
- elseif string.match(n, "Y") then
- line(x, y, x+(w/2), y-(h/2)) --diag left
- line(x + w, y, x+(w/2), y-(h/2)) -- diag right
- line(x + (w/2), y-h, x+(w/2), y-(h/2)) -- down middle
- elseif string.match(n, "Z") then
- line(x, y, x + w, y) -- across top
- line(x + w, y - h, x, y - h)-- across bottom
- line(x + w, y, x, y - h) -- diag right
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement