--***Main Game Loop***
while true do
screen:clear()
pad = Controls.read()
if pad:start() and oldpad:start() ~= pad:start() and paused == false then paused = true end
if pad:start() and oldpad:start() ~= pad:start() and paused == true then paused = false end
if paused == true then
screen:fillRect(210,125,5 3,20,Color.new(255,255,25 5))
screen:print(214,131,"Pau sed", red)
elseif paused == false then
rnumber = math.random(1,10)
gamestime=gametimer:time( )
ammunition() --Calls for the Ammo configurations--
screen:blit(100, 0, background1)
screen:blit(0, 0, hud)
mugShot()
playerimg:blit(player.x, player.y, 30)
screen:print(375, 10, "Fighter Name", white)
screen:print(380, 25, ""..user, red)
screen:print(408, 130, "Score:"..score, white)
screen:print(413, 100, "High", red)
screen:print(408, 110, "Score:"..tscore, red)
screen:print(5, 150, "Ammo:"..ammo, white)
screen:print(45, 255, chargebar.number.."%", red)
healthBar()
shootbarS()
chargeShot()
screen:fontPrint(proporti onal, 220, 25, time, red)
--Shoots gun
if pad:r() and oldpad:r() ~= pad:r() and shootbar.number == 50 and player.State == "alive" then
shootbar.number = 0
fire:play()
bulletSetup()
end
if player.State == "dead" then
pex:blit(player.x -30, player.y - 30, 100)
boom:play()
end
if pex:getFrame() == 4 then
screen.waitVblankStart(75 )
dofile("menu.lua")
end
highScore()
collisionCheck(enemy1hit)
collisionCheck2(enemy2hit )
collisionCheck3(enemy3hit )
collisionCheckp(playerhit )
enemy1AI()
enemy2AI()
enemy3AI()
EBFire()
EB2Fire()
EB3Fire()
bulletFire()
screen:flip()
pmove()
--Game timer countdown
if gamestime>1000 then time=time - 1 gametimer:reset(0) gametimer:start() end
if time < 0 and score < tscore then
screen:clear()
screen:print(100, 100, user.."'s Score Was:"..score, white)
screen:flip()
screen.waitVblankStart(20 0)
dofile("menu.lua")
elseif time < 0 and score > tscore then
tscore = score
file = io.open("tscore.txt","w")
myText = score
file:write(myText)
file:close()
file = io.open("tuser.txt","w")
myText = user
file:write(myText)
file:close()
screen:clear()
newhi:play()
screen:print(100, 100, user.."'s Score Was:"..score, white)
screen:print(100, 110, "A NEW hight score!!!", red)
screen:flip()
screen.waitVblankStart(20 0)
dofile("menu.lua")
end
--This is for Music on/off feature
if pad:triangle() and oldpad:triangle() ~= pad:triangle() and Music.playing() == true then
Music.pause()
end
if pad:circle() and oldpad:circle() ~= pad:circle() and Music.playing() == false then
Music.resume()
end
screen.waitVblankStart()
oldpad = pad
end
end