Code: Select all
function love.load()
--Load in images
bg = love.graphics.newImage("images/bg.png")
eyel = love.graphics.newImage("images/eyel.png")
eyer = love.graphics.newImage("images/eyer.png")
bOne = love.graphics.newImage("images/b1.png")
wnr = love.graphics.newImage("images/wnr.png")
lsr = love.graphics.newImage("images/lsr.png")
--set default positions
--Lid Positions
elx = 159
ely = 100 --max is 209
erx = 471
ery = 92 --max is 205
--Bonus Text Positions
bonusly = 700 -- Move to 550 to show
bonusry = 700 -- Move to 550 to show
--Win/Lose postitions
wnx = 900 -- Move to 50 to show for left 600 for right
lrx = 900 -- Move to 50 to show for left 600 for right
--starting values
canMove = true
canCont = true
closeSpeed = .3
incSpeed = 0.001
lMoveAmt = 25
rMoveAmt = 25
gameOver = false
end
function love.update()
--add incSpeed to closeSpeed every second
if closeSpeed < 6 and closeSpeed > 0 then
closeSpeed = closeSpeed + incSpeed
end
--move left lid down
if ely <= 209 and canMove == true then
ely = ely + closeSpeed
end
--move right lid down
if ery <= 205 and canMove == true then
ery = ery + closeSpeed
end
--check for win or loose
if ely >= 209 then
canMove = false
canCont = false
wnx = 50
lrx = 600
gameOver = true
end
if ery >= 205 then
canMove = false
canCont = false
wnx = 600
lrx = 50
gameOver = true
end
end
function love.keypressed(key)
if key == "z" and ely <= 209 and ely >= 100 and canCont == true then
ely = ely - lMoveAmt
end
if key == "m" and ery <= 205 and ery >= 92 and canCont == true then
ery = ery - rMoveAmt
end
if key == "r" then
wnx = 900
lrx = 900
canCont = true
canMove = true
bonusly = 700
bonusry = 700
bly = 100
rly = 92
end
end
function love.draw()
love.graphics.draw(bg, 0, 0)
love.graphics.draw(eyel, elx, ely)
love.graphics.draw(eyer, erx, ery)
love.graphics.draw(bOne, 100, bonusly)
love.graphics.draw(bOne, 600, bonusry)
love.graphics.draw(wnr, wnx, 15)
love.graphics.draw(lsr, lrx, 15)
end