1
0
Fork 0
tetris-go/game/block.go

40 lines
518 B
Go

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
BLOCK_GHOST
)
func (c Block) Tile() graphics.Tile {
if c >= 9 {
c = BLOCK_EMPTY
}
if c == BLOCK_GHOST {
return graphics.Tile{
Size: assets.BLOCK_TILE_SIZE,
X: byte(7),
Y: byte(1),
}
}
return graphics.Tile{
Size: assets.BLOCK_TILE_SIZE,
X: byte(c),
Y: byte(0),
}
}