fix: check bound before placing a block in LockShape()
This commit is contained in:
parent
dab2570b76
commit
ca6497d362
1 changed files with 4 additions and 0 deletions
4
main.go
4
main.go
|
|
@ -40,6 +40,10 @@ func SpawnShape() {
|
|||
func LockShape() {
|
||||
for _, block := range shape.Coordinates() {
|
||||
block = shape_pos.Add(block)
|
||||
// Check bounds
|
||||
if block.X < 0 || block.X > int8(grid.Width()) || block.Y < 0 || block.Y > int8(grid.Height()) {
|
||||
continue
|
||||
}
|
||||
grid.Set(byte(block.X), byte(block.Y), shape.GetBlock())
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue