Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- extends Node2D
- const MIN_WIDTH = 10
- func _ready():
- test([])
- test([2])
- test([2, 3])
- func get_grid(argv: Array):
- var width = argv.pop_front() # get null or value
- var height = argv.pop_front() # get null or value
- if width == null:
- width = MIN_WIDTH
- if height == null:
- height = width
- var grid = []
- grid.resize(height)
- var row = []
- row.resize(width)
- row = PoolIntArray(row) # Generate a row of integer zeros
- for n in height:
- grid[n] = Array(row) # Cast to array
- return grid
- func test(argv):
- var grid = get_grid(argv)
- print("size: ", Vector2(grid.size(), grid[0][0].size()))
- print("row: ", grid[0][0])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement