1
0
Fork 0

feat: use ShapeQueue to implement shape RNG

This commit is contained in:
Henrik Hautakoski 2025-09-17 06:39:02 +02:00
parent 5c4503268f
commit d6c9389e60

19
main.go
View file

@ -15,13 +15,14 @@ import (
)
var (
shape game.Shape
shape_pos core.Vec2i8
score game.Score
dropTimer = core.NewIntervalTimer(0.3)
moveTimer = core.NewIntervalTimer(0.1)
grid = game.Grid{}
nextShape = game.NewShape(game.SHAPE_O)
shape game.Shape
shape_pos core.Vec2i8
score game.Score
dropTimer = core.NewIntervalTimer(0.3)
moveTimer = core.NewIntervalTimer(0.1)
grid = game.Grid{}
nextShape = game.NewShape(game.SHAPE_O)
shapeQueue = game.NewShapeQueue()
r = draw.Renderer{
Theme: &draw.Theme{
@ -36,8 +37,8 @@ var (
func SpawnShape() {
shape = nextShape
nextShape = shapeQueue.Next()
shape_pos = core.Vec2i8{X: 4, Y: 0}
nextShape = game.NewShape((nextShape.Type() + 1) % 7)
}
func LockShape() {
@ -123,6 +124,8 @@ func main() {
render.SetTexture(texture)
render.SetFont(&assets.Font)
nextShape = shapeQueue.Next()
SpawnShape()
for !rl.WindowShouldClose() {