Löve est un cadriciel puissant pour programmer des jeux en Lua.
Astuces
Il est possible d'y interfacer Nuklear, mais cela ne rendra pas le sytème très portable. Malgré tout, pour une application locale cela peut aller.
LoveNuklear
Pour une interface plus simple, SUIT sera adapté, le système est un peu vieux mais fonctionne toujours dans la dernière version de Löve 11.4
Fork de Suit, en un seul fichier.
Il est ensuite possible de créer une version pour le WEB avec l'outil LoveWebBuilder
LoveWebBuilder
Attention, Löve utilisant LuaJIT, qui prend la syntaxe de Lua 5.1, certains ajouts dans Lua 5.3 et 5.4 ne seront pas compatibles.
Liens
Love2d
Exemples
Exemple de création d'un programme "compteur", avec l'interface en Suit.
Fonctionne également sous Android.
sudo apt install love
git clone https://github.com/HTV04/suit-compact.git
cd suit-compact
echo "
-- suit up
local suit = require 'suit'
myCount = 0
myScore = 0
function love.load()
love.graphics.setBackgroundColor(0.8,0.7,0.6,1)
suit.theme.color.normal.fg = {0.25,0.28,0.2}
suit.theme.color.normal.bg = {0.9,0.85,0.75}
suit.theme.color.hovered = {bg = {0.975,0.96,0.70}, fg = {0.2,0.1,0.2}}
suit.theme.color.active = {bg = {0.63,0.57,0.49}, fg = {0.9,0.9,0.9}}
end
-- all the UI is defined in love.update or functions that are called from here
function love.update(dt)
-- put the layout origin at position (100,300)
-- the layout will grow down and to the right from this point
suit.layout:reset(100,300)
local font = love.graphics.newFont(22)
love.graphics.setFont(font)
-- put a button of size 40x40 px in the cell below
-- if the button is pressed, quit the game
if suit.Button('x', 285,20,40,40).hit then
love.event.quit()
end
-- adding more buttons to the sample
if suit.Button('Count', 15, 280, 100, 40).hit then
myScore = myScore + 1
myCount = myCount + 1
end
if suit.Button('Miss', 120, 280, 100, 40).hit then
myCount = myCount + 1
end
if suit.Button('Reset', 225, 280, 100, 40).hit then
myScore = 0
myCount = 0
end
end
function love.draw()
-- draw the SUIT gui
suit.draw()
-- draw the counter
local font = love.graphics.newFont(40)
love.graphics.setFont(font)
love.graphics.print('Counter', 10, 10)
love.graphics.print(myScore, 110, 150)
love.graphics.print(' / ', 170, 150)
love.graphics.print(myCount, 215, 150)
end
function love.keypressed(key)
-- forward keypresses to SUIT
suit.keypressed(key)
end
" > main.lua
echo "function love.conf(t)
t.window.width = 400
t.window.height = 800
t.window.title = 'Counter demo'
--t.window.icon = 'love_icon.png'
end
" > conf.lua
love ./
#informatique
index.gmi