feat: implement shape drop
This commit is contained in:
parent
ffbf1332c5
commit
ab69d501b9
1 changed files with 7 additions and 18 deletions
25
main.go
25
main.go
|
|
@ -13,26 +13,11 @@ import (
|
||||||
rl "github.com/gen2brain/raylib-go/raylib"
|
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() {
|
func main() {
|
||||||
shape := game.NewShape(game.SHAPE_O)
|
shape := game.NewShape(game.SHAPE_O)
|
||||||
shape_pos := core.Vec2i8{X: 1, Y: 13}
|
shape_pos := core.Vec2i8{X: 4, Y: 0}
|
||||||
grid := createGrid()
|
dropTimer := core.NewIntervalTimer(0.3)
|
||||||
|
grid := game.Grid{}
|
||||||
|
|
||||||
// Set random blocks to test
|
// Set random blocks to test
|
||||||
render.Init(render.Config{
|
render.Init(render.Config{
|
||||||
|
|
@ -62,6 +47,10 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
for !rl.WindowShouldClose() {
|
for !rl.WindowShouldClose() {
|
||||||
|
if dropTimer.UpdateReset(rl.GetFrameTime()) {
|
||||||
|
shape_pos.Y += 1
|
||||||
|
}
|
||||||
|
|
||||||
render.Begin(r.Theme.GridBackground)
|
render.Begin(r.Theme.GridBackground)
|
||||||
r.DrawGrid(rl.NewVector2(25, 25), grid)
|
r.DrawGrid(rl.NewVector2(25, 25), grid)
|
||||||
draw.DrawShape(rl.NewVector2(25, 25), shape_pos, shape)
|
draw.DrawShape(rl.NewVector2(25, 25), shape_pos, shape)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue