Tag: GDScript 2.0
-
Tetris Extras 01 – GameOver tweak
We will be updating our GameOver routine as follows. Let’s begin with blurring the ‘GameRoot’. Open ‘main.tscn’. Select ‘UILayer’. Set ‘Layer’ -> ‘Layer’ = 1. Select ‘UIRoot’. Add a ColorRect node. Rename it to ‘BlurOverlay’. With ‘BlurOverlay’ selected, set the following properties. Our ‘Main’ scene now looks like this. Save ‘main.tscn’. Now we add a…
-
Tetris 10 – Game Over script
Open the ‘game_over.tscn’ scene. Select the ‘GameOver’ node. Attach a script. Save the script as ‘game_over.gd’. Introduction
-
Tetris 06 – Game Over scene
Create a new scene of type ‘Control’. Rename the ‘Control’ node to ‘GameOver’. Save the scene as ‘game_over.tscn’. Set Layout to ‘Full Rect’. Add a Control -> CenterContainer node to ‘GameOver’. Select the ‘CenterContainer’. Set Layout to ‘Full Rect’. Add a Control -> Panel node to ‘CenterContainer’. Select the ‘Panel’ node. Set Layout to ‘Full…
-
Tetris 11 – Test run
Before we do a test run, we have to set the ‘Main Scene’ in ‘Project Settings’. Now that we have set the ‘Main Scene’, then whenever we click the ‘Run Project’, the ‘main.tscn’ will be the master. Introduction
-
Tetris 09 – NextPreview script
Open the ‘next_preview.gd’ script. We start by adding constants right after the ‘extends Node2D’ line. And then we add the ‘func update_preview()’ function. Now we need a function to show the next shape – ‘func _draw()’. This concludes the ‘next_preview.gd’ script. Save it. Introduction
-
Tetris 08 – Main script
Open the ‘main.gd’ script. We start by adding constants right after the ‘extends Node2D’ line. And then we add the ‘func _ready()’ and ‘_on_viewport_size_changed()’ functions. Now we add a function ‘func _on_lines_cleared()’ to update over scores. We add a function to get layout bounds ‘func _get_layout_bounds()’. We add a function to change next_preview – ‘func…
-
Tetris 07 – Board script
Open the ‘board.gd’ script. We start by adding constants right after the ‘extends Node2D’ line. Add a reset game function ‘func reset_game()’. Now we initialize the board. Add ‘func _ready()’ as follows. Now we add the new functions, starting with ‘func _init_grid()’. Spawning pieces and next preview. Next piece. Movement & rotation. Now add the…
-
Tetris 05 – HUDRight scene
Create a new scene with type ‘Control’. Rename the ‘Control’ to ‘HUDRight’. Add a ‘VBoxContainer’ to ‘HUDRight’. Now add the following controls to the ‘VBoxContainer’ Layout Select the ‘HUDRight’ Node and set the layout to ‘Top Left’: Save the scene as ‘hud_right.tscn’ Attach a script to the ‘NextPreview’ node and save it as ‘next_preview.gd’ Open…
-
Tetris 04 – HUDLeft scene
Create a new scene of type ‘Control’. Rename the ‘Control’ node to ‘HUDLeft’. Add a ‘VBoxContainer’ to ‘HUDLeft’. Now add the following controls to the ‘VBoxContainer’ Layout Select the ‘HUDLeft’ node and set the layout to ‘Center Left’: Save the scene as ‘hud_left.tscn’ Open the ‘main.tscn’ scene. Right-click ‘GameRoot’ node and select ‘Instantiate Child Scene…’…