Some cleanup and safe area implementation
This commit is contained in:
parent
7de25e7c21
commit
1e54f7bb52
14
GameBoard.gd
14
GameBoard.gd
@ -5,13 +5,13 @@ signal score_changed(new_score)
|
|||||||
signal new_next_shape(next_shape_scene)
|
signal new_next_shape(next_shape_scene)
|
||||||
|
|
||||||
var shapes = [
|
var shapes = [
|
||||||
preload("res://ShapeI.tscn"),
|
preload("res://Shapes/ShapeI.tscn"),
|
||||||
preload("res://ShapeJ.tscn"),
|
preload("res://Shapes/ShapeJ.tscn"),
|
||||||
preload("res://ShapeL.tscn"),
|
preload("res://Shapes/ShapeL.tscn"),
|
||||||
preload("res://ShapeZ.tscn"),
|
preload("res://Shapes/ShapeZ.tscn"),
|
||||||
preload("res://ShapeS.tscn"),
|
preload("res://Shapes/ShapeS.tscn"),
|
||||||
preload("res://ShapeT.tscn"),
|
preload("res://Shapes/ShapeT.tscn"),
|
||||||
preload("res://ShapeO.tscn")
|
preload("res://Shapes/ShapeO.tscn")
|
||||||
]
|
]
|
||||||
|
|
||||||
var active_shape: TetrisShape
|
var active_shape: TetrisShape
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[gd_scene load_steps=4 format=2]
|
[gd_scene load_steps=4 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://background.png" type="Texture" id=1]
|
[ext_resource path="res://Resources/background.png" type="Texture" id=1]
|
||||||
[ext_resource path="res://GameBoard.gd" type="Script" id=2]
|
[ext_resource path="res://GameBoard.gd" type="Script" id=2]
|
||||||
[ext_resource path="res://SwipeHandler.gd" type="Script" id=3]
|
[ext_resource path="res://SwipeHandler.gd" type="Script" id=3]
|
||||||
|
|
||||||
|
18
Main.tscn
18
Main.tscn
@ -1,14 +1,19 @@
|
|||||||
[gd_scene load_steps=4 format=2]
|
[gd_scene load_steps=6 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://GameBoard.tscn" type="PackedScene" id=1]
|
[ext_resource path="res://GameBoard.tscn" type="PackedScene" id=1]
|
||||||
[ext_resource path="res://UI.gd" type="Script" id=2]
|
[ext_resource path="res://UI.gd" type="Script" id=2]
|
||||||
[ext_resource path="res://Main.gd" type="Script" id=3]
|
[ext_resource path="res://Main.gd" type="Script" id=3]
|
||||||
|
[ext_resource path="res://Resources/Kenney Future.ttf" type="DynamicFontData" id=4]
|
||||||
|
|
||||||
|
[sub_resource type="DynamicFont" id=1]
|
||||||
|
size = 128
|
||||||
|
font_data = ExtResource( 4 )
|
||||||
|
|
||||||
[node name="Main" type="Node"]
|
[node name="Main" type="Node"]
|
||||||
script = ExtResource( 3 )
|
script = ExtResource( 3 )
|
||||||
|
|
||||||
[node name="GameBoard" parent="." instance=ExtResource( 1 )]
|
[node name="GameBoard" parent="." instance=ExtResource( 1 )]
|
||||||
position = Vector2( 547, 813 )
|
position = Vector2( 540, 1000 )
|
||||||
|
|
||||||
[node name="UI" type="Control" parent="."]
|
[node name="UI" type="Control" parent="."]
|
||||||
anchor_right = 1.0
|
anchor_right = 1.0
|
||||||
@ -30,13 +35,14 @@ margin_right = 1080.0
|
|||||||
margin_bottom = 150.0
|
margin_bottom = 150.0
|
||||||
|
|
||||||
[node name="Score" type="Label" parent="UI/VBoxContainer/HBoxContainer"]
|
[node name="Score" type="Label" parent="UI/VBoxContainer/HBoxContainer"]
|
||||||
margin_top = 68.0
|
margin_top = 3.0
|
||||||
margin_right = 8.0
|
margin_right = 107.0
|
||||||
margin_bottom = 82.0
|
margin_bottom = 147.0
|
||||||
|
custom_fonts/font = SubResource( 1 )
|
||||||
text = "0"
|
text = "0"
|
||||||
|
|
||||||
[node name="Spacer" type="Control" parent="UI/VBoxContainer/HBoxContainer"]
|
[node name="Spacer" type="Control" parent="UI/VBoxContainer/HBoxContainer"]
|
||||||
margin_left = 12.0
|
margin_left = 111.0
|
||||||
margin_right = 926.0
|
margin_right = 926.0
|
||||||
margin_bottom = 150.0
|
margin_bottom = 150.0
|
||||||
size_flags_horizontal = 3
|
size_flags_horizontal = 3
|
||||||
|
BIN
Resources/Kenney Future.ttf
Normal file
BIN
Resources/Kenney Future.ttf
Normal file
Binary file not shown.
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 3.3 KiB |
@ -2,15 +2,15 @@
|
|||||||
|
|
||||||
importer="texture"
|
importer="texture"
|
||||||
type="StreamTexture"
|
type="StreamTexture"
|
||||||
path="res://.import/background.png-98289422cd7d93003950872a7b97021f.stex"
|
path="res://.import/background.png-29f75aad12319c515b0a31e04e27d610.stex"
|
||||||
metadata={
|
metadata={
|
||||||
"vram_texture": false
|
"vram_texture": false
|
||||||
}
|
}
|
||||||
|
|
||||||
[deps]
|
[deps]
|
||||||
|
|
||||||
source_file="res://background.png"
|
source_file="res://Resources/background.png"
|
||||||
dest_files=[ "res://.import/background.png-98289422cd7d93003950872a7b97021f.stex" ]
|
dest_files=[ "res://.import/background.png-29f75aad12319c515b0a31e04e27d610.stex" ]
|
||||||
|
|
||||||
[params]
|
[params]
|
||||||
|
|
Before Width: | Height: | Size: 6.2 KiB After Width: | Height: | Size: 6.2 KiB |
@ -2,15 +2,15 @@
|
|||||||
|
|
||||||
importer="texture"
|
importer="texture"
|
||||||
type="StreamTexture"
|
type="StreamTexture"
|
||||||
path="res://.import/brick.png-3b7e2d2d29430a475fb75656e3e81471.stex"
|
path="res://.import/brick.png-f9b7612ef038ee5d9ee3b9e2a0996994.stex"
|
||||||
metadata={
|
metadata={
|
||||||
"vram_texture": false
|
"vram_texture": false
|
||||||
}
|
}
|
||||||
|
|
||||||
[deps]
|
[deps]
|
||||||
|
|
||||||
source_file="res://brick.png"
|
source_file="res://Resources/brick.png"
|
||||||
dest_files=[ "res://.import/brick.png-3b7e2d2d29430a475fb75656e3e81471.stex" ]
|
dest_files=[ "res://.import/brick.png-f9b7612ef038ee5d9ee3b9e2a0996994.stex" ]
|
||||||
|
|
||||||
[params]
|
[params]
|
||||||
|
|
23
ShapeI.tscn
23
ShapeI.tscn
@ -1,23 +0,0 @@
|
|||||||
[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="ShapeI" type="Node2D"]
|
|
||||||
script = ExtResource( 2 )
|
|
||||||
|
|
||||||
[node name="Block" parent="." instance=ExtResource( 1 )]
|
|
||||||
position = Vector2( 32, 32 )
|
|
||||||
color = Color( 0.717647, 1, 0.952941, 1 )
|
|
||||||
|
|
||||||
[node name="Block2" parent="." instance=ExtResource( 1 )]
|
|
||||||
position = Vector2( 32, -32 )
|
|
||||||
color = Color( 0.717647, 1, 0.952941, 1 )
|
|
||||||
|
|
||||||
[node name="Block3" parent="." instance=ExtResource( 1 )]
|
|
||||||
position = Vector2( 32, -96 )
|
|
||||||
color = Color( 0.717647, 1, 0.952941, 1 )
|
|
||||||
|
|
||||||
[node name="Block4" parent="." instance=ExtResource( 1 )]
|
|
||||||
position = Vector2( 32, -160 )
|
|
||||||
color = Color( 0.717647, 1, 0.952941, 1 )
|
|
23
ShapeJ.tscn
23
ShapeJ.tscn
@ -1,23 +0,0 @@
|
|||||||
[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="ShapeJ" type="Node2D"]
|
|
||||||
script = ExtResource( 2 )
|
|
||||||
|
|
||||||
[node name="Block" parent="." instance=ExtResource( 1 )]
|
|
||||||
position = Vector2( -32, 32 )
|
|
||||||
color = Color( 0.486275, 0.494118, 1, 1 )
|
|
||||||
|
|
||||||
[node name="Block2" parent="." instance=ExtResource( 1 )]
|
|
||||||
position = Vector2( 32, 32 )
|
|
||||||
color = Color( 0.486275, 0.494118, 1, 1 )
|
|
||||||
|
|
||||||
[node name="Block3" parent="." instance=ExtResource( 1 )]
|
|
||||||
position = Vector2( 32, -32 )
|
|
||||||
color = Color( 0.486275, 0.494118, 1, 1 )
|
|
||||||
|
|
||||||
[node name="Block4" parent="." instance=ExtResource( 1 )]
|
|
||||||
position = Vector2( 32, -96 )
|
|
||||||
color = Color( 0.486275, 0.494118, 1, 1 )
|
|
23
ShapeL.tscn
23
ShapeL.tscn
@ -1,23 +0,0 @@
|
|||||||
[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 )
|
|
||||||
color = Color( 1, 0.47451, 0.47451, 1 )
|
|
||||||
|
|
||||||
[node name="Block3" parent="." instance=ExtResource( 1 )]
|
|
||||||
position = Vector2( -32, -32 )
|
|
||||||
color = Color( 1, 0.47451, 0.47451, 1 )
|
|
||||||
|
|
||||||
[node name="Block4" parent="." instance=ExtResource( 1 )]
|
|
||||||
position = Vector2( -32, -96 )
|
|
||||||
color = Color( 1, 0.47451, 0.47451, 1 )
|
|
||||||
|
|
||||||
[node name="Block2" parent="." instance=ExtResource( 1 )]
|
|
||||||
position = Vector2( 32, 32 )
|
|
||||||
color = Color( 1, 0.47451, 0.47451, 1 )
|
|
23
ShapeO.tscn
23
ShapeO.tscn
@ -1,23 +0,0 @@
|
|||||||
[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="ShapeSquare" type="Node2D"]
|
|
||||||
script = ExtResource( 2 )
|
|
||||||
|
|
||||||
[node name="Block" parent="." instance=ExtResource( 1 )]
|
|
||||||
position = Vector2( 32, 32 )
|
|
||||||
color = Color( 0.827451, 1, 0.490196, 1 )
|
|
||||||
|
|
||||||
[node name="Block2" parent="." instance=ExtResource( 1 )]
|
|
||||||
position = Vector2( 32, -32 )
|
|
||||||
color = Color( 0.827451, 1, 0.490196, 1 )
|
|
||||||
|
|
||||||
[node name="Block3" parent="." instance=ExtResource( 1 )]
|
|
||||||
position = Vector2( -32, -32 )
|
|
||||||
color = Color( 0.827451, 1, 0.490196, 1 )
|
|
||||||
|
|
||||||
[node name="Block4" parent="." instance=ExtResource( 1 )]
|
|
||||||
position = Vector2( -32, 32 )
|
|
||||||
color = Color( 0.827451, 1, 0.490196, 1 )
|
|
23
ShapeS.tscn
23
ShapeS.tscn
@ -1,23 +0,0 @@
|
|||||||
[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="ShapeS" type="Node2D"]
|
|
||||||
script = ExtResource( 2 )
|
|
||||||
|
|
||||||
[node name="Block" parent="." instance=ExtResource( 1 )]
|
|
||||||
position = Vector2( -32, 32 )
|
|
||||||
color = Color( 0.607843, 1, 0.603922, 1 )
|
|
||||||
|
|
||||||
[node name="Block2" parent="." instance=ExtResource( 1 )]
|
|
||||||
position = Vector2( 32, 32 )
|
|
||||||
color = Color( 0.607843, 1, 0.603922, 1 )
|
|
||||||
|
|
||||||
[node name="Block3" parent="." instance=ExtResource( 1 )]
|
|
||||||
position = Vector2( 32, -32 )
|
|
||||||
color = Color( 0.607843, 1, 0.603922, 1 )
|
|
||||||
|
|
||||||
[node name="Block4" parent="." instance=ExtResource( 1 )]
|
|
||||||
position = Vector2( 96, -32 )
|
|
||||||
color = Color( 0.607843, 1, 0.603922, 1 )
|
|
23
ShapeT.tscn
23
ShapeT.tscn
@ -1,23 +0,0 @@
|
|||||||
[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="ShapeT" type="Node2D"]
|
|
||||||
script = ExtResource( 2 )
|
|
||||||
|
|
||||||
[node name="Block" parent="." instance=ExtResource( 1 )]
|
|
||||||
position = Vector2( -32, 32 )
|
|
||||||
color = Color( 0.968627, 0.411765, 1, 1 )
|
|
||||||
|
|
||||||
[node name="Block2" parent="." instance=ExtResource( 1 )]
|
|
||||||
position = Vector2( 32, 32 )
|
|
||||||
color = Color( 0.968627, 0.411765, 1, 1 )
|
|
||||||
|
|
||||||
[node name="Block3" parent="." instance=ExtResource( 1 )]
|
|
||||||
position = Vector2( 32, -32 )
|
|
||||||
color = Color( 0.968627, 0.411765, 1, 1 )
|
|
||||||
|
|
||||||
[node name="Block4" parent="." instance=ExtResource( 1 )]
|
|
||||||
position = Vector2( 96, 32 )
|
|
||||||
color = Color( 0.968627, 0.411765, 1, 1 )
|
|
23
ShapeZ.tscn
23
ShapeZ.tscn
@ -1,23 +0,0 @@
|
|||||||
[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="ShapeZ" type="Node2D"]
|
|
||||||
script = ExtResource( 2 )
|
|
||||||
|
|
||||||
[node name="Block" parent="." instance=ExtResource( 1 )]
|
|
||||||
position = Vector2( -32, -32 )
|
|
||||||
color = Color( 0.984314, 1, 0.537255, 1 )
|
|
||||||
|
|
||||||
[node name="Block2" parent="." instance=ExtResource( 1 )]
|
|
||||||
position = Vector2( 32, -32 )
|
|
||||||
color = Color( 0.984314, 1, 0.537255, 1 )
|
|
||||||
|
|
||||||
[node name="Block3" parent="." instance=ExtResource( 1 )]
|
|
||||||
position = Vector2( 32, 32 )
|
|
||||||
color = Color( 0.984314, 1, 0.537255, 1 )
|
|
||||||
|
|
||||||
[node name="Block4" parent="." instance=ExtResource( 1 )]
|
|
||||||
position = Vector2( 96, 32 )
|
|
||||||
color = Color( 0.984314, 1, 0.537255, 1 )
|
|
@ -1,7 +1,7 @@
|
|||||||
[gd_scene load_steps=5 format=2]
|
[gd_scene load_steps=5 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://brick.png" type="Texture" id=1]
|
[ext_resource path="res://Shapes/Block.gd" type="Script" id=1]
|
||||||
[ext_resource path="res://Block.gd" type="Script" id=2]
|
[ext_resource path="res://Resources/brick.png" type="Texture" id=2]
|
||||||
|
|
||||||
[sub_resource type="Shader" id=1]
|
[sub_resource type="Shader" id=1]
|
||||||
code = "shader_type canvas_item;
|
code = "shader_type canvas_item;
|
||||||
@ -21,10 +21,10 @@ shader = SubResource( 1 )
|
|||||||
shader_param/color = Color( 1, 1, 1, 1 )
|
shader_param/color = Color( 1, 1, 1, 1 )
|
||||||
|
|
||||||
[node name="Block" type="Node2D"]
|
[node name="Block" type="Node2D"]
|
||||||
script = ExtResource( 2 )
|
script = ExtResource( 1 )
|
||||||
color = Color( 1, 1, 1, 1 )
|
color = Color( 1, 1, 1, 1 )
|
||||||
|
|
||||||
[node name="Sprite" type="Sprite" parent="."]
|
[node name="Sprite" type="Sprite" parent="."]
|
||||||
material = SubResource( 2 )
|
material = SubResource( 2 )
|
||||||
scale = Vector2( 0.125, 0.125 )
|
scale = Vector2( 0.125, 0.125 )
|
||||||
texture = ExtResource( 1 )
|
texture = ExtResource( 2 )
|
23
Shapes/ShapeI.tscn
Normal file
23
Shapes/ShapeI.tscn
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
[gd_scene load_steps=3 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://Shapes/TetrisShape.gd" type="Script" id=1]
|
||||||
|
[ext_resource path="res://Shapes/Block.tscn" type="PackedScene" id=2]
|
||||||
|
|
||||||
|
[node name="ShapeI" type="Node2D"]
|
||||||
|
script = ExtResource( 1 )
|
||||||
|
|
||||||
|
[node name="Block" parent="." instance=ExtResource( 2 )]
|
||||||
|
position = Vector2( 32, 32 )
|
||||||
|
color = Color( 0.717647, 1, 0.952941, 1 )
|
||||||
|
|
||||||
|
[node name="Block2" parent="." instance=ExtResource( 2 )]
|
||||||
|
position = Vector2( 32, -32 )
|
||||||
|
color = Color( 0.717647, 1, 0.952941, 1 )
|
||||||
|
|
||||||
|
[node name="Block3" parent="." instance=ExtResource( 2 )]
|
||||||
|
position = Vector2( 32, -96 )
|
||||||
|
color = Color( 0.717647, 1, 0.952941, 1 )
|
||||||
|
|
||||||
|
[node name="Block4" parent="." instance=ExtResource( 2 )]
|
||||||
|
position = Vector2( 32, -160 )
|
||||||
|
color = Color( 0.717647, 1, 0.952941, 1 )
|
23
Shapes/ShapeJ.tscn
Normal file
23
Shapes/ShapeJ.tscn
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
[gd_scene load_steps=3 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://Shapes/TetrisShape.gd" type="Script" id=1]
|
||||||
|
[ext_resource path="res://Shapes/Block.tscn" type="PackedScene" id=2]
|
||||||
|
|
||||||
|
[node name="ShapeJ" type="Node2D"]
|
||||||
|
script = ExtResource( 1 )
|
||||||
|
|
||||||
|
[node name="Block" parent="." instance=ExtResource( 2 )]
|
||||||
|
position = Vector2( -32, 32 )
|
||||||
|
color = Color( 0.486275, 0.494118, 1, 1 )
|
||||||
|
|
||||||
|
[node name="Block2" parent="." instance=ExtResource( 2 )]
|
||||||
|
position = Vector2( 32, 32 )
|
||||||
|
color = Color( 0.486275, 0.494118, 1, 1 )
|
||||||
|
|
||||||
|
[node name="Block3" parent="." instance=ExtResource( 2 )]
|
||||||
|
position = Vector2( 32, -32 )
|
||||||
|
color = Color( 0.486275, 0.494118, 1, 1 )
|
||||||
|
|
||||||
|
[node name="Block4" parent="." instance=ExtResource( 2 )]
|
||||||
|
position = Vector2( 32, -96 )
|
||||||
|
color = Color( 0.486275, 0.494118, 1, 1 )
|
23
Shapes/ShapeL.tscn
Normal file
23
Shapes/ShapeL.tscn
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
[gd_scene load_steps=3 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://Shapes/TetrisShape.gd" type="Script" id=1]
|
||||||
|
[ext_resource path="res://Shapes/Block.tscn" type="PackedScene" id=2]
|
||||||
|
|
||||||
|
[node name="ShapeL" type="Node2D"]
|
||||||
|
script = ExtResource( 1 )
|
||||||
|
|
||||||
|
[node name="Block" parent="." instance=ExtResource( 2 )]
|
||||||
|
position = Vector2( -32, 32 )
|
||||||
|
color = Color( 1, 0.47451, 0.47451, 1 )
|
||||||
|
|
||||||
|
[node name="Block3" parent="." instance=ExtResource( 2 )]
|
||||||
|
position = Vector2( -32, -32 )
|
||||||
|
color = Color( 1, 0.47451, 0.47451, 1 )
|
||||||
|
|
||||||
|
[node name="Block4" parent="." instance=ExtResource( 2 )]
|
||||||
|
position = Vector2( -32, -96 )
|
||||||
|
color = Color( 1, 0.47451, 0.47451, 1 )
|
||||||
|
|
||||||
|
[node name="Block2" parent="." instance=ExtResource( 2 )]
|
||||||
|
position = Vector2( 32, 32 )
|
||||||
|
color = Color( 1, 0.47451, 0.47451, 1 )
|
23
Shapes/ShapeO.tscn
Normal file
23
Shapes/ShapeO.tscn
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
[gd_scene load_steps=3 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://Shapes/TetrisShape.gd" type="Script" id=1]
|
||||||
|
[ext_resource path="res://Shapes/Block.tscn" type="PackedScene" id=2]
|
||||||
|
|
||||||
|
[node name="ShapeSquare" type="Node2D"]
|
||||||
|
script = ExtResource( 1 )
|
||||||
|
|
||||||
|
[node name="Block" parent="." instance=ExtResource( 2 )]
|
||||||
|
position = Vector2( 32, 32 )
|
||||||
|
color = Color( 0.827451, 1, 0.490196, 1 )
|
||||||
|
|
||||||
|
[node name="Block2" parent="." instance=ExtResource( 2 )]
|
||||||
|
position = Vector2( 32, -32 )
|
||||||
|
color = Color( 0.827451, 1, 0.490196, 1 )
|
||||||
|
|
||||||
|
[node name="Block3" parent="." instance=ExtResource( 2 )]
|
||||||
|
position = Vector2( -32, -32 )
|
||||||
|
color = Color( 0.827451, 1, 0.490196, 1 )
|
||||||
|
|
||||||
|
[node name="Block4" parent="." instance=ExtResource( 2 )]
|
||||||
|
position = Vector2( -32, 32 )
|
||||||
|
color = Color( 0.827451, 1, 0.490196, 1 )
|
23
Shapes/ShapeS.tscn
Normal file
23
Shapes/ShapeS.tscn
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
[gd_scene load_steps=3 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://Shapes/TetrisShape.gd" type="Script" id=1]
|
||||||
|
[ext_resource path="res://Shapes/Block.tscn" type="PackedScene" id=2]
|
||||||
|
|
||||||
|
[node name="ShapeS" type="Node2D"]
|
||||||
|
script = ExtResource( 1 )
|
||||||
|
|
||||||
|
[node name="Block" parent="." instance=ExtResource( 2 )]
|
||||||
|
position = Vector2( -32, 32 )
|
||||||
|
color = Color( 0.607843, 1, 0.603922, 1 )
|
||||||
|
|
||||||
|
[node name="Block2" parent="." instance=ExtResource( 2 )]
|
||||||
|
position = Vector2( 32, 32 )
|
||||||
|
color = Color( 0.607843, 1, 0.603922, 1 )
|
||||||
|
|
||||||
|
[node name="Block3" parent="." instance=ExtResource( 2 )]
|
||||||
|
position = Vector2( 32, -32 )
|
||||||
|
color = Color( 0.607843, 1, 0.603922, 1 )
|
||||||
|
|
||||||
|
[node name="Block4" parent="." instance=ExtResource( 2 )]
|
||||||
|
position = Vector2( 96, -32 )
|
||||||
|
color = Color( 0.607843, 1, 0.603922, 1 )
|
23
Shapes/ShapeT.tscn
Normal file
23
Shapes/ShapeT.tscn
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
[gd_scene load_steps=3 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://Shapes/TetrisShape.gd" type="Script" id=1]
|
||||||
|
[ext_resource path="res://Shapes/Block.tscn" type="PackedScene" id=2]
|
||||||
|
|
||||||
|
[node name="ShapeT" type="Node2D"]
|
||||||
|
script = ExtResource( 1 )
|
||||||
|
|
||||||
|
[node name="Block" parent="." instance=ExtResource( 2 )]
|
||||||
|
position = Vector2( -32, 32 )
|
||||||
|
color = Color( 0.968627, 0.411765, 1, 1 )
|
||||||
|
|
||||||
|
[node name="Block2" parent="." instance=ExtResource( 2 )]
|
||||||
|
position = Vector2( 32, 32 )
|
||||||
|
color = Color( 0.968627, 0.411765, 1, 1 )
|
||||||
|
|
||||||
|
[node name="Block3" parent="." instance=ExtResource( 2 )]
|
||||||
|
position = Vector2( 32, -32 )
|
||||||
|
color = Color( 0.968627, 0.411765, 1, 1 )
|
||||||
|
|
||||||
|
[node name="Block4" parent="." instance=ExtResource( 2 )]
|
||||||
|
position = Vector2( 96, 32 )
|
||||||
|
color = Color( 0.968627, 0.411765, 1, 1 )
|
23
Shapes/ShapeZ.tscn
Normal file
23
Shapes/ShapeZ.tscn
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
[gd_scene load_steps=3 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://Shapes/TetrisShape.gd" type="Script" id=1]
|
||||||
|
[ext_resource path="res://Shapes/Block.tscn" type="PackedScene" id=2]
|
||||||
|
|
||||||
|
[node name="ShapeZ" type="Node2D"]
|
||||||
|
script = ExtResource( 1 )
|
||||||
|
|
||||||
|
[node name="Block" parent="." instance=ExtResource( 2 )]
|
||||||
|
position = Vector2( -32, -32 )
|
||||||
|
color = Color( 0.984314, 1, 0.537255, 1 )
|
||||||
|
|
||||||
|
[node name="Block2" parent="." instance=ExtResource( 2 )]
|
||||||
|
position = Vector2( 32, -32 )
|
||||||
|
color = Color( 0.984314, 1, 0.537255, 1 )
|
||||||
|
|
||||||
|
[node name="Block3" parent="." instance=ExtResource( 2 )]
|
||||||
|
position = Vector2( 32, 32 )
|
||||||
|
color = Color( 0.984314, 1, 0.537255, 1 )
|
||||||
|
|
||||||
|
[node name="Block4" parent="." instance=ExtResource( 2 )]
|
||||||
|
position = Vector2( 96, 32 )
|
||||||
|
color = Color( 0.984314, 1, 0.537255, 1 )
|
19
UI.gd
19
UI.gd
@ -1,6 +1,10 @@
|
|||||||
extends Control
|
extends Control
|
||||||
|
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
_set_safe_area()
|
||||||
|
|
||||||
|
|
||||||
func update_score(new_score):
|
func update_score(new_score):
|
||||||
$VBoxContainer/HBoxContainer/Score.text = str(new_score)
|
$VBoxContainer/HBoxContainer/Score.text = str(new_score)
|
||||||
|
|
||||||
@ -10,3 +14,18 @@ func set_next_shape(shape_scene):
|
|||||||
child.free()
|
child.free()
|
||||||
|
|
||||||
$VBoxContainer/HBoxContainer/NextShape/Origin.add_child(shape_scene.instance())
|
$VBoxContainer/HBoxContainer/NextShape/Origin.add_child(shape_scene.instance())
|
||||||
|
|
||||||
|
|
||||||
|
# Resizes the UI to accomodate for notches, rounded corners, etc on mobile
|
||||||
|
# Adapted from https://github.com/godotengine/godot/issues/49887
|
||||||
|
func _set_safe_area():
|
||||||
|
var window_to_root = Transform2D.IDENTITY.scaled(get_tree().root.size / OS.window_size)
|
||||||
|
var safe_area_root = window_to_root.xform(OS.get_window_safe_area())
|
||||||
|
|
||||||
|
assert(get_viewport() == get_tree().root, "Assumption: control is not in a nested Viewport")
|
||||||
|
var parent_to_root = get_viewport_transform() * get_global_transform() * get_transform().affine_inverse()
|
||||||
|
var root_to_parent = parent_to_root.affine_inverse()
|
||||||
|
|
||||||
|
var safe_area_relative_to_parent = root_to_parent.xform(safe_area_root)
|
||||||
|
rect_position = safe_area_relative_to_parent.position
|
||||||
|
rect_size = safe_area_relative_to_parent.size
|
||||||
|
@ -12,7 +12,7 @@ _global_script_classes=[ {
|
|||||||
"base": "Node2D",
|
"base": "Node2D",
|
||||||
"class": "TetrisShape",
|
"class": "TetrisShape",
|
||||||
"language": "GDScript",
|
"language": "GDScript",
|
||||||
"path": "res://TetrisShape.gd"
|
"path": "res://Shapes/TetrisShape.gd"
|
||||||
} ]
|
} ]
|
||||||
_global_script_class_icons={
|
_global_script_class_icons={
|
||||||
"TetrisShape": ""
|
"TetrisShape": ""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user