1
0
Fork 0

feat: implement shape drop

This commit is contained in:
Henrik Hautakoski 2025-09-14 22:00:26 +02:00
parent ffbf1332c5
commit ab69d501b9

25
main.go
View file

@ -13,26 +13,11 @@ import (
rl "github.com/gen2brain/raylib-go/raylib"
)
// Create a grid with a block patter to test
// if all the blocks renders correctly
func createGrid() *game.Grid {
grid := &game.Grid{}
c := 0
for y := range byte(grid.Height() - 4) {
for x := range byte(grid.Width()) {
grid.Set(x, y, game.Block((c%7)+1))
c++
}
}
return grid
}
func main() {
shape := game.NewShape(game.SHAPE_O)
shape_pos := core.Vec2i8{X: 1, Y: 13}
grid := createGrid()
shape_pos := core.Vec2i8{X: 4, Y: 0}
dropTimer := core.NewIntervalTimer(0.3)
grid := game.Grid{}
// Set random blocks to test
render.Init(render.Config{
@ -62,6 +47,10 @@ func main() {
}
for !rl.WindowShouldClose() {
if dropTimer.UpdateReset(rl.GetFrameTime()) {
shape_pos.Y += 1
}
render.Begin(r.Theme.GridBackground)
r.DrawGrid(rl.NewVector2(25, 25), grid)
draw.DrawShape(rl.NewVector2(25, 25), shape_pos, shape)