From 6e21b1fcb2cd0f6554e5af3b52222f31c461915c Mon Sep 17 00:00:00 2001 From: Henrik Hautakoski Date: Sun, 14 Sep 2025 09:24:54 +0200 Subject: [PATCH] feat: add game/block.go This type represents a single block in a grid. --- game/block.go | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 game/block.go diff --git a/game/block.go b/game/block.go new file mode 100644 index 0000000..0221d49 --- /dev/null +++ b/game/block.go @@ -0,0 +1,30 @@ +package game + +import ( + "tetris/assets" + "tetris/engine/graphics" +) + +type Block byte + +const ( + BLOCK_EMPTY Block = iota + BLOCK_RED + BLOCK_GREEN + BLOCK_BLUE + BLOCK_YELLOW + BLOCK_ORANGE + BLOCK_MAGENTA + BLOCK_TEAL +) + +func (c Block) Tile() graphics.Tile { + if c >= 8 { + c = BLOCK_EMPTY + } + return graphics.Tile{ + Size: assets.BLOCK_TILE_SIZE, + X: byte(c), + Y: byte(0), + } +}