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