Fonts and Menu

Added a font library and four fonts
Added Scene configuration
Added a Menu scene
Added intro text to menu (+ FADE!!!!!!)
This commit is contained in:
Zaponium 2023-08-31 20:48:42 +02:00
commit f68115733e
11 changed files with 106 additions and 34 deletions

View file

@ -9,7 +9,10 @@ check_space = {}
function love.load()
math.randomseed(os.time())
physics = require('physics')
Scene = "menu"
physics_ini = require('physics')
menu_ini = require('menu')
menu.load()
window = {}
NPCs = {}
window.x, window.y = love.window.getDesktopDimensions()
@ -31,35 +34,43 @@ function love.load()
end
function love.update(dt)
input(player, dt)
gravity(player, dt)
mouvement(player, dt)
for i = 1, #NPCs do
gravity(NPCs[i], dt)
wander(NPCs[i], dt)
mouvement(NPCs[i], dt)
if NPCs[i].bools.isInteracting then
sayHello(NPCs[i], dt)
if Scene == "gameTest" then
input(player, dt)
gravity(player, dt)
mouvement(player, dt)
for i = 1, #NPCs do
gravity(NPCs[i], dt)
wander(NPCs[i], dt)
mouvement(NPCs[i], dt)
if NPCs[i].bools.isInteracting then
sayHello(NPCs[i], dt)
end
end
elseif Scene == "menu" then
menu.update(dt)
end
end
function love.draw()
love.graphics.rectangle("line", player.x, player.y, player.width, player.height)
if player.bools.isFacingRight then
love.graphics.rectangle("line", player.x+10, player.y-20, 20, 20)
else
love.graphics.rectangle("line", player.x-10, player.y-20, 20, 20)
end
for i = 1, #NPCs do
love.graphics.rectangle("fill", NPCs[i].x, NPCs[i].y, NPCs[i].width, NPCs[i].height)
end
for i = 1, #NPCs do
if NPCs[i].bools.isInteracting then
local font = love.graphics.getFont()
local helloText = love.graphics.newText(font, "Hello there")
love.graphics.draw(helloText, NPCs[i].x, NPCs[i].y-10)
if Scene == "gameTest" then
love.graphics.rectangle("line", player.x, player.y, player.width, player.height)
if player.bools.isFacingRight then
love.graphics.rectangle("line", player.x+10, player.y-20, 20, 20)
else
love.graphics.rectangle("line", player.x-10, player.y-20, 20, 20)
end
for i = 1, #NPCs do
love.graphics.rectangle("fill", NPCs[i].x, NPCs[i].y, NPCs[i].width, NPCs[i].height)
end
for i = 1, #NPCs do
if NPCs[i].bools.isInteracting then
local font = love.graphics.getFont()
local helloText = love.graphics.newText(font, "Hello there")
love.graphics.draw(helloText, NPCs[i].x, NPCs[i].y-10)
end
end
elseif Scene == "menu" then
menu.draw()
end
end
@ -104,16 +115,22 @@ function love.mousemoved(x, y)
end
function love.keypressed(key)
if key == keybind.jump then player.physics.velocityY = player.physics.velocityY - 3 end
if key == keybind.interact then
check_space.interactables(player.x, player.y)
end
if key == keybind.create then
NPCs[#NPCs+1] = character.create({"attributes", "functions","bools","physics"}, false)
NPCs[#NPCs].x = math.random(0, window.x-20)
NPCs[#NPCs].y = window.y/2-window.y/20
NPCs[#NPCs].width = 20
NPCs[#NPCs].height = 80
if Scene == "gameTest" then
if key == keybind.jump then player.physics.velocityY = player.physics.velocityY - 3 end
if key == keybind.interact then
check_space.interactables(player.x, player.y)
end
if key == keybind.create then
NPCs[#NPCs+1] = character.create({"attributes", "functions","bools","physics"}, false)
NPCs[#NPCs].x = math.random(0, window.x-20)
NPCs[#NPCs].y = window.y/2-window.y/20
NPCs[#NPCs].width = 20
NPCs[#NPCs].height = 80
end
else
if key == keybind.jump then
titleCard.duration = true
end
end
end