feat: add game/block.go
This type represents a single block in a grid.
This commit is contained in:
parent
93a660e8d3
commit
6e21b1fcb2
1 changed files with 30 additions and 0 deletions
30
game/block.go
Normal file
30
game/block.go
Normal file
|
|
@ -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),
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue