L Shape and basic rotation
This commit is contained in:
parent
8c8d64486b
commit
d18fec84bf
@ -7,3 +7,5 @@
|
|||||||
[node name="Sprite" type="Sprite" parent="."]
|
[node name="Sprite" type="Sprite" parent="."]
|
||||||
scale = Vector2( 0.125, 0.125 )
|
scale = Vector2( 0.125, 0.125 )
|
||||||
texture = ExtResource( 1 )
|
texture = ExtResource( 1 )
|
||||||
|
|
||||||
|
[node name="AdjacentRays" type="Sprite" parent="."]
|
||||||
|
10
GameBoard.gd
10
GameBoard.gd
@ -13,7 +13,7 @@ func _ready():
|
|||||||
|
|
||||||
func get_random_shape():
|
func get_random_shape():
|
||||||
# TODO: Make random
|
# TODO: Make random
|
||||||
var new_shape = preload("res://ShapeSquare.tscn").instance()
|
var new_shape = preload("res://ShapeL.tscn").instance()
|
||||||
add_child(new_shape)
|
add_child(new_shape)
|
||||||
return new_shape
|
return new_shape
|
||||||
|
|
||||||
@ -52,7 +52,7 @@ func check_for_full_line():
|
|||||||
for line_block in $StaticBlocks.get_children():
|
for line_block in $StaticBlocks.get_children():
|
||||||
if line_block.position.y == line_count_y:
|
if line_block.position.y == line_count_y:
|
||||||
line_block.free()
|
line_block.free()
|
||||||
elif line_block.position.y > line_count_y:
|
elif line_block.position.y < line_count_y:
|
||||||
# Move higher-up blocks down
|
# Move higher-up blocks down
|
||||||
line_block.position.y += RASTER_SIZE
|
line_block.position.y += RASTER_SIZE
|
||||||
|
|
||||||
@ -67,6 +67,10 @@ func move_right():
|
|||||||
active_shape.position.x += RASTER_SIZE
|
active_shape.position.x += RASTER_SIZE
|
||||||
|
|
||||||
|
|
||||||
|
func rotate_shape():
|
||||||
|
active_shape.rotation_degrees += 90
|
||||||
|
|
||||||
|
|
||||||
func drop():
|
func drop():
|
||||||
active_shape.position.y = BOTTOM
|
active_shape.position.y = BOTTOM
|
||||||
|
|
||||||
@ -80,6 +84,6 @@ func _input(event):
|
|||||||
elif event.is_action_pressed("move_right"):
|
elif event.is_action_pressed("move_right"):
|
||||||
move_right()
|
move_right()
|
||||||
elif event.is_action_pressed("rotate"):
|
elif event.is_action_pressed("rotate"):
|
||||||
pass
|
rotate_shape()
|
||||||
elif event.is_action_pressed("drop"):
|
elif event.is_action_pressed("drop"):
|
||||||
drop()
|
drop()
|
||||||
|
19
ShapeL.tscn
Normal file
19
ShapeL.tscn
Normal file
@ -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 )
|
Loading…
x
Reference in New Issue
Block a user