Professional Documents
Culture Documents
Code
Code
WINDOW_WIDTH = 1280
WINDOW_HEIGHT = 720
VIRTUAL_WIDTH = 512
VIRTUAL_HEIGHT = 288
function love.load( )
push:setupScreen(VIRTUAL_WIDTH, VIRTUAL_HEIGHT, WINDOW_WIDTH, WINDOW_HEIGHT, {
vysnc = true,
resizable = true,
fullscren = false
})
randOne = love.math.random(1,50)
randTwo = love.math.random(1,50)
randThree = love.math.random(1,50)
randFour = love.math.random(1,50)
end
function love.keypressed(key)
if gameState == 'menu' then
if key == "1" then
selectedNumber = tonumber(randOne)
invalidEntry = false
gameState = "list"
else
invalidEntry = true
end
else
gameState = 'menu'
end
end
function fibonacci(n)
a = 0
b = 1
for i = 1, n do
a, b = b, a + b
end
return a
end
function love.draw( )
push:start()
if gameState == 'menu' then
love.graphics.setFont(largeFont)
love.graphics.print('SELECT ITEM', 20, 20)
love.graphics.print('1. ' .. randOne, 20, 44)
love.graphics.print('2. ' .. randTwo, 20, 68)
love.graphics.print('3. ' .. randThree, 20, 92)
love.graphics.print('4. ' .. randFour, 20, 116)
if invalidEntry then
love.graphics.print('Invalid Selection.', 20, 140)
end
else
love.graphics.setFont(smallFont)
love.graphics.print('The Fibonacci number for memeber number ' ..
selectedNumber .. ' is ' .. fibonacci(selectedNumber) , 20, 140)