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wwwwwwwwww7swwwwwwwwwwwwwwwwwww}wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww wwwwẇwwwwwwwww}wwww0.9 then if rank>0.3 then newType=3 --big end elseif rand>0.75 then if rank>0.15 then newType=2 --runner end end if newType==1 then newEnemy.rad=4 newEnemy.maxHp=150 newEnemy.hp=newEnemy.maxHp newEnemy.type=newType elseif newType==2 then newEnemy.rad=4 newEnemy.maxHp=100 newEnemy.hp=newEnemy.maxHp newEnemy.type=newType newEnemy.speed=newEnemy.speed*2 else newEnemy.rad=8 newEnemy.maxHp=500 newEnemy.hp=newEnemy.maxHp newEnemy.type=newType newEnemy.speed=newEnemy.speed/3 end local newVel local ang=AngBetween(newEnemy,p) local newVel=AngToVector(ang) newEnemy.vel=newVel newEnemy.ang=ang table.insert(enemyList, newEnemy) end --Spawns a bullet function SpawnBullet(src,angle,newType) local newX=src.x local newY=src.y local newVel=AngToVector(angle) local newDam local speed --Temp, applied to vel later local newRad if newType==1 then --pistol/smg speed=6 newDam=50 newRad=2 elseif newType==2 then --shotgun speed=5.25+math.random()*1.5 --random speed newDam=40 newRad=2 elseif newType==3 then --AR speed=7 newDam=75 newRad=3 elseif newType==4 then --Rifle speed=8 newDam=170 newRad=3 elseif newType==5 then --Grenade local mouseLoc={x=mX+camX,y=mY+camY} speed=0.05*Dist(src,mouseLoc) newDam=500 newRad=40 else --Enemy bullet speed=1 newDam=17 newRad=1 end newVel.x=newVel.x*speed newVel.y=newVel.y*speed local newBul={ x=newX, y=newY, vel=newVel, ang=angle, dam=newDam, life=0, rad=newRad, type=newType, remove=false } table.insert(bulletList,newBul) end --Spawns a pickup --[[ 1=health 2=smg 3=shotgun 4=ar 5=sniper 6=grende ]] function SpawnPickup(newX,newY,newType) local newPickup={ x=newX, y=newY, type=newType, rad=4, timer=0, remove=false } table.insert(pickupList,newPickup) end function SpawnParticle(v,x_,y_,a) local newType if type(v)=="string" then newType=1 else newType=v end local newParticle={ type=newType, x=x_, y=y_, vel=AngToVector(a), life=0, yellow=false, value=nil, remove=false } if newType==1 then newParticle.vel.x=0 newParticle.vel.y=-1.5 newParticle.value=v elseif newType==2 or newType==3 then newParticle.vel.x=newParticle.vel.x*2.5*(math.random()/2+0.2) newParticle.vel.y=newParticle.vel.y*2.5*(math.random()/2+0.2) if newType==3 then newParticle.type=2 newParticle.yellow=true end end table.insert(particleList,newParticle) end --Adds ammo function AddAmmo(w,amount) p.guns[w].ammo=p.guns[w].ammo+amount if p.guns[w].ammo>p.guns[w].ammoMax then p.guns[w].ammo=p.guns[w].ammoMax end end --Normalize a (x,y) vector function Normalize(v) local l=math.sqrt(v.x*v.x+v.y*v.y) v.x=v.x/l v.y=v.y/l return v end --Distance formula function Dist(a,b) return math.sqrt(((b.x-a.x)*(b.x-a.x))+((b.y-a.y)*(b.y-a.y))) end --Takes an angle 0.0 to 1.0 and returns a normalized vector function AngToVector(input) output={x,y} output.x=math.cos(input*tau) output.y=math.sin(input*tau) return output end function AngToDir(input) local output local ang=input.ang if ang<0.25 then output=1 elseif ang<0.5 then output=2 elseif ang<0.75 then output=3 else output=4 end return output end --Circle collision detection function Col(a,b) local dX=a.x-b.x local dY=a.y-b.y local d=(dX*dX)+(dY*dY) local dHit=(a.rad+b.rad)*(a.rad+b.rad) if d<=dHit then return true end return false end --takes a vector and returns an angle from 0.0 to 1.0 function VectorToAng(input) output=math.atan2(input.y,input.x) if output<0 then output=output+tau end output=output/tau return output end function AngBetween(input1,input2) temp={x,y} temp.x=input2.x-input1.x temp.y=input2.y-input1.y return VectorToAng(temp) end function DamagePlayer(amount) if p.hp>0 then p.hp=p.hp-amount p.invulnTimer=90 if p.hp<=0 then PlaySound(12) p.hp=0 gameOverTimer=0 p.invulnTimer=0 else PlaySound(7) end end end function PlaySound(id) if id==1 then --Pistol sfx(1,47,30,0,10,1) elseif id==2 then --shotgun sfx(1,35,30,0,12,0) elseif id==3 then --AR sfx(1,38,30,0,14,1) elseif id==4 then --Rifle sfx(1,50,30,0,15,-1) elseif id==5 then --explosion sfx(0,40,30,3,15,-1) elseif id==6 then --enemy hit sfx(4,17,30,1,12,0) elseif id==7 then --player hit sfx(5,48,30,3,12,1) elseif id==8 then --pickup blip sfx(2,45,30,2,10,1) elseif id==9 then --menu screen change sfx(3,36,60,3,12,-1) elseif id==10 then --throw nade sfx(6,32,60,3,12,1) elseif id==11 then --weapon change blip sfx(7,22,60,2,9,3) elseif id==12 then --player die sfx(5,60,60,2,9,0) end end function NewGame() timer=0 timerSecs=0 gameOverTimer=-1 infoScreen=false p.x=mapWidth/2 p.y=mapHeight/2 p.hp=p.hpMax p.gun=1 p.guns[2].ammo=0--p.guns[2].ammoMax p.guns[3].ammo=0--p.guns[3].ammoMax p.guns[4].ammo=0--p.guns[4].ammoMax p.guns[5].ammo=0--p.guns[5].ammoMax p.grenades=2 score=0 kills=0 spawnDelay=15 rank=0 for i,v in ipairs(enemyList) do enemyList[i]=nil end for i,v in ipairs(bulletList) do enemyList[i]=nil end for i,v in ipairs(pickupList) do pickupList[i]=nil end for i,v in ipairs(particleList) do particleList[i]=nil end end --Create Map for ix=0,mwt-1 do for iy=0,mht-1 do local rand=math.random() if rand>0.98 then rand=math.random() if rand>0.7 then mset(ix,iy,36) else mset(ix,iy,37) end elseif rand>0.7 then rand=math.random() if rand>0.66 then mset(ix,iy,33) elseif rand>.33 then mset(ix,iy,34) else mset(ix,iy,35) end else mset(ix,iy,32) end end end function TIC() --------- --LOGIC-- --------- mX,mY,b1,b3,b2,sX,sY=mouse() if mX==255 then mX=0 end if mY==255 then mY=0 end if gamestate==1 then --title screen if infoScreen==false then menuAnimTimer=menuAnimTimer+1 if menuAnimTimer>20 then menuAnimTimer=0 end if btnp(4) then PlaySound(9) gamestate=2 NewGame() camX=p.x-90+((mX-90)*0.3) camY=p.y-(screenHeight//2)+((mY-68)*0.3) end if btnp(5) then PlaySound(9) infoScreen=true end else if btnp(4) then PlaySound(9) infoScreen=false end end elseif gamestate==2 then --game --Timer stuff timer=timer+1 if timer==60 then timer=0 timerSecs=timerSecs+1 --Update rank rank=timerSecs/400 --rank=1 if rank>1 then rank=1 end end if gameOverTimer>-1 then gameOverTimer=gameOverTimer+1 if gameOverTimer==91 or gameOverTimer==181 then PlaySound(9) end if btnp(4) and gameOverTimer>200 then PlaySound(9) gamestate=1 NewGame() end end spawnDelay=spawnDelay-1 if spawnDelay==0 then --sliding from 3 secs to 1 by rank spawnDelay=math.floor(60+(1-rank)*60) if p.hp>0 then SpawnEnemy() end end --Position camera camX=p.x-90+((mX-90)*0.3) camY=p.y-(screenHeight//2)+((mY-68)*0.3) --Clamp camera to map bounds if camX<0 then camX=0 elseif camX>mapWidth-screenWidth+59 then camX=mapWidth-screenWidth+59 end if camY<0 then camY=0 elseif camY>mapHeight-screenHeight then camY=mapHeight-screenHeight end --Player movement p.running=false if p.hp>0 then if btn(0) then p.running=true if btn(2) or btn(3) then p.y=p.y-p.speed*0.707 else p.y=p.y-p.speed end elseif btn(1) then p.running=true if btn(2) or btn(3) then p.y=p.y+p.speed*0.707 else p.y=p.y+p.speed end end if btn(2) then p.running=true if btn(0) or btn(1) then p.x=p.x-p.speed*0.707 else p.x=p.x-p.speed end elseif btn(3) then p.running=true if btn(0) or btn(1) then p.x=p.x+p.speed*0.707 else p.x=p.x+p.speed end end end --Clamp player pos within map bounds if p.x<4 then p.x=4 elseif p.x>mapWidth-4 then p.x=mapWidth-4 end if p.y<4 then p.y=4 elseif p.y>mapHeight-4 then p.y=mapHeight-4 end --weapon switching if p.hp>0 then if btnp(4) or btnp(5) or sY~=0 then if p.guns[2].ammo>0 or p.guns[3].ammo>0 or p.guns[4].ammo>0 or p.guns[5].ammo>0 then PlaySound(11) end local dir if btnp(4) or sY>0 then dir=-1 else dir=1 end local loop=true while loop do p.gun=p.gun+dir if p.gun>5 then p.gun=1 end if p.gun==0 then p.gun=5 end if p.guns[p.gun].ammo>0 then loop=false end end end end --Invuln timer if p.invulnTimer>0 then p.invulnTimer=p.invulnTimer-1 end --Enemy collisions for i,v in ipairs(enemyList) do if Col(p,v) and p.invulnTimer==0 then DamagePlayer(20) end end --Player shooting if p.hp>0 then if p.swingTimer>0 then p.swingTimer=p.swingTimer-1 else if b1 then --Play sound PlaySound(p.guns[p.gun].sound) local tempTar={x=mX+camX, y=mY+camY} local spread=p.guns[p.gun].spread local repeats=1 if p.gun==3 then repeats=8 end for i=1,repeats do local angOffset=spread/2*-1+math.random()*spread SpawnBullet(p,AngBetween(p,tempTar)+angOffset,p.guns[p.gun].bulType) end p.swingTimer=p.guns[p.gun].timer --Subtract one bullet if not on pistol if p.gun ~=1 then p.guns[p.gun].ammo=p.guns[p.gun].ammo-1 end --Auto switch to pistol if out of ammo if p.guns[p.gun].ammo==0 then p.gun=1 end end end if p.grenadeSwingTimer>0 then p.grenadeSwingTimer=p.grenadeSwingTimer-1 else if b2 and p.grenades>0 then PlaySound(10) local tempTar={x=mX+camX, y=mY+camY} local tempAng=AngBetween(p,tempTar) tempAng=tempAng-0.005+math.random()*0.01 SpawnBullet(p,tempAng,5) p.grenades=p.grenades-1 p.grenadeSwingTimer=60 end end end --Update bullets for i,v in ipairs(bulletList) do --slow it down if it's a grenade if v.type==5 then v.vel.x=v.vel.x*0.95 v.vel.y=v.vel.y*0.95 end --Move the bullet --Apply speed increase by rank if enemy local modifier=1 if v.type==6 then modifier=modifier+rank*0.5 end v.x=v.x+v.vel.x*modifier v.y=v.y+v.vel.y*modifier --check collisions if v.type==6 then --enemy bullet if Col(p,v) and p.invulnTimer==0 and p.hp>0 then DamagePlayer(v.dam) v.remove=true i=i-1 end elseif v.type==5 then --grenade else --normal bullets for ie,ve in ipairs(enemyList) do if Col(ve,v) then if ve.hp>0 then PlaySound(6) ve.hp=ve.hp-v.dam ve.flashTimer=4 local particleAng=v.ang+0.5 if particleAng>1 then particleAng=particleAng-1 end local tempCol=2 if ve.type==2 then tempCol=3 end SpawnParticle(tempCol,v.x,v.y,particleAng) SpawnParticle(tempCol,v.x,v.y,particleAng) v.remove=true end end end end --Update timers/clearing v.life=v.life+1 if v.type==6 then --enemy bullet if v.x<-20 or v.x>mapWidth+20 or v.y<-20 or v.y>mapHeight+20 then v.remove=true end elseif v.type==5 then --grenade if v.life==90 then --stop the movement v.vel.x=0 v.vel.y=0 --spawn explosion PlaySound(5) for ie,ve in ipairs(enemyList) do if Col(ve,v) then if ve.hp>0 then ve.hp=ve.hp-v.dam end end end elseif v.life>92 then --delete the grenade v.remove=true end else --regular bullets if v.life>30 then v.remove=true end end end --Remove dead bulets for i=#bulletList,1,-1 do if bulletList[i].remove then table.remove(bulletList, i) end end --Update enemies for i,v in ipairs(enemyList) do v.timer=v.timer+1 if v.flashTimer>0 then v.flashTimer=v.flashTimer-1 end v.moveTimer=v.moveTimer-1 if v.moveTimer==0 then v.ang=AngBetween(v,p) v.vel=AngToVector(v.ang) v.moveTimer=60 end v.x=v.x+v.vel.x*v.speed v.y=v.y+v.vel.y*v.speed v.swingTimer=v.swingTimer-1 if v.swingTimer==0 then if Dist(v,p)<128 then if v.type==1 then if p.hp>0 then SpawnBullet(v,AngBetween(v,p),6) end elseif v.type==3 then local r=math.random()*2 for i=1,8 do if p.hp>0 then SpawnBullet(v,r+i*0.625,6) end end end end v.swingTimer=math.floor(60+(1-rank)*30) end if v.hp<=0 then v.remove=true if p.hp>0 then --only add score if game isn't over yet kills=kills+1 local tempCol=2 if v.type==2 then tempCol=3 end for i=1,8 do SpawnParticle(tempCol, v.x-v.rad+math.random()*v.rad*2, v.y-v.rad+math.random()*v.rad*2, math.random()) end if v.type==1 then score=score+100 elseif v.type==2 then score=score+75 else score=score+250 end end --chance to drop pickup if math.random()>0.85 then local rand=math.random(6) SpawnPickup(v.x,v.y,rand) end end end --Remove dead enemies for i=#enemyList,1,-1 do if enemyList[i].remove then table.remove(enemyList, i) end end --Update pickups for i,v in ipairs(pickupList) do v.timer=v.timer+1 if Col(v,p) then v.remove=true score=score+100 PlaySound(8) if v.type==1 then local healAmount=30 if p.hp==p.hpMax then score=score+200 SpawnParticle("200 BONUS!",v.x,v.y,0) else p.hp=p.hp+healAmount if p.hp>p.hpMax then p.hp=p.hpMax end SpawnParticle("Health",v.x,v.y,0) end elseif v.type==2 then --smg AddAmmo(2,80) SpawnParticle("SMG",v.x,v.y,0) elseif v.type==3 then --shotgun AddAmmo(3,15) SpawnParticle("Shotgun",v.x,v.y,0) elseif v.type==4 then --ar AddAmmo(4,50) SpawnParticle("AR",v.x,v.y,0) elseif v.type==5 then --sniper AddAmmo(5,15) SpawnParticle("Sniper",v.x,v.y,0) else --v.type==6 --grenades p.grenades=p.grenades+1 if p.grenades>p.grenadesMax then p.grenades=p.grenadesMax end SpawnParticle("Grenade",v.x,v.y,0) end end if v.timer>900 then v.remove=true end end --Remove dead pickups for i=#pickupList,1,-1 do if pickupList[i].remove then table.remove(pickupList, i) end end --Update particles for i,v in ipairs(particleList) do --move particle v.x=v.x+v.vel.x v.y=v.y+v.vel.y v.life=v.life+1 if v.type==1 then --text v.vel.y=v.vel.y+0.08 if v.vel.y>0 then v.vel.y=0 end if v.life>60 then v.remove=true end elseif v.type==2 then --bone particle v.vel.x=v.vel.x*0.95 v.vel.y=v.vel.y*0.95 if v.life>20 then v.remove=true end end end --Remove dead particles for i=#particleList,1,-1 do if particleList[i].remove then table.remove(particleList, i) end end end--gamestate2 ------------- --RENDERING-- ------------- cls(0) if gamestate==1 then if infoScreen==false then print("THE",100,25,12,false,2) print("BONE ZONE",67,40,12,false,2) print("Press A to begin",73,75,12) print("Press B for info",73,85,12) --spr(149,5,115,0,1,0,0,4,3) --print("WASD keybinds",37,117,12) --print("recommended!",37,125,12) print("A game by Yakkers",3,128,12) print("v1.1",218,128,12) --find frame local sprId if menuAnimTimer>15 then sprId=320 elseif menuAnimTimer>10 then sprId=321 elseif menuAnimTimer>5 then sprId=322 else sprId=323 end --Blink yellow if menuAnimTimer%4<2 then sprId=sprId+16 end spr(sprId,44,37,0,2) spr(sprId,176,37,0,2) else local cTop=6 local iTop=7 print("HOW TO PLAY",57,10,12,false,2) print("Scroll wheel or A&B: Cycle weapons",27,25+cTop,12) print("Left click: Fire",27,33+cTop,12) print("Right click: Throw grenade",27,42+cTop,12) print("Your goal is to survive an onslaught of",10,58+iTop,12) print("angry skeletons for as long as possible.",10,66+iTop,12) print("Skeletons will drop ammo and health",10,74+iTop,12) print("kits to aid you in your survival. A health",10,82+iTop,12) print("kit is worth bonus points while your",10,90+iTop,12) print("health is full. Good luck!",10,98+iTop,12) print("Press A to return",67,121,12) end elseif gamestate==2 then --Draw map map(camX//8,camY//8,31,18,camX%8*-1,camY%8*-1) --Draw player local mouseLoc={ x=mX+camX, y=mY+camY } local tempAng=AngBetween(p,mouseLoc) local tempObj={ ang=tempAng } local dir=AngToDir(tempObj) local flip=0 local backwards=0 local altFrame=0 local flash=0 if dir==2 or dir==3 then flip=1 end if dir>2 then backwards=2 end if p.running and timer%10>4 then altFrame=1 end if p.invulnTimer>0 and timer%2==0 then flash=1 end local sprite=256+altFrame+backwards+flash*16 if p.hp==0 then spr(288,p.x-4-camX,p.y-4-camY,11) else spr(sprite,p.x-4-camX,p.y-4-camY,11,1,flip) end --Draw pickups for i,v in ipairs(pickupList) do local draw=true if v.timer>720 and timer%2==0 then draw=false end if draw then spr(472+v.type,v.x-camX-4,v.y-camY-4,11) end end --Draw enemies for i,v in ipairs(enemyList) do local dir=AngToDir(v) local flip=0 --horizontal flip local backwards=0 --use back frame local altFrame=0 --for 2frame walk cycle local flash=0 if dir==2 or dir==3 then flip=1 end if dir>2 then backwards=1 end if v.timer%10>4 then altFrame=1 end if v.flashTimer>0 then flash=1 end local sprite local sprSize if v.type==1 then sprite=264 sprSize=1 elseif v.type==2 then sprite=296 sprSize=1 else sprite=328 sprSize=2 end sprite=sprite+altFrame*sprSize sprite=sprite+backwards*sprSize*2 sprite=sprite+16*flash*sprSize spr(sprite,v.x-camX-v.rad,v.y-camY-v.rad,0,1,flip,0,sprSize,sprSize) end --Draw bone particles for i,v in ipairs(particleList) do if v.type==2 then local sprite=392+v.life%4 if v.yellow==true then sprite=sprite+16 end spr(sprite,v.x-camX-4,v.y-camY-4,0) end end --Draw bullets for i,v in ipairs(bulletList) do local a=v.ang --rotate by 1/16 so the octants point polar a=a+0.0625 if a>1 then a=a-1 end local sprId,sprRot local sprSize=1 local diag=false if a<0.125 then --right sprRot=0 elseif a<0.25 then --downright diag=true sprRot=0 elseif a<0.375 then --down sprRot=1 elseif a<0.5 then --downleft diag=true sprRot=1 elseif a<0.625 then --left sprRot=2 elseif a<0.75 then --upleft diag=true sprRot=2 elseif a<0.875 then --up sprRot=3 else --upright diag=true sprRot=3 end if v.type==1 then --pistol/smg sprId=352 elseif v.type==2 then --shotgun sprId=368 sprRot=0 diag=false elseif v.type==3 then --ar sprId=384 sprSize=2 elseif v.type==4 then --rifle sprId=416 sprSize=2 elseif v.type==5 then --grenade sprId=448 if timer%3==0 then sprId=449 end sprRot=0 diag=false else --enemy bullet sprRot=0 diag=false --find frame local s=v.life%40 if s>30 then sprId=320 elseif s>20 then sprId=321 elseif s>10 then sprId=322 else sprId=323 end --Blink yellow if timer%4<2 then sprId=sprId+16 end end if diag then if v.type==3 or v.type==4 then sprId=sprId+2 else sprId=sprId+1 end end spr(sprId,v.x-4*sprSize-camX,v.y-4*sprSize-camY,0,1,0,sprRot,sprSize,sprSize) if v.type==5 and v.life>=90 then circ(v.x-camX,v.y-camY,v.rad,12) end end --Draw enemy HP bars for i,v in ipairs(enemyList) do local pX=v.x-4-camX local pY=v.y-v.rad-4-camY rect(pX,pY,8,2,0) rect(pX,pY,v.hp/v.maxHp*8,2,2) end --Draw text particles for i,v in ipairs(particleList) do if v.type==1 then local width=print(v.value,0,-8) print(v.value,v.x-camX-width/2,v.y-camY,12) end end end --gamestate 2 drawOverlay() end vpX=185 vpY=4 vpWidth=51 vpHeight=43 --Draw HUD function drawOverlay() if gamestate==1 then elseif gamestate==2 then --HUD cover rect(181,0,59,136,15) --Map rect(vpX,vpY,vpWidth,vpHeight,0) pix(vpX+p.x/mapWidth*vpWidth,vpY+p.y/mapHeight*vpHeight,6) for i,v in ipairs(enemyList) do pix(vpX+v.x/mapWidth*vpWidth,vpY+v.y/mapHeight*vpHeight,2) end rectb(vpX-1,vpY-1,vpWidth+2,vpHeight+2,12) --HP bar rectb(184,51,53,9,12) --border rect(185,52,51,7,16) --backdrop rect(185,52,p.hp/p.hpMax*51,7,2) --fill --Score and kills print(score,184,63,12) --print(rank,4,screenHeight-8,12) if kills==1 then print("1 kill",184,71,12) else print(kills .." kills",184,71,12) end --Weapon info local grenadeCol if p.grenades>0 then spr(469,211,85) --grenade icon grenadeCol=12 else spr(501,211,85) grenadeCol=14 end print(p.grenades.."/"..p.grenadesMax,220,87,grenadeCol) for i=1,5 do local offset=0 local col=12 --white if p.gun==i then offset=16 --selected icons col=4 --yellow elseif p.guns[i].ammo==0 then offset=32 --out of ammo icons col=14 --gray end spr(463+offset+i,184,75+i*10) if i>1 then print(p.guns[i].ammo.."/"..p.guns[i].ammoMax,195,77+i*10,col) else local infOffset=0 if p.gun==1 then infOffset=-16 end spr(470+infOffset,195,76+i*10,0,1,0,0,2,1) end end if gameOverTimer>90 then print("GAME OVER",65,20,12) end if gameOverTimer>180 then print("Press A to return to main menu",8,30,12) end end end