From d18fec84bff09e791ce50f3ae64990788d2f60ab Mon Sep 17 00:00:00 2001 From: karl Date: Wed, 17 Nov 2021 17:52:33 +0100 Subject: [PATCH] L Shape and basic rotation --- Block.tscn | 2 ++ GameBoard.gd | 10 +++++++--- ShapeL.tscn | 19 +++++++++++++++++++ 3 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 ShapeL.tscn diff --git a/Block.tscn b/Block.tscn index 31ba5b1..858d3ce 100644 --- a/Block.tscn +++ b/Block.tscn @@ -7,3 +7,5 @@ [node name="Sprite" type="Sprite" parent="."] scale = Vector2( 0.125, 0.125 ) texture = ExtResource( 1 ) + +[node name="AdjacentRays" type="Sprite" parent="."] diff --git a/GameBoard.gd b/GameBoard.gd index ca08acf..1050e84 100644 --- a/GameBoard.gd +++ b/GameBoard.gd @@ -13,7 +13,7 @@ func _ready(): func get_random_shape(): # TODO: Make random - var new_shape = preload("res://ShapeSquare.tscn").instance() + var new_shape = preload("res://ShapeL.tscn").instance() add_child(new_shape) return new_shape @@ -52,7 +52,7 @@ func check_for_full_line(): for line_block in $StaticBlocks.get_children(): if line_block.position.y == line_count_y: line_block.free() - elif line_block.position.y > line_count_y: + elif line_block.position.y < line_count_y: # Move higher-up blocks down line_block.position.y += RASTER_SIZE @@ -67,6 +67,10 @@ func move_right(): active_shape.position.x += RASTER_SIZE +func rotate_shape(): + active_shape.rotation_degrees += 90 + + func drop(): active_shape.position.y = BOTTOM @@ -80,6 +84,6 @@ func _input(event): elif event.is_action_pressed("move_right"): move_right() elif event.is_action_pressed("rotate"): - pass + rotate_shape() elif event.is_action_pressed("drop"): drop() diff --git a/ShapeL.tscn b/ShapeL.tscn new file mode 100644 index 0000000..a13b719 --- /dev/null +++ b/ShapeL.tscn @@ -0,0 +1,19 @@ +[gd_scene load_steps=3 format=2] + +[ext_resource path="res://Block.tscn" type="PackedScene" id=1] +[ext_resource path="res://TetrisShape.gd" type="Script" id=2] + +[node name="ShapeL" type="Node2D"] +script = ExtResource( 2 ) + +[node name="Block" parent="." instance=ExtResource( 1 )] +position = Vector2( -32, 32 ) + +[node name="Block3" parent="." instance=ExtResource( 1 )] +position = Vector2( -32, -32 ) + +[node name="Block4" parent="." instance=ExtResource( 1 )] +position = Vector2( -32, -96 ) + +[node name="Block2" parent="." instance=ExtResource( 1 )] +position = Vector2( 32, 32 )