1
0
Fork 0
tetris-go/game/draw/shape.go

25 lines
567 B
Go

package draw
import (
"tetris/engine/core"
"tetris/engine/graphics"
"tetris/game/draw/grid"
rl "github.com/gen2brain/raylib-go/raylib"
)
type Shape interface {
Tile() graphics.Tile
Coordinates() [4]core.Vec2i8
}
func DrawShape(offset rl.Vector2, pos core.Vec2i8, shape Shape) {
DrawShapeTile(offset, pos, shape, shape.Tile())
}
func DrawShapeTile(offset rl.Vector2, pos core.Vec2i8, shape Shape, tile graphics.Tile) {
for _, coord := range shape.Coordinates() {
block := pos.Add(coord)
grid.DrawBlock(offset, byte(block.X), byte(block.Y), tile)
}
}