A small Snake game built with LÖVE (Love2D).
- Minimal grid-based Snake. The code uses a simple state stack for title, countdown, play, and score.
- LÖVE / Love2D installed (https://love2d.org).
From the repository root run:
love .- Enter: start / confirm
- Arrow keys: move the snake
- Escape: quit
- The project uses discrete update ticks to advance the snake on a grid (see
states/play.lua). - The play area is a
Room(grid). Food is placed on random free cells inside the room (elements/room.lua). - The
Snaketracks a list of body segments and a direction (elements/snake.lua). On each tick the head moves one cell; when eating food the snake grows by keeping the tail segment instead of removing it. - Collisions:
- Food: when the head reaches a food cell the score increases and a new food is spawned.
- Self: if the head collides with any body segment the play state ends and the score state is shown.
- Walls: head position is validated against the room bounds; leaving the bounds ends the game.
- Game flow is managed by states in
game.luaand files understates/.
- Fonts and sound effects are in the
assets/folder and referenced frommain.lua.
main.lua— entry point and LÖVE callbacksgame.lua— simple state stack / managerelements/snake.lua— snake movement, growth, and collision helperselements/room.lua— playfield grid and random cell placementelements/food.lua— food representationstates/title.lua,states/countdown.lua,states/play.lua,states/score.lua— UI and game states
That's all required to run and inspect the game logic.