From 1e54f7bb526f63d62b127748cd88ff04a4eeae8f Mon Sep 17 00:00:00 2001 From: karl Date: Sun, 21 Nov 2021 14:03:19 +0100 Subject: [PATCH] Some cleanup and safe area implementation --- GameBoard.gd | 14 +++++------ GameBoard.tscn | 2 +- Main.tscn | 18 +++++++++----- Resources/Kenney Future.ttf | Bin 0 -> 34116 bytes background.png => Resources/background.png | Bin .../background.png.import | 6 ++--- brick.png => Resources/brick.png | Bin .../brick.png.import | 6 ++--- ShapeI.tscn | 23 ------------------ ShapeJ.tscn | 23 ------------------ ShapeL.tscn | 23 ------------------ ShapeO.tscn | 23 ------------------ ShapeS.tscn | 23 ------------------ ShapeT.tscn | 23 ------------------ ShapeZ.tscn | 23 ------------------ Block.gd => Shapes/Block.gd | 0 Block.tscn => Shapes/Block.tscn | 8 +++--- Shapes/ShapeI.tscn | 23 ++++++++++++++++++ Shapes/ShapeJ.tscn | 23 ++++++++++++++++++ Shapes/ShapeL.tscn | 23 ++++++++++++++++++ Shapes/ShapeO.tscn | 23 ++++++++++++++++++ Shapes/ShapeS.tscn | 23 ++++++++++++++++++ Shapes/ShapeT.tscn | 23 ++++++++++++++++++ Shapes/ShapeZ.tscn | 23 ++++++++++++++++++ TetrisShape.gd => Shapes/TetrisShape.gd | 0 UI.gd | 19 +++++++++++++++ project.godot | 2 +- 27 files changed, 211 insertions(+), 186 deletions(-) create mode 100644 Resources/Kenney Future.ttf rename background.png => Resources/background.png (100%) rename background.png.import => Resources/background.png.import (71%) rename brick.png => Resources/brick.png (100%) rename brick.png.import => Resources/brick.png.import (73%) delete mode 100644 ShapeI.tscn delete mode 100644 ShapeJ.tscn delete mode 100644 ShapeL.tscn delete mode 100644 ShapeO.tscn delete mode 100644 ShapeS.tscn delete mode 100644 ShapeT.tscn delete mode 100644 ShapeZ.tscn rename Block.gd => Shapes/Block.gd (100%) rename Block.tscn => Shapes/Block.tscn (74%) create mode 100644 Shapes/ShapeI.tscn create mode 100644 Shapes/ShapeJ.tscn create mode 100644 Shapes/ShapeL.tscn create mode 100644 Shapes/ShapeO.tscn create mode 100644 Shapes/ShapeS.tscn create mode 100644 Shapes/ShapeT.tscn create mode 100644 Shapes/ShapeZ.tscn rename TetrisShape.gd => Shapes/TetrisShape.gd (100%) diff --git a/GameBoard.gd b/GameBoard.gd index fef6c96..0cd9d56 100644 --- a/GameBoard.gd +++ b/GameBoard.gd @@ -5,13 +5,13 @@ signal score_changed(new_score) signal new_next_shape(next_shape_scene) var shapes = [ - preload("res://ShapeI.tscn"), - preload("res://ShapeJ.tscn"), - preload("res://ShapeL.tscn"), - preload("res://ShapeZ.tscn"), - preload("res://ShapeS.tscn"), - preload("res://ShapeT.tscn"), - preload("res://ShapeO.tscn") + preload("res://Shapes/ShapeI.tscn"), + preload("res://Shapes/ShapeJ.tscn"), + preload("res://Shapes/ShapeL.tscn"), + preload("res://Shapes/ShapeZ.tscn"), + preload("res://Shapes/ShapeS.tscn"), + preload("res://Shapes/ShapeT.tscn"), + preload("res://Shapes/ShapeO.tscn") ] var active_shape: TetrisShape diff --git a/GameBoard.tscn b/GameBoard.tscn index 5fb8e4d..a16e7f8 100644 --- a/GameBoard.tscn +++ b/GameBoard.tscn @@ -1,6 +1,6 @@ [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://SwipeHandler.gd" type="Script" id=3] diff --git a/Main.tscn b/Main.tscn index bdf40a1..b2816c1 100644 --- a/Main.tscn +++ b/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://UI.gd" type="Script" id=2] [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"] script = ExtResource( 3 ) [node name="GameBoard" parent="." instance=ExtResource( 1 )] -position = Vector2( 547, 813 ) +position = Vector2( 540, 1000 ) [node name="UI" type="Control" parent="."] anchor_right = 1.0 @@ -30,13 +35,14 @@ margin_right = 1080.0 margin_bottom = 150.0 [node name="Score" type="Label" parent="UI/VBoxContainer/HBoxContainer"] -margin_top = 68.0 -margin_right = 8.0 -margin_bottom = 82.0 +margin_top = 3.0 +margin_right = 107.0 +margin_bottom = 147.0 +custom_fonts/font = SubResource( 1 ) text = "0" [node name="Spacer" type="Control" parent="UI/VBoxContainer/HBoxContainer"] -margin_left = 12.0 +margin_left = 111.0 margin_right = 926.0 margin_bottom = 150.0 size_flags_horizontal = 3 diff --git a/Resources/Kenney Future.ttf b/Resources/Kenney Future.ttf new file mode 100644 index 0000000000000000000000000000000000000000..1dbb2dd5f7ca220796c5fae5bcbd4cfe09aa5a77 GIT binary patch literal 34116 zcmeHQYm8l2bzXO7{LaJRyq(8!Vuz5%9>+<5xG7ACaS{>=#3oJKG%#b2X9jy7nHl4l zM|CP8#E(iK6``m_h@z;fN?P#)wfVshBcZA)`GLTt0V3g2K>R2OwN#1}@a^}lwb$PJ zJnq~(*n$epx!(8evma}H>sxC-&bfE4r6VGnrIcYQ-g#(r-^i!ee@|rV0hGS)$n5yS zKmFrVZ1KFv$Y-WboIdv9y~}Sy{Z~bvzGixI{OEhPc0Vby?jf{!!!!zp%I-&SUE+G@ z^z8C8pZLUo{{+|1i3}e-F@I!SI{))|kw1GG*VD7(&n$GmBY!QjX(QSfbK|pRVpL?~>%h}g4v3vw6ukV$ww{u(C?CB+g z|8n*W8Ct~Hpa*ez`Fe2$MD{e-z1j|KN<3y<@3YSA%BT{cw}?PUn=h!`B=zbCQpuhE9AGyW9#-= z9{9Je`{)Dn3#S)nrlyyRM<(ayCQldp_TG6{$R0eod~$K}vB{~EC&m{K&d)6$T3$SP zB(}8bO4}kdetdFqX=Z+|xO2~5tKV&nGa)le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0+$N#zwDk}OEB6Q}G zOKp)y0MTH8gx|;G{|4yRwHir2aD+S5hRIa|lH3jccgq2kjRQ(5`DPE^l+XOSWJx}y z)~+EREErGWx7Su9zsX>b?~E#-PKijc-;<&X^&o1E3Ze~3ujy|sQAxPnlw8`Az?#OvPz%=DW;E>a8S4QAVKAJbCh z!2Ou!J?Qi2Dap44;iZ-3mwr``SLFw>u7%yRScwwQH$3z4=+Sd1%_Bbhtr30;QSnnr z%&5kEj4LXj!=cEz`swFhr9~pI^>Dj9f+IS&Ek8paRhH=Ozn!fR+&Wap{>Ycmz!WWF z|8PICJ)2<~mcTMQB08c7g_SbbtSGe)utf}x9jzK=-h)zgqE<@u@B1#7qKeMwRk~?! zc&WM=7#av1_)&1*F{E>D1DJjWub>oBpV1y@QQZ0q)dZIxhO!2eg=K=;4us5b#}pV+ zH2NFBH{gHttB#4lyAge=59orjkw-~>rH3zA3H8%xkleD4XGLCfH&Ti89MTW4LP7RxKZEoOZ1W*+8`@rRAJR)AS5AvuHG+ie zt3Hl|va26O`kBZzN0D%S?N%h@uZ4_jA>%sezwQ9i3nJT}M0!Q!`X`WH#Mcs0cf*%O zZrq4;2hs_oABfzv6X~N!&|RQy@sh|6oOk?K+4-FuFUE~0CzwK_MABY_Ml*oh7`Ovh; z!=Dp*`vIh%i#&opkDL{G^svY~9z{ai-$%c9jv%4kyY53m*}H!%a_ABy;5fW2@}9eq zUKDv8{r>>vPuzio@+W}l54R$n!~ekfg2*3#O617{NIw_(lP`)q1^n+5B;Xq_k$xsJ zfr5#1B1a(m=mHY-O#;K@b4aM4+KL3ZQ)n}N1=6EPA4Njh46bLEki_E_yvhZ<{r?2@xy8Bt7 literal 0 HcmV?d00001 diff --git a/background.png b/Resources/background.png similarity index 100% rename from background.png rename to Resources/background.png diff --git a/background.png.import b/Resources/background.png.import similarity index 71% rename from background.png.import rename to Resources/background.png.import index 1e8ce85..b3a67a1 100644 --- a/background.png.import +++ b/Resources/background.png.import @@ -2,15 +2,15 @@ importer="texture" type="StreamTexture" -path="res://.import/background.png-98289422cd7d93003950872a7b97021f.stex" +path="res://.import/background.png-29f75aad12319c515b0a31e04e27d610.stex" metadata={ "vram_texture": false } [deps] -source_file="res://background.png" -dest_files=[ "res://.import/background.png-98289422cd7d93003950872a7b97021f.stex" ] +source_file="res://Resources/background.png" +dest_files=[ "res://.import/background.png-29f75aad12319c515b0a31e04e27d610.stex" ] [params] diff --git a/brick.png b/Resources/brick.png similarity index 100% rename from brick.png rename to Resources/brick.png diff --git a/brick.png.import b/Resources/brick.png.import similarity index 73% rename from brick.png.import rename to Resources/brick.png.import index f35588f..cf6fd34 100644 --- a/brick.png.import +++ b/Resources/brick.png.import @@ -2,15 +2,15 @@ importer="texture" type="StreamTexture" -path="res://.import/brick.png-3b7e2d2d29430a475fb75656e3e81471.stex" +path="res://.import/brick.png-f9b7612ef038ee5d9ee3b9e2a0996994.stex" metadata={ "vram_texture": false } [deps] -source_file="res://brick.png" -dest_files=[ "res://.import/brick.png-3b7e2d2d29430a475fb75656e3e81471.stex" ] +source_file="res://Resources/brick.png" +dest_files=[ "res://.import/brick.png-f9b7612ef038ee5d9ee3b9e2a0996994.stex" ] [params] diff --git a/ShapeI.tscn b/ShapeI.tscn deleted file mode 100644 index 3afa308..0000000 --- a/ShapeI.tscn +++ /dev/null @@ -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 ) diff --git a/ShapeJ.tscn b/ShapeJ.tscn deleted file mode 100644 index ad01cf6..0000000 --- a/ShapeJ.tscn +++ /dev/null @@ -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 ) diff --git a/ShapeL.tscn b/ShapeL.tscn deleted file mode 100644 index 9286a9f..0000000 --- a/ShapeL.tscn +++ /dev/null @@ -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 ) diff --git a/ShapeO.tscn b/ShapeO.tscn deleted file mode 100644 index dc03e0e..0000000 --- a/ShapeO.tscn +++ /dev/null @@ -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 ) diff --git a/ShapeS.tscn b/ShapeS.tscn deleted file mode 100644 index 84cddf5..0000000 --- a/ShapeS.tscn +++ /dev/null @@ -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 ) diff --git a/ShapeT.tscn b/ShapeT.tscn deleted file mode 100644 index d029cf9..0000000 --- a/ShapeT.tscn +++ /dev/null @@ -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 ) diff --git a/ShapeZ.tscn b/ShapeZ.tscn deleted file mode 100644 index fa6ea72..0000000 --- a/ShapeZ.tscn +++ /dev/null @@ -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 ) diff --git a/Block.gd b/Shapes/Block.gd similarity index 100% rename from Block.gd rename to Shapes/Block.gd diff --git a/Block.tscn b/Shapes/Block.tscn similarity index 74% rename from Block.tscn rename to Shapes/Block.tscn index d812e31..a75da87 100644 --- a/Block.tscn +++ b/Shapes/Block.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=5 format=2] -[ext_resource path="res://brick.png" type="Texture" id=1] -[ext_resource path="res://Block.gd" type="Script" id=2] +[ext_resource path="res://Shapes/Block.gd" type="Script" id=1] +[ext_resource path="res://Resources/brick.png" type="Texture" id=2] [sub_resource type="Shader" id=1] code = "shader_type canvas_item; @@ -21,10 +21,10 @@ shader = SubResource( 1 ) shader_param/color = Color( 1, 1, 1, 1 ) [node name="Block" type="Node2D"] -script = ExtResource( 2 ) +script = ExtResource( 1 ) color = Color( 1, 1, 1, 1 ) [node name="Sprite" type="Sprite" parent="."] material = SubResource( 2 ) scale = Vector2( 0.125, 0.125 ) -texture = ExtResource( 1 ) +texture = ExtResource( 2 ) diff --git a/Shapes/ShapeI.tscn b/Shapes/ShapeI.tscn new file mode 100644 index 0000000..4c2cda9 --- /dev/null +++ b/Shapes/ShapeI.tscn @@ -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 ) diff --git a/Shapes/ShapeJ.tscn b/Shapes/ShapeJ.tscn new file mode 100644 index 0000000..52314b0 --- /dev/null +++ b/Shapes/ShapeJ.tscn @@ -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 ) diff --git a/Shapes/ShapeL.tscn b/Shapes/ShapeL.tscn new file mode 100644 index 0000000..39b8774 --- /dev/null +++ b/Shapes/ShapeL.tscn @@ -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 ) diff --git a/Shapes/ShapeO.tscn b/Shapes/ShapeO.tscn new file mode 100644 index 0000000..d69bdf4 --- /dev/null +++ b/Shapes/ShapeO.tscn @@ -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 ) diff --git a/Shapes/ShapeS.tscn b/Shapes/ShapeS.tscn new file mode 100644 index 0000000..816b84b --- /dev/null +++ b/Shapes/ShapeS.tscn @@ -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 ) diff --git a/Shapes/ShapeT.tscn b/Shapes/ShapeT.tscn new file mode 100644 index 0000000..0c8f21b --- /dev/null +++ b/Shapes/ShapeT.tscn @@ -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 ) diff --git a/Shapes/ShapeZ.tscn b/Shapes/ShapeZ.tscn new file mode 100644 index 0000000..f5bdab1 --- /dev/null +++ b/Shapes/ShapeZ.tscn @@ -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 ) diff --git a/TetrisShape.gd b/Shapes/TetrisShape.gd similarity index 100% rename from TetrisShape.gd rename to Shapes/TetrisShape.gd diff --git a/UI.gd b/UI.gd index a25d134..9712468 100644 --- a/UI.gd +++ b/UI.gd @@ -1,6 +1,10 @@ extends Control +func _ready(): + _set_safe_area() + + func update_score(new_score): $VBoxContainer/HBoxContainer/Score.text = str(new_score) @@ -10,3 +14,18 @@ func set_next_shape(shape_scene): child.free() $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 diff --git a/project.godot b/project.godot index e620c0c..fd3e327 100644 --- a/project.godot +++ b/project.godot @@ -12,7 +12,7 @@ _global_script_classes=[ { "base": "Node2D", "class": "TetrisShape", "language": "GDScript", -"path": "res://TetrisShape.gd" +"path": "res://Shapes/TetrisShape.gd" } ] _global_script_class_icons={ "TetrisShape": ""