0 votes

I have created a 2D array using the following code in Godot 3

for x in range(width):
    var col = []
    col.resize(height)
    screen.append(col)

for x in range(width):
    for y in range(height):
        screen[x][y]= 1

Where screen is declared outside of this code.

Honestly not even sure if this works, but I would like to draw rectangles with the same sizes on to the screen using this matrix. The size would be depending on the viewport size(Ex: You would take the amount of rows in the 2D array and divide it by the viewport's height to get the size of the rectangles to display on screen)

in Engine by (23 points)

1 Answer

0 votes

My preferred way of going about this is to create a rectangle (tile?) scene with a sprite. That way it can also hold values like position in the grid or neighbouring rectangles.

You could even have the sprite be only one pixel, then set the scale to whatever width and height you want.

by (64 points)

Alright, thanks for your reply!

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.