feat: use ShapeQueue to implement shape RNG
This commit is contained in:
parent
5c4503268f
commit
d6c9389e60
1 changed files with 11 additions and 8 deletions
19
main.go
19
main.go
|
|
@ -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() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue