Code: Select all
local game = {}
local gravity = 100
local score = 0
function game:load()
arrow = {
Arrowx = 380,
Arrowy = 490,
arrow1 = love.graphics.newImage("assets\arrow.png")
}
--enemy = {}
love.graphics.setBackgroundColor(0, 0, 0)
love.graphics.setDefaultFilter("nearest", "nearest")
enemyx = love.math.random(0, 770)--mettere sempre 770
enemyy = 60 --mettere sempre 60
enemy.sprite = love.graphics.newImage('assets/blocktest.png')
end
function game:update(dt)
if love.keyboard.isDown("d") then
arrowx = arrowx + 10
end
if love.keyboard.isDown("a") then
arrowx = arrowx - 10
end
end
function game:draw()
love.graphics.setLineWidth(5)
love.graphics.line(0, 540, 800, 540)
love.graphics.line(0, 480, 800, 480)
--love.graphics.polygon("fill", 400, 540, 410, 520, 390, 520)
love.graphics.draw(arrow.arrow1, arrow.Arrowx, arrow.Arrowy, 0, 2.5, 2.5)
--love.graphics.draw(enemy, enemyx, enemyy, 0, 1, 1)
-- love.graphics.print(score, 0, 80)
end
return game
Code: Select all
local menu = {}
local font = love.graphics.newFont("assets/PressStart2P-Regular.ttf", 50)
local Delta = "ΔDelta"
local Start = "Start"
local Exit = "Exit"
local Game = require("game")
function menu.draw()
love.graphics.setFont(font)
love.graphics.print(Delta, 0, 300)
love.graphics.print(Start, 0, 400)
love.graphics.print(Exit, 0, 500)
end
function menu.keyreleased(key)
if key == "w" then
Start = "• Start"
Exit = "Exit"
end
if key == "s" then
Exit = "• Exit"
Start = "Start"
end
if key == "return" then
if Start == "• Start" then
function love.load()
Game.load()
end
function love.draw()
Game.draw()
end
end
if Exit == "• Exit" then
love.event.quit()
end
end
end
return menu
Code: Select all
function love.load()
Menu = require("menu")
Game = require("game")
end
function love.draw()
Menu.draw()
end
function love.keyreleased(key)
Menu.keyreleased(key)
end
