1
0
Fork 0

feat: draw shape on grid.

This commit is contained in:
Henrik Hautakoski 2025-09-14 21:50:29 +02:00
parent 02157a12ea
commit 63a3662dbe

View file

@ -4,6 +4,7 @@ import (
"image/color"
"tetris/assets"
"tetris/engine/core"
"tetris/engine/graphics"
"tetris/engine/render"
"tetris/game"
@ -18,7 +19,7 @@ func createGrid() *game.Grid {
grid := &game.Grid{}
c := 0
for y := range byte(grid.Height() - 2) {
for y := range byte(grid.Height() - 4) {
for x := range byte(grid.Width()) {
grid.Set(x, y, game.Block((c%7)+1))
c++
@ -29,6 +30,8 @@ func createGrid() *game.Grid {
}
func main() {
shape := game.NewShape(game.SHAPE_O)
shape_pos := core.Vec2i8{X: 1, Y: 13}
grid := createGrid()
// Set random blocks to test
@ -61,6 +64,7 @@ func main() {
for !rl.WindowShouldClose() {
render.Begin(r.Theme.GridBackground)
r.DrawGrid(rl.NewVector2(25, 25), grid)
draw.DrawShape(rl.NewVector2(25, 25), shape_pos, shape)
r.DrawFrame(rl.RectangleInt32{X: 400, Y: 25, Width: 250, Height: 100})
r.DrawHeaderText(410, 30, "Score")
r.DrawText(410, 65, "999999")