Game Development with LÖVE
39.1 About LÖVE
LÖVE (love2d.org) is a free 2D game framework using LuaJIT. It provides graphics, audio, input, physics (Box2D), shaders (GLSL), filesystem, threads, and networking. Games like *Balatro* were built with it.
love mygame/ # run the folder containing main.lua39.2 A Minimal Game
-- main.lua
local player = {x = 400, y = 300, speed = 200, radius = 20}
local enemies = {}
local score, spawn_timer = 0, 0
function love.load()
love.window.setTitle("Dodge!")
love.graphics.setBackgroundColor(0.1, 0.1, 0.15)
math.randomseed(os.time())
end
function love.update(dt) -- dt: seconds since the last frame
if love.keyboard.isDown("left", "a") then player.x = player.x - player.speed * dt end
if love.keyboard.isDown("right", "d") then player.x = player.x + player.speed * dt end
if love.keyboard.isDown("up", "w") then player.y = player.y - player.speed * dt end
if love.keyboard.isDown("down", "s") then player.y = player.y + player.speed * dt end
spawn_timer = spawn_timer - dt
if spawn_timer <= 0 then
enemies[#enemies + 1] = {x = math.random(0, 800), y = -20, speed = math.random(100, 250)}
spawn_timer = 0.5
end
for i = #enemies, 1, -1 do
local e = enemies[i]
e.y = e.y + e.speed * dt
local dx, dy = e.x - player.x, e.y - player.y
if dx * dx + dy * dy < (player.radius + 10) ^ 2 then
score = 0; enemies = {}; break
elseif e.y > 620 then
…-- conf.lua
function love.conf(t)
t.window.width, t.window.height = 800, 600
t.version = "11.5"
end39.3 Game Development Concepts in Lua
The game loop (load/update/draw), delta time, sprite sheets and animation (anim8), tweening (flux, tween.lua), cameras (hump.camera, gamera), state machines / scene management (hump.gamestate), collision (bump.lua, Box2D via love.physics), entity-component systems (tiny-ecs, Concord), tilemaps (STI for Tiled maps), UI (SUIT), and serialization for save games (bitser, binser).
Packaging: a .love file (a zip of the game) fused with the LÖVE executable for distribution. Tools: makelove, love-release.