0,]']Б>Sя}WџЭuЇ№p8Зd%qyњЪ ;]ЩAІіsяївЦвe4,Vl†3 800 then local width = print(message,0,-6) print(message,(240 - width)//2 , 136 //2 + 50,12) end local width = print(title,0,-20) print(title,(240 - width * 2)//2,136 //2 + 20,8,false,2) end spr(192,(240 - 64)//2,136 //2 - 54,0,2,0,0,4,4) -- start button if btnp(4) then gameStart = true sfx(34,"F-2",-1,3) elseif btnp(7)then level = "leaderboard" sfx(33,"c-4",-1,3) end if startD //60 >= 3 then level = "level1" player.totalScore = 0 player.stuns = 0 gameStart = false startD = 0 ResetBloodDrips() end end function LeaderBoard() cls() BloodRun() scoreHolder = {} for i = 0, 10,1 do if pmem(i) > 0 then table.insert(scoreHolder,pmem(i)) end end table.sort(scoreHolder,function(a,b) return a>b end) rect((240 - 150)//2,(136 -115)//2,150,115,15) local message = "HighScores" local width = print(message,0,-6) print(message,(240 - width * 2)//2,(136 - 105)//2,8,false,2) for i = #scoreHolder, 1 ,-1 do local message = scoreHolder[i] local width = print(message,0,-6) print(message,(240 - width)//2,(136 - 105)//2 + 15 + (7*i) ,8,false) local message = i.."." local width = print(message,0,-6) print(message,(240 - width)//2 -20,(136 - 105)//2 + 15 + (7*i) ,8,false) end if btnp(7) or btnp(4)then level = "menu" sfx(33,"c-4",-1,3) ResetBloodDrips() end end -- level info put in here for each level function Level(_level,_levelCoordsX,_levelCoordsY,_nextLevel) --stop music music() musicPlay = false -- initialise if initComplete == false then INIT() end startD = startD +1 ChainsawSound() --checks map for collidable tiles, if non you can move if CheckCollideWithSolid(leatherF,_levelCoordsX,_levelCoordsY) == false and leatherF.stunned == false then Move() else Stun() end -- draw map map(_levelCoordsX,_levelCoordsY) if startD//60 >= 3 and winTimeShown == false then --get inputs from the player Input() -- loop through victims to make them all move for i=1,#victims,1 do if(victims[i].active)then if CheckCollideWithSolid(victims[i],_levelCoordsX,_levelCoordsY) == true then VictimOpDir(victims[i])end VictimsMove(victims[i]) end end -- start text on start of level if startD//60 <= 3.5 then local width = print("Go",0,-6) print("Go" ,(240//2) - (width//2)*2,10 + 136 //2,8,false,2) end elseif startD//60 <= 3 then local width = print("Ready",0,-6) print("Ready" ,(240//2) - (width//2)*2,10 + 136 //2,8,false,2) end -- control the players bounderies movment Border(leatherF) -- loop through for victims to control th border control -- and to draw the victims sprites DrawAllVictimRemains() for i=1,#victims,1 do Border(victims[i]) DrawVictim(victims[i]) -- checks to see if victim is active if they are player can kill if(victims[i].active)then KillVictims(victims[i]) else DrawBlood(victims[i],victims[i].x,victims[i].y) end end --Draw leatherface Sprite DrawLeatherFace() -- draw the ui display kills DisplayKills() gameM.gameT = gameM.gameT-1 if gameM.gameT <= 0 then --level = "timeout" WinLevel(_nextLevel) --gameM.gameT = 1000 --music(1,-1,-1,false) end if gameM.gameT//60 <= 0 then gameM.gameT = 0 end -- print the time passed from start of game local width = print("Time",0,-6) print("Time",2,2,12) local Twidth = print(gameM.gameT//60,0,-6) if gameM.gameT//60 <= 10 then print(gameM.gameT//60,(width // 2) - Twidth //2,10,2,false,2) if gameM.gameT/60 == math.floor(gameM.gameT/60) and winTimeShown == false then sfx(2,"C-7",2,1) end else print(gameM.gameT//60,(width // 2) - Twidth //2,10,12) end end function Input() --up and sown movement if btn(0) then leatherF.vy = leatherF.vy - leatherF.accel elseif btn(1) then leatherF.vy = leatherF.vy + leatherF.accel end -- left and right movement if btn(2) then leatherF.vx = leatherF.vx - leatherF.accel elseif btn(3) then leatherF.vx = leatherF.vx + leatherF.accel end -- add friction leatherF.vy = leatherF.vy * leatherF.fFriction leatherF.vx = leatherF.vx * leatherF.fFriction -- caps the max speed to 1 if leatherF.vx > 1 then leatherF.vx = 1 elseif leatherF.vx < -1 then leatherF.vx = -1 end if leatherF.vy > 1 then leatherF.vy = 1 elseif leatherF.vy < -1 then leatherF.vy = -1 end end function Move() leatherF.x = leatherF.x + leatherF.vx leatherF.y = leatherF.y + leatherF.vy end vibT = 0 stunT = 0 idleT = 0 function DrawLeatherFace() if vibT ==1 then vibT=0 else vibT = 1 end idleT = idleT +1 stunT = stunT +1 local stunFlipNum = stunT%60//30,10,10 -- checks to see if player is stunned if leatherF.stunned == false and not winTimeShown then -------- draws sprites when moving right if btn(3) then --draws laeatherface spriteLastUsed = leatherF.sprite spr(leatherF.sprite,leatherF.x,leatherF.y,0) lastchainsawS = leatherF.chainsawSprite --draws his chainsaw spr(leatherF.chainsawSprite,leatherF.x+4,leatherF.y + vibT,0) --------draws sprites when moving left elseif btn(2) then --draws leatherface spriteLastUsed = leatherF.sprite + 3 spr(leatherF.sprite + 3,leatherF.x,leatherF.y,0) --draws his chainsaw lastchainsawS = leatherF.chainsawSprite +5 spr(leatherF.chainsawSprite + 5,leatherF.x-4,leatherF.y + vibT,0) --------- draws sprites when moving Up elseif btn(0) then --draws his chainsaw lastchainsawS = leatherF.chainsawSprite + 1 spr(leatherF.chainsawSprite+1,(leatherF.x-1)+ vibT,leatherF.y-4,0) --draws laeatherface spriteLastUsed = leatherF.sprite + 1 spr(leatherF.sprite + 1,leatherF.x,leatherF.y,0) ---------- draws sprites when moving down elseif btn(1)then --draws laeatherface spriteLastUsed = leatherF.sprite + 2 spr(leatherF.sprite + 2,leatherF.x,leatherF.y,0) --draws his chainsaw lastchainsawS = leatherF.chainsawSprite + 2 spr(leatherF.chainsawSprite+2,(leatherF.x+3) + vibT,leatherF.y+7,0) end ------------------draws sprites when no input from player if not btn(0) and not btn(1)and not btn(2) and not btn(3) then if lastchainsawS == leatherF.chainsawSprite then spr(leatherF.sprite,leatherF.x,leatherF.y,0) spr(leatherF.chainsawSprite+3 ,leatherF.x+4,leatherF.y - idleT%6//3,0) elseif lastchainsawS == leatherF.chainsawSprite+1 then spr(leatherF.chainsawSprite+1,leatherF.x-1,(leatherF.y-4) - idleT%6//3,0) spr(leatherF.sprite + 1,leatherF.x,leatherF.y,0) elseif lastchainsawS == leatherF.chainsawSprite+2 then spr(leatherF.sprite + 2,leatherF.x,leatherF.y,0) spr(leatherF.chainsawSprite+2,leatherF.x+3,(leatherF.y+7) - idleT%6//3,0) else spr(leatherF.sprite + 3,leatherF.x,leatherF.y,0) spr(leatherF.chainsawSprite+4 ,leatherF.x-4,leatherF.y - idleT%6//3,0) end end end --make dazed sprite if leatherF.stunned == true then spr(leatherF.sprite + 4,leatherF.x,leatherF.y,0) spr(leatherF.chainsawSprite+4 ,leatherF.x-5,leatherF.y,0) spr(271,leatherF.x,leatherF.y - 7,0,1,stunFlipNum) end -- if wins if winTimeShown == true then spr(leatherF.sprite + 5,leatherF.x,leatherF.y,0) spr(leatherF.chainsawSprite+4 ,leatherF.x - 3,(leatherF.y - 6) + vibT,0) end end --bloodT = 0 rX={} rY={} num=0 function DrawBlood(v,originX,originY) v.bloodT = v.bloodT + 1 if v.bloodT / 60 < 1 then if v.bloodT / 60 <= 0.02 then num = 10 for i=0,num,1 do rX[i] = math.random(-6,6) rY[i] = math.random(-3,3) end end if v.bloodT / 60 <= 0.4 then for i=0,num,1 do pix((originX + 4) + rX[i],(originY + 4) + rY[i],2) end end if v.bloodT / 60 >= 0.2 and v.bloodT / 60 < 0.22 then num = 20 for i=0,num,1 do rX[i] = math.random(-8,8) rY[i] = math.random(-6,6) end end if v.bloodT / 60 >= 0.22 and v.bloodT / 60 < 0.35 then for i=0,num,1 do pix((originX + 4) + rX[i],(originY + 4) + rY[i],2) end end if v.bloodT / 60 >= 0.35 and v.bloodT / 60 < 0.37 then num = 5 for i=0,num,1 do rX[i] = math.random(-5,5) rY[i] = math.random(-3,3) end end if v.bloodT / 60 >= 0.37 and v.bloodT / 60 < 0.6 then for i=0,num,1 do pix((originX + 4) + rX[i],(originY + 4) + rY[i],2) end end end end function VictimsMove(v) local r = math.random(2,5) v.timer = v.timer +1 if v.timer > r*60 then v.direction = math.random(0,3) v.timer = 0 end if v.direction == 0 then v.vx = (v.speed) v.vy = 0 elseif v.direction == 1 then v.vx = (-1 * v.speed) v.vy = 0 elseif v.direction == 2 then v.vy = (v.speed) v.vx = 0 elseif v.direction == 3 then v.vy = (-1 * v.speed) v.vx = 0 end v.x = v.x + v.vx v.y = v.y + v.vy end function VictimOpDir(v) if v.direction == 0 then v.direction = 1 elseif v.direction == 1 then v.direction = 0 elseif v.direction == 2 then v.direction = 3 elseif v.direction == 3 then v.direction = 2 end end function DrawVictim(v) if v.active==false then v.deathT = v.deathT + 1 if v.deathT < 5 then spr(v.sprite + 4,v.x,v.y,0,1,1) elseif v.deathT < 10 and v.deathT >= 5 then spr(v.sprite + 5,v.x,v.y,0,1,1) elseif v.deathT < 15 and v.deathT >= 10 then spr(v.sprite + 6,v.x,v.y,0,1,1) elseif v.deathT < 20 and v.deathT >= 15 then spr(v.sprite + 7,v.x,v.y,0,1,1) elseif v.deathT < 25 and v.deathT >= 20 then spr(v.sprite + 8,v.x,v.y,0,1,1) elseif v.deathT < 30 and v.deathT >= 25 then spr(v.sprite + 9,v.x,v.y,0,1,1) elseif v.deathT < 35 and v.deathT >= 30 then spr(v.sprite + 10,v.x,v.y,0,1,1) local s = {v.sprite + 10,v.x,v.y,0,1,1} --spr(s[1],s[2],s[3],s[4],s[5],s[6]) table.insert(vicBloodSplats,s) else end return end -------- draws sprites when moving right if v.vx > 0 then spr(v.sprite,v.x,v.y,0) --------draws sprites when moving left elseif v.vx < 0 then spr(v.sprite,v.x,v.y,0,1,1) end --------- draws sprites when moving Up if v.vy < 0 then spr(v.sprite + 1,v.x,v.y,0) ---------- draws sprites when moving down elseif v.vy > 0 then spr(v.sprite + 2,v.x,v.y,0) end if v.vy == 0 and v.vx == 0 then spr(v.sprite,v.x,v.y,0) end end function DrawAllVictimRemains() if #vicBloodSplats > 0 then for i=1,#vicBloodSplats,1 do spr(vicBloodSplats[i][1],vicBloodSplats[i][2],vicBloodSplats[i] [3],vicBloodSplats[i][4],vicBloodSplats[i][5],vicBloodSplats[i][6]) end end end function Border(obj) if obj.x > 236 then obj.x = -4 end if obj.x < -4 then obj.x = 236 end if obj.y < -4 then obj.y = 130 end if obj.y > 130 then obj.y = -4 end end function KillVictims(v) hit = Collision(leatherF.x,leatherF.y,v.x,v.y) if hit then v.active = false vDead = vDead + 1 gameM.victimsOnScreen = gameM.victimsOnScreen -1 sfx(17,'G-3',-1,1) end if gameM.victimsOnScreen <= gameM.victimMinAmount then gameM.vSpawnDelayT = gameM.vSpawnDelayT + 1 if gameM.vSpawnDelayT >= gameM.vSpawnDelay then MakeVictims(gameM.victimSpawnAmount) gameM.vSpawnDelayT =0 end end end function Collision(px,py,ox,oy) local hitX = false; local hitY = false; -- left or right side collided? if(px>=ox and pxox and px+8=oy and pyoy and py+80 end function CheckCollideWithSolid(c,cX,cY) u =c.y + (c.vy +1) d =c.y + c.vy + 6 l =c.x + (c.vx +1) r =c.x + c.vx + 6 local hit = false -- check sideCollisions with solid if c.vx < 0 and (CheckMapTileSolid(l,u,cX,cY))or CheckMapTileSolid(l,d,cX,cY) then c.vx = 0 hit = true end if c.vx > 0 and (CheckMapTileSolid(r,u,cX,cY))or CheckMapTileSolid(r,d,cX,cY) then c.vx = 0 hit = true end -- check top,bottom collisions with solid if c.vy < 0 and (CheckMapTileSolid(l,u,cX,cY))or CheckMapTileSolid(r,u,cX,cY) then c.vy = 0 hit = true end if c.vy > 0 and (CheckMapTileSolid(l,d,cX,cY))or CheckMapTileSolid(r,d,cX,cY) then c.vy = 0 hit = true end return hit end function DisplayKills() local width = print("Kills ".. vDead,0,-6) print("Kills ".. vDead ,235 - width,2,2) end function ChainsawSound() isRevving = false if not leatherF.stunned and winTimeShown == false then -- check to see if player velocity is more than (Moving) if btn(0) or btn(1) or btn(2) or btn(3) then isRevving = true end stunSPlaying = false else if stunSPlaying == false then --sfx(-1) sfx(16,'F#1',-1) revSPlaying = false IdleSPlaying = true stunSPlaying = true end end -- play the running sound if isRevving == true and revSPlaying == false then sfx(16,'F#2',-1) revSPlaying = true IdleSPlaying = false --play the idle sound elseif isRevving == false and IdleSPlaying == false then sfx(16,'A-1',-1) revSPlaying = false IdleSPlaying = true elseif winTimeShown == true then if winSPlaying == false then winSPlaying = true sfx(-1) sfx(16,'G#2',-1) end end end function Stun() -- plays the sound and sets flag for stunned state local stunTime = 1 if hasPlayedS == false then sfx(18,'A-3',-1,1) leatherF.stunned = true hasPlayedS = true player.stuns = player.stuns + 1 end -- cuts out velocity when stunned if leatherF.stunned then leatherF.sTimer = leatherF.sTimer+1 leatherF.vx = 0 leatherF.vy = 0 end -- after stun time unstun if leatherF.sTimer//60 > stunTime then leatherF.stunned =false hasPlayedS = false leatherF.sTimer = 0 end end function WinLevel(_level) if winTimeShown == false then wintime = gameM.gameT winTimeShown = true end leatherF.vx = 0 leatherF.vy = 0 local width = print(vDead,0,-6) print(vDead,(239//2) - (width//2)*3 ,136 //2 - 20,8,false,3) local width = print("Killed",0,-6) -- print(vDead, 240//2 - 45 ,136 //2 + 40,8,false,3) print("Killed", (239//2) - (width//2)*3 ,136 //2,8,false,3) gameM.winT = gameM.winT +1 -- print("With "..(wintime//60).." Seconds Left",240//2 -55 ,136 //2+20,8,false) -- gameM.gameT = wintime if gameM.winT//60 > 5 then player.totalScore = player.totalScore + wintime//60 level = _level gameM.gameT = gameM.SetGameT gameM.winT = 0 for i=1,#vicBloodSplats,1 do vicBloodSplats[i] = nil end initComplete = false startD =0 music(0) end end secs = 0 function RecapScreen() cls() BloodRun() t=time()//1 secs = secs + 1 if secs <= 1 then sfx(-1) --music() music(2,-1,-1,false) score = vDead * 10 if score <=0 then score =0 end SaveScore(score) --pmem(0,player.totalScore - player.stuns) end rect((240 - 150)//2,(136 -115)//2,150,115,15) local message = " Total Score" local width = print(message,0,-6) print(message,(240 - width * 2)//2,(136 - 110)//2,8,false,2) local message = "Total Kills "..vDead .." People" local width = print(message,0,-6) print(message,(240 - width)//2,(136 -20)//2,2) --local message = "Total Stuns " .. player.stuns.." * 10" --local width = print(message,0,-6) --print(message,(240 - width)//2,(136 -40)//2,2) --local message = player.totalScore.." - "..(player.stuns*10) --local width = print(message,0,-6) --print(message,(240 - width)//2,(136)//2,8) local message = "Total Points\n" local width = print(message,0,-6) print(message,(240 - width * 2)//2,(136 + 40)//2,10,false,2) if secs >= 5*60 then local message = score local width = print(message,0,-6) print(message,(240 - width * 2)//2,(136 + 80)//2,10,false,2) if btnp(4,60,60) then level = "leaderboard" sfx(33,"c-4",-1,3) secs = 0 ResetBloodDrips() end if t%1600 > 800 then local message = "Press A" local width = print(message,0,-6) print(message,(240 - width)//2,(136+120)//2,12) end end end -- makes the blood run at the recap screen function BloodRun() cls() blood_t = blood_t + 0.3 local timer local next = 0 for i = 0,bloodDripIndex,1 do if drip[i] == nil then drip[i] = {speed = dripSpeed[math.random(1,#dripSpeed)],widthShift = unEvenNumbers[math.random(1,#unEvenNumbers)],timer = 0} end if drip[i].speed > 1 then drip[i].timer = blood_t drip[i].speed = drip[i].speed - 0.001 else drip[i].speed = 1 end rect(blood_x + next ,blood_y,drip[i].widthShift,(drip[i].timer * drip[i].speed),2) circ((blood_x + next) + (drip[i].widthShift /2),blood_y + (drip[i].timer * drip[i].speed),drip[i].widthShift//2 ,2) drip[i].lastFrameSpeed = drip[i].speed next = next + drip[i].widthShift end end function ResetBloodDrips() for i = 0,bloodDripIndex,1 do drip[i] = nil end blood_t = 0 end function SaveScore(_score) for i =0,10,1 do if pmem(i) == 0 then pmem(i,_score) do return end end end for i =0,10,1 do if pmem(i) <= _score then pmem(i,_score) do return end end end end tOTime = 0 function TimeOutScreen() startD =0 tOTime = tOTime + 1 rect(0,0,240,136,0) BloodRun() sfx(-1) local message = "Out Of Time" local width = print(message,0,-6) print(message,(240 - width*3)//2,(136 -10)//2,8,false,3) if tOTime //60 > 3 then local message = "Press A" local width = print(message,0,-6) print(message,(240 - width)//2,(136+120)//2,12) if btnp(4) then tOTime = 0 sfx(33,"c-4",-1,3) level = "recap" ResetBloodDrips() end end end