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
5
main.go
5
main.go
|
|
@ -22,6 +22,7 @@ var (
|
||||||
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() {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue