1
0
Fork 0

feat(draw): add grid.DrawBlock()

This commit is contained in:
Henrik Hautakoski 2025-09-14 21:48:30 +02:00
parent 656487903e
commit 4dd6d93653

View file

@ -32,23 +32,21 @@ func DrawBackground(pos rl.Vector2, grid Grid, col color.RGBA, border_size int32
}, col, border_size, border_col) }, col, border_size, border_col)
} }
func Draw(pos rl.Vector2, grid Grid) { func DrawBlock(pos rl.Vector2, x, y byte, tile graphics.Tile) {
// offset for background. dest := rl.Rectangle{
pos.X = pos.X + CELL_SPACING X: float32(int32(pos.X) + (int32(x) * (CELL_SIZE + CELL_SPACING)) + CELL_SPACING),
pos.Y = pos.Y + CELL_SPACING Y: float32(int32(pos.Y) + (int32(y) * (CELL_SIZE + CELL_SPACING)) + CELL_SPACING),
cell := rl.Rectangle{
X: 0,
Y: 0,
Width: float32(CELL_SIZE), Width: float32(CELL_SIZE),
Height: float32(CELL_SIZE), Height: float32(CELL_SIZE),
} }
for y := range grid.Height() { render.DrawTextureRec(tile.GetTexRect(), dest)
for x := range grid.Width() { }
cell.X = float32(int32(pos.X) + (x * (CELL_SIZE + CELL_SPACING)))
cell.Y = float32(int32(pos.Y) + (y * (CELL_SIZE + CELL_SPACING))) func Draw(pos rl.Vector2, grid Grid) {
render.DrawTextureRec(grid.Tile(byte(x), byte(y)).GetTexRect(), cell) for y := range byte(grid.Height()) {
for x := range byte(grid.Width()) {
DrawBlock(pos, x, y, grid.Tile(x, y))
} }
} }
} }