Mode:
Duration:
1
Coding works best on desktop or with an external keyboard.
Coding works best on desktop or with an external keyboard.
Player collects items to increase score.
-- main.lua
local player = {x=200, y=200}
local items = {{x=400, y=200}, {x=500, y=300}}
local score = 0
function love.update(dt)
for i=#items,1,-1 do
local item = items[i]
if math.abs(player.x - item.x) < 25 and math.abs(player.y - item.y) < 25 then
table.remove(items, i)
score = score + 10
end
end
end
function love.draw()
love.graphics.rectangle("fill", player.x, player.y, 50, 50)
for _, item in ipairs(items) do
love.graphics.circle("fill", item.x, item.y, 20)
end
love.graphics.print("Score: " .. score, 100, 50)
endLOVE2D (LÖVE) is a free, open-source framework for 2D game development using Lua, focusing on simplicity, rapid prototyping, and cross-platform desktop and mobile deployment.
Origin & Creator
LOVE2D was created by Rafael 'Hoelzro' Lima in 2006, designed to make 2D game development accessible, fast, and flexible with Lua scripting.
Industrial Note
LOVE2D is widely used in indie game jams, rapid prototyping, educational coding projects, and hobbyist 2D game development due to its simplicity and lightweight framework.