I am currently trying to make my own version of famous games and also programming simple games (like one that imitates the Linux terminal and you play using commands).
Now I'm trying the most classic game I know; Tetris.
For that I'm using 8x8 graphics, in a window of 120x240 pixels, with a play field of 104 pixels wide. All of this is divided in 8x8 squares, so the whole window is 15x30 squares.
I need to make the squares the tetrominos are made of appear and reappear in these sectors.
The problem is I don't know how to make the squares appear and dissapear.
I have three ways in mind;
1.- Instead of making the squares appear and form the tetrominos, I just make png files of each tetromino, place a bunch of them otside the window where no player can see them and move them instead of drawing new ones. MEDIOCRE
2.- I place one square of every colour in every sector of the play field and make them visible and invisible depending on the value of a 2D array that represents it. Example; number 0 means all invisible, number 1 means red visible only....
3.- This is the one I actually want to do; have only the squares I need, no invisibility allowed. So it means I need to draw them dinamically.
For this I first tried using the main node (the one that gives it's name to the scene) to draw a square at the beggining of the game in the middle of the play field using
var greensq = preload("res://greensq.png")
and in the ready function
draw_texture(greensq, Vector2(32, 32))
Of course this didn't work so I created a Node2D and used the exact same code, but didn't work. Then I realised and moved the draw texture function to the draw() function.
It didn't work either so I browsed the internet for a while and tried
var sprgreensq = Sprite.new()
sprgreensq.set_texture(greensq)
sprgreensq.set_position(Vector2(32,32))
In the draw function too, but it didn't work. I made sure to move this node to the top so it isn't covered by any other nodes (I placed some decorative pngs and a background).
Then I tried making all of those other nodes invisible but it didn't work either.
So I need any way of making the graphics of a tetris game to work.
Now I had diner, and I'm going to study calculus for a couple of hours before going to sleep so I will answer your replies tomorrow after class ( it is 22:24 now, so I'll answer in anywhere from 17 hours to 25 hours).
Thank you in advance for your help!