feat(draw): add DrawShape()
This commit is contained in:
parent
4dd6d93653
commit
02157a12ea
1 changed files with 23 additions and 0 deletions
23
game/draw/shape.go
Normal file
23
game/draw/shape.go
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
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) {
|
||||
tile := shape.Tile()
|
||||
|
||||
for _, coord := range shape.Coordinates() {
|
||||
block := pos.Add(coord)
|
||||
grid.DrawBlock(offset, byte(block.X), byte(block.Y), tile)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue