Help us measure site usage?

With your permission, we use self-hosted analytics to understand page usage. It is optional and does not affect the Service. Learn more.

LuaintermediatecliAI generated

LOVE2D Puzzle Game with Level Editor

Build a sliding-block puzzle game with LÖVE (LOVE2D), a free framework for making 2D games in Lua. The player pushes blocks around a grid to get each one onto its target, like the classic Sokoban. The game comes with a built-in level editor: press a key to switch to editing, place walls, blocks, targets and the player with the mouse, then save the level as a JSON file and play it straight away. A menu lists every level in the levels folder. You'll learn the game loop (load, update, draw), handling keyboard and mouse input, drawing a tile grid, game rules and undo, and saving and loading structured data as JSON.

Estimate
~9.5h
Steps
6
Completed by
0
Proposed by
codeseed.app

LOVE2D · JSON

Project roadmap

  1. 01

    Set up the game and draw the grid

    ~1.5h

    Install LÖVE and create main.lua with love.load, love.update and love.draw. Represent a level as a 2D table of tiles (floor, wall and target) plus the positions of blocks and the player, and draw it with love.graphics.rectangle using a different color per tile. Hard-code one small level to start. Done when: running love . shows the level on screen.

  2. 02

    Add the puzzle rules

    ~2h

    Handle the arrow keys in love.keypressed: the player moves one tile unless there's a wall; walking into a block pushes it if the tile behind it is free (not a wall or another block). The level is won when every block is on a target. Count moves, add U to undo the last move (keep a history of states) and R to restart. Done when: the level can be played and won, and undo works.

  3. 03

    Build the level editor

    ~2h

    Press E to switch between playing and editing. In the editor, choose a tool with the number keys (wall, floor, target, block, player) and click or drag with the mouse to place it, converting mouse positions to grid cells. Show the selected tool on screen. Allow only one player. Done when: you can build a new level from scratch with the mouse and switch to play it.

  4. 04

    Save and load levels as JSON

    ~1.5h

    Add a JSON library (such as rxi's json.lua, a single file). Save the level (size, tiles, blocks, targets and player) with love.filesystem.write, and load it with love.filesystem.read. Check a level before saving and when loading: exactly one player, at least one block, and as many targets as blocks, showing an error message when it's wrong. Done when: a saved level loads back exactly the same after restarting the game.

  5. 05

    Add a level menu

    ~1.5h

    Build a menu screen that lists the levels in the levels folder (love.filesystem.getDirectoryItems), sorted by name, with the arrow keys to choose and Enter to play. Show a win screen with the move count and a key to go to the next level. Remember completed levels in a save file and mark them in the menu. Done when: you can pick any level, play it, and move to the next one.

  6. 06

    Test the rules

    ~1h

    Move the rules into a module that doesn't use love, so they can be tested with plain Lua or busted: moving into walls, pushing blocks, not pushing two blocks at once, the win check, undo, and level validation. Done when: the tests pass.

Ready to build this?

Get a GitHub repo and start building. Your AI reviewer checks each step as you go.

~9.5h · 6 steps

Tech stack

LOVE2DJSON