1
0
Fork 0
A small, self‑contained Tetris clone written in Go using raylib‑go.
Find a file
2025-10-28 06:38:56 +01:00
assets feat(assets): adding logo data 2025-10-06 18:47:27 +02:00
engine feat(audio): add SetVolume() and Volume() 2025-10-28 06:38:56 +01:00
game feat(ui): call onSelect in Select() function and make Next()/Previous() use that function 2025-10-28 06:38:55 +01:00
.editorconfig chore: add editorconfig 2025-09-25 21:57:52 +02:00
.gitignore chore: fix build for windows 2025-09-24 20:13:56 +02:00
CHANGELOG.md v1.0 2025-10-28 06:38:55 +01:00
go.mod chore: update go.mod 2025-09-15 06:49:06 +02:00
go.sum Initial commit 2025-09-14 22:16:29 +02:00
LICENSE chore: update readme and add license 2025-10-08 09:57:52 +02:00
Makefile chore(makefile): add .PHONY target again 2025-09-24 20:15:58 +02:00
README.md feat: add line clear animation 2025-10-28 06:38:55 +01:00
tetris.go feat: dont close application when user presses Esc key 2025-10-28 06:38:56 +01:00

Tetris (Go + Raylib)

A small, selfcontained Tetris clone written in Go using raylibgo. It features classic gameplay (movement, rotation, line clearing, scoring), a simple menu and gameover flow, pixelart tiles, and embedded audio — all shipped as a single binary via go:embed.

Features

  • Classic Tetris gameplay with 7 tetrominoes
  • Next piece preview and line clearing with scoring
  • Keyboard controls for movement, rotation, and soft drop
  • Simple menu and gameover screens via a tiny state machine
  • Embedded sprites, icon, SFX, and background music (no external files at runtime)

Controls

  • Left / Right: Move piece
  • Up: Rotate clockwise
  • Down (hold): Soft drop (faster fall)
  • Enter: Select in menu, restart from game over
  • Q: Return to menu from game over

Scoring

Points are awarded per simultaneous line clear using: score = L^2 * 100 where L is the number of lines cleared at once.

  • 1 line → 100
  • 2 lines → 400
  • 3 lines → 900
  • 4 lines → 1600

Build and Run

Prerequisites:

  • Go (as indicated in go.mod)
  • A working C toolchain (required by raylibgo). On Linux you may need basic X11/ALSA dev packages.

Build

Using make

make

Using go directly:

go build tetris.go

Run

./tetris

Project Structure

  • tetris.go: Program entrypoint; initializes window, renderer, audio, and the state machine.
  • assets/: Embedded resources (sprites, icon, SFX, music) and a compact tilefont mapping.
  • engine/: Lightweight helpers for audio, graphics, font/tile rendering, timing, and render context.
  • game/: Core gameplay (grid, shapes, collision, scoring) and state handlers for menu, gameplay, and gameover.

Roadmap

  • Line clear animations
  • Hard drop and ghost piece
  • Level/speed progression and pause
  • High score persistence
  • Custom key bindings