diff --git a/Theme/button_normal.tres b/Theme/button_normal.tres new file mode 100644 index 0000000..9619788 --- /dev/null +++ b/Theme/button_normal.tres @@ -0,0 +1,10 @@ +[gd_resource type="StyleBoxTexture" load_steps=2 format=3 uid="uid://dj3hx8vj1mid1"] + +[ext_resource type="Texture2D" uid="uid://b2s6ir44pjyg1" path="res://assets/Buttons/BasicButton_normal.png" id="1_arer0"] + +[resource] +texture = ExtResource("1_arer0") +texture_margin_left = 30.0 +texture_margin_top = 30.0 +texture_margin_right = 30.0 +texture_margin_bottom = 30.0 diff --git a/Theme/button_pressedl.tres b/Theme/button_pressedl.tres new file mode 100644 index 0000000..67464a2 --- /dev/null +++ b/Theme/button_pressedl.tres @@ -0,0 +1,10 @@ +[gd_resource type="StyleBoxTexture" load_steps=2 format=3 uid="uid://ddgwjywgelxnh"] + +[ext_resource type="Texture2D" uid="uid://fhfxfbphnrlq" path="res://assets/Buttons/BasicButton_pressed.png" id="1_hjs03"] + +[resource] +texture = ExtResource("1_hjs03") +texture_margin_left = 30.0 +texture_margin_top = 30.0 +texture_margin_right = 30.0 +texture_margin_bottom = 30.0 diff --git a/Theme/main.tres b/Theme/main.tres new file mode 100644 index 0000000..7c7a29d --- /dev/null +++ b/Theme/main.tres @@ -0,0 +1,12 @@ +[gd_resource type="Theme" load_steps=4 format=3 uid="uid://1nebbd65iyce"] + +[ext_resource type="StyleBox" uid="uid://dj3hx8vj1mid1" path="res://Theme/button_normal.tres" id="1_0lddq"] +[ext_resource type="StyleBox" uid="uid://ddgwjywgelxnh" path="res://Theme/button_pressedl.tres" id="2_eqhtm"] + +[sub_resource type="StyleBoxTexture" id="StyleBoxTexture_rp1q2"] + +[resource] +Button/styles/focus = SubResource("StyleBoxTexture_rp1q2") +Button/styles/hover = ExtResource("1_0lddq") +Button/styles/normal = ExtResource("1_0lddq") +Button/styles/pressed = ExtResource("2_eqhtm") diff --git a/assets/Buttons/BasicButton.png b/assets/Buttons/BasicButton.png new file mode 100644 index 0000000..1766cc7 Binary files /dev/null and b/assets/Buttons/BasicButton.png differ diff --git a/assets/Buttons/BasicButton.png.import b/assets/Buttons/BasicButton.png.import new file mode 100644 index 0000000..e27e1f8 --- /dev/null +++ b/assets/Buttons/BasicButton.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://blauiujlkoh1x" +path="res://.godot/imported/BasicButton.png-de86cb5cc582db65ec033a502603129b.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/Buttons/BasicButton.png" +dest_files=["res://.godot/imported/BasicButton.png-de86cb5cc582db65ec033a502603129b.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/assets/Buttons/BasicButton.pxo b/assets/Buttons/BasicButton.pxo new file mode 100644 index 0000000..4a8e2d0 Binary files /dev/null and b/assets/Buttons/BasicButton.pxo differ diff --git a/assets/Buttons/BasicButton_normal.png b/assets/Buttons/BasicButton_normal.png new file mode 100644 index 0000000..5ac5a70 Binary files /dev/null and b/assets/Buttons/BasicButton_normal.png differ diff --git a/assets/Buttons/BasicButton_normal.png.import b/assets/Buttons/BasicButton_normal.png.import new file mode 100644 index 0000000..d7dc255 --- /dev/null +++ b/assets/Buttons/BasicButton_normal.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://b2s6ir44pjyg1" +path="res://.godot/imported/BasicButton_normal.png-d7036cb5a6690c189f5e324307f41b8a.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/Buttons/BasicButton_normal.png" +dest_files=["res://.godot/imported/BasicButton_normal.png-d7036cb5a6690c189f5e324307f41b8a.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/assets/Buttons/BasicButton_pressed.png b/assets/Buttons/BasicButton_pressed.png new file mode 100644 index 0000000..1766cc7 Binary files /dev/null and b/assets/Buttons/BasicButton_pressed.png differ diff --git a/assets/Buttons/BasicButton_pressed.png.import b/assets/Buttons/BasicButton_pressed.png.import new file mode 100644 index 0000000..92b36c6 --- /dev/null +++ b/assets/Buttons/BasicButton_pressed.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://fhfxfbphnrlq" +path="res://.godot/imported/BasicButton_pressed.png-3063cea8580bc519ff3700f7111f9a82.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/Buttons/BasicButton_pressed.png" +dest_files=["res://.godot/imported/BasicButton_pressed.png-3063cea8580bc519ff3700f7111f9a82.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/assets/Buttons/DownArrow.png b/assets/Buttons/DownArrow.png new file mode 100644 index 0000000..f68d00d Binary files /dev/null and b/assets/Buttons/DownArrow.png differ diff --git a/assets/Buttons/DownArrow.png.import b/assets/Buttons/DownArrow.png.import new file mode 100644 index 0000000..d9f26e3 --- /dev/null +++ b/assets/Buttons/DownArrow.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cevua7g7nsrfj" +path="res://.godot/imported/DownArrow.png-daaf4af3e32a18e4ff2950887dc075d6.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/Buttons/DownArrow.png" +dest_files=["res://.godot/imported/DownArrow.png-daaf4af3e32a18e4ff2950887dc075d6.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/assets/Buttons/DownArrow.pxo b/assets/Buttons/DownArrow.pxo new file mode 100644 index 0000000..4a16ecc Binary files /dev/null and b/assets/Buttons/DownArrow.pxo differ diff --git a/assets/Buttons/LeftArrow.png b/assets/Buttons/LeftArrow.png new file mode 100644 index 0000000..3f12c60 Binary files /dev/null and b/assets/Buttons/LeftArrow.png differ diff --git a/assets/Buttons/LeftArrow.png.import b/assets/Buttons/LeftArrow.png.import new file mode 100644 index 0000000..6780fe4 --- /dev/null +++ b/assets/Buttons/LeftArrow.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bfji7a4suq6a1" +path="res://.godot/imported/LeftArrow.png-b0c7ed511e95f0ad98a63d99e4188378.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/Buttons/LeftArrow.png" +dest_files=["res://.godot/imported/LeftArrow.png-b0c7ed511e95f0ad98a63d99e4188378.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/assets/Buttons/LeftArrow.pxo b/assets/Buttons/LeftArrow.pxo new file mode 100644 index 0000000..262a55e Binary files /dev/null and b/assets/Buttons/LeftArrow.pxo differ diff --git a/assets/Buttons/RightArrow.png b/assets/Buttons/RightArrow.png new file mode 100644 index 0000000..b1750df Binary files /dev/null and b/assets/Buttons/RightArrow.png differ diff --git a/assets/Buttons/RightArrow.png.import b/assets/Buttons/RightArrow.png.import new file mode 100644 index 0000000..611db24 --- /dev/null +++ b/assets/Buttons/RightArrow.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dsg7p035f3g52" +path="res://.godot/imported/RightArrow.png-8558667dcf0e5c07a5563c83a281291f.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/Buttons/RightArrow.png" +dest_files=["res://.godot/imported/RightArrow.png-8558667dcf0e5c07a5563c83a281291f.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/assets/Buttons/RightArrow.pxo b/assets/Buttons/RightArrow.pxo new file mode 100644 index 0000000..809ee11 Binary files /dev/null and b/assets/Buttons/RightArrow.pxo differ diff --git a/assets/Buttons/RotationLeft.png b/assets/Buttons/RotationLeft.png new file mode 100644 index 0000000..99a590d Binary files /dev/null and b/assets/Buttons/RotationLeft.png differ diff --git a/assets/Buttons/RotationLeft.png.import b/assets/Buttons/RotationLeft.png.import new file mode 100644 index 0000000..de61ddd --- /dev/null +++ b/assets/Buttons/RotationLeft.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://ct4dkk00pyv6v" +path="res://.godot/imported/RotationLeft.png-914b1c6fbc338ab04fd0f63963fc5cd9.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/Buttons/RotationLeft.png" +dest_files=["res://.godot/imported/RotationLeft.png-914b1c6fbc338ab04fd0f63963fc5cd9.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/assets/Buttons/RotationLeft.pxo b/assets/Buttons/RotationLeft.pxo new file mode 100644 index 0000000..3b85eee Binary files /dev/null and b/assets/Buttons/RotationLeft.pxo differ diff --git a/assets/Buttons/RotationRight.png b/assets/Buttons/RotationRight.png new file mode 100644 index 0000000..65215ec Binary files /dev/null and b/assets/Buttons/RotationRight.png differ diff --git a/assets/Buttons/RotationRight.png.import b/assets/Buttons/RotationRight.png.import new file mode 100644 index 0000000..c9ffcf7 --- /dev/null +++ b/assets/Buttons/RotationRight.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://5gbnb7gtwww3" +path="res://.godot/imported/RotationRight.png-76811f2593715fe1e653e9bd3b4cb6b4.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/Buttons/RotationRight.png" +dest_files=["res://.godot/imported/RotationRight.png-76811f2593715fe1e653e9bd3b4cb6b4.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/assets/Buttons/RotationRight.pxo b/assets/Buttons/RotationRight.pxo new file mode 100644 index 0000000..fffea9a Binary files /dev/null and b/assets/Buttons/RotationRight.pxo differ diff --git a/assets/RightArrow.png.import b/assets/RightArrow.png.import new file mode 100644 index 0000000..ce8c6f4 --- /dev/null +++ b/assets/RightArrow.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dvhykprtl45q0" +path="res://.godot/imported/RightArrow.png-a32550768e227e9d644da82207d67585.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/RightArrow.png" +dest_files=["res://.godot/imported/RightArrow.png-a32550768e227e9d644da82207d67585.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/project.godot b/project.godot index d378d97..a4d8f12 100644 --- a/project.godot +++ b/project.godot @@ -11,6 +11,7 @@ config_version=5 [application] config/name="GmtkGameJam2024" +config/description="Submission for the GMTK Game jam 2024. Tetris with special Blocks that expands" config/tags=PackedStringArray("game_jam") run/main_scene="res://scenes/Main/main.tscn" config/features=PackedStringArray("4.3", "GL Compatibility") @@ -25,10 +26,9 @@ GLOBAL="*res://scenes/Globals/global.gd" [display] window/size/viewport_width=1080 -window/size/viewport_height=1080 +window/size/viewport_height=1280 window/stretch/mode="viewport" window/stretch/aspect="expand" -window/stretch/scale=0.8 window/handheld/orientation=1 [editor] @@ -79,7 +79,7 @@ rotate_right={ , Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":12,"pressure":0.0,"pressed":true,"script":null) ] } -stop={ +down={ "deadzone": 0.5, "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":32,"key_label":0,"unicode":32,"location":0,"echo":false,"script":null) , Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194309,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) @@ -87,6 +87,10 @@ stop={ ] } +[input_devices] + +pointing/emulate_touch_from_mouse=true + [internationalization] locale/locale_filter_mode=0 @@ -99,6 +103,7 @@ locale/locale_filter_mode=0 2d_physics/layer_4="TurnTest" 2d_physics/layer_5="oneBlock" 2d_physics/layer_6="expandBlock" +2d_physics/layer_7="LoseArea" [rendering] diff --git a/scenes/Globals/global.gd b/scenes/Globals/global.gd index 8eec9ee..906c73f 100644 --- a/scenes/Globals/global.gd +++ b/scenes/Globals/global.gd @@ -2,9 +2,9 @@ extends Node var points = 0 -enum SPEED {MIN= 5, MAX= 12} - -var currentSpeed := SPEED.MIN +const minSpeed = 0.5 +const maxSpeed = 0.15 +var currentSpeed := minSpeed var hasSelectedSpeed = false @@ -30,6 +30,22 @@ var currentUID = lastUID var time = 0 +var lost = false + func getNewUID() -> int: lastUID += 1 return lastUID + + +func resetGame(): + points = 0 + lastUID = 0 + currentUID = lastUID + time = 0 + lost = false + +func _ready() -> void: + resetGame() + +func lose(): + lost = true diff --git a/scenes/Grid/camera_2d.gd b/scenes/Grid/camera_2d.gd new file mode 100644 index 0000000..1b84783 --- /dev/null +++ b/scenes/Grid/camera_2d.gd @@ -0,0 +1,14 @@ +extends Camera2D + +@onready var scoreLabel = $CanvasLayer/Control/HBoxContainer/ScoreValue +@onready var timeLabel = $CanvasLayer/Control/HBoxContainer2/TimeValue + +# Called when the node enters the scene tree for the first time. +func _ready() -> void: + pass # Replace with function body. + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta: float) -> void: + scoreLabel.text = str(GLOBAL.points) + timeLabel.text = str(GLOBAL.time) diff --git a/scenes/Grid/grid.gd b/scenes/Grid/grid.gd index e317b56..9846de7 100644 --- a/scenes/Grid/grid.gd +++ b/scenes/Grid/grid.gd @@ -5,6 +5,10 @@ extends Node2D @onready var tickerTimer = $Ticker @onready var patterns = $Patterns @onready var turnTickTimer = $TurnTick +@onready var loseArea = $LoseArea +@onready var gameTimer = $GameTimer +@onready var coyoteTimer = $CoyoteTimer + var nextBlocks = [] @@ -16,6 +20,7 @@ var blockSpeed = 0.5 var stopped = false + func spawnBlock() -> void: var block = nextBlocks[0] GLOBAL.currentBlock = block @@ -31,18 +36,18 @@ func _ready() -> void: func _physics_process(delta: float) -> void: - #for i in $Borders.get_children(): - #for j in i.get_overlapping_areas(): - #if j.is_in_group("Block"): - #if j.get_parent().UID == GLOBAL.currentUID: - #for s in getBlockGroupsList()[j.get_parent().UID]: - #s.queue_free() - #else: - #j.get_parent().queue_free() - #for i in getBlockGroupsList(): - #if i != GLOBAL.currentUID: - #moveUidGroup(GLOBAL.Direction.BOTTOM, i) + for i in getBlockGroupsList(): + if i != GLOBAL.currentUID: + moveUidGroup(GLOBAL.Direction.BOTTOM, i) var blockGroups = getBlockGroupsList() + #if Input.is_action_pressed("down"): + + if Input.is_action_pressed("down") and not stopped and not Input.is_action_just_released("down"): + if not tickerTimer.is_stopped(): + blockSpeed = GLOBAL.maxSpeed + else: + if not tickerTimer.is_stopped(): + blockSpeed = GLOBAL.minSpeed if Input.is_action_just_pressed("rotate_right") and not stopped: if blockGroups.has(GLOBAL.currentUID): for i in blockGroups[GLOBAL.currentUID]: @@ -54,7 +59,6 @@ func _physics_process(delta: float) -> void: print(5*delta) turnTickTimer.start(9*delta) - if Input.is_action_just_pressed("rotate_left") and not stopped: if blockGroups.has(GLOBAL.currentUID): for i in blockGroups[GLOBAL.currentUID]: @@ -181,8 +185,11 @@ func getNewPatterns(): newPatterns.append(load(GLOBAL.BLOCKSPATTERS[i]).instantiate()) newPatterns.shuffle() newPatterns[0].type = GLOBAL.BLOCKTYPES.HEAVY + newPatterns.shuffle() newPatterns[0].expand = true newPatterns.shuffle() + for i in newPatterns: + i.expand = true patternsArray.append_array(newPatterns) func turnBlocks(): @@ -202,60 +209,92 @@ func _on_turn_tick_timeout() -> void: func _on_ticker_timeout() -> void: stopped = true if getBlockedDirection(GLOBAL.Direction.BOTTOM, GLOBAL.currentUID): + coyoteTimer.start(0.1) - if currentPattern.expand: - if currentPattern.get_scale() != Vector2(2,2): - for i in getBlockGroupsList()[GLOBAL.currentUID]: - if i.turningPoint: - currentPattern.set_scale(Vector2(2,2)) - currentPattern.moveToPosition(i.global_position-spawnpoint.position - Vector2(64,64*4)) - if await currentPattern.getCollidingBorder() != []: - currentPattern.position.y -= 64 - for i in range(1,8): - if await currentPattern.getCollidingBorder() == []: - break - currentPattern.position.x -= 64 - currentPattern.position.x = 0 - for i in range(1,8): - if await currentPattern.getCollidingBorder() == []: - break - currentPattern.position.x += 64 - #if await currentPattern.getCollidingBorder() != []: - #currentPattern.position.y += 64 - - #if await currentPattern.getCollidingBorder() != []: - #currentPattern.position.x -= 64 - for i in getBlockGroupsList()[GLOBAL.currentUID].size(): - getBlockGroupsList()[GLOBAL.currentUID][i].global_position = currentPattern.getPositions()[i].global_position - Vector2(GLOBAL.GRID, GLOBAL.GRID) - getBlockGroupsList()[GLOBAL.currentUID][i].set_scale(Vector2(2,2)) - for i in await currentPattern.getCollidingBlocks(): - i.queue_free() - #for i in blocks.get_children(): - #if i.get_scale() != Vector2(2,2): - #i.set_scale(Vector2(2,2)) - #i.move(-64,-64) - #var turningPointBlock - #for g in currentPattern.getPositions().size(): - #if not getBlockGroupsList()[GLOBAL.currentUID][g].turningPoint: - #getBlockGroupsList()[GLOBAL.currentUID][g].global_position = currentPattern.getPositions()[g].global_position- Vector2(32,32) - #else: - #turningPointBlock = getBlockGroupsList()[GLOBAL.currentUID][g] - #for g in currentPattern.getPositions(): - #if g.turningPoint: - #turningPointBlock.global_position = g.global_position- Vector2(32,32) - #if i.turningPoint: - #currentPattern.global_position = i.global_position- Vector2(32,32) - - for i in $RowTests.get_children(): - if i.isCompleted(): - for j in i.getRow(): - splitOphansUID(j.UID) - GLOBAL.points += j.type - j.queue_free() - PlacePattern() for i in getBlockGroupsList(): moveUidGroup(GLOBAL.Direction.BOTTOM, i) tickerTimer.start(blockSpeed) stopped = false + + +func _on_game_timer_timeout() -> void: + if GLOBAL.time + 1 > 0: + GLOBAL.time += 1 + #else: + #GLOBAL.lose() + gameTimer.start(1) + + +func _on_coyote_timer_timeout() -> void: + for i in $RowTests.get_children(): + for j in getBlockGroupsList(): + if j != GLOBAL.currentUID: + moveUidGroup(GLOBAL.Direction.BOTTOM, i) + stopped = true + if loseArea.get_overlapping_areas() != []: + GLOBAL.lose() + if currentPattern.expand: + if currentPattern.get_scale() != Vector2(2,2): + for i in getBlockGroupsList()[GLOBAL.currentUID]: + if i.turningPoint: + currentPattern.set_scale(Vector2(2,2)) + currentPattern.moveToPosition(i.global_position-spawnpoint.position - Vector2(64,64*4)) + #if await currentPattern.getCollidingBorder() != []: + for i in await currentPattern.getCollidingBorder(): + if i.is_in_group("Floor"): + currentPattern.position.y -= 64 + elif i.is_in_group("LeftBorder"): + for j in range(1,8): + if await currentPattern.getCollidingBorder() == []: + break + currentPattern.position.x += 64 + elif i.is_in_group("RightBorder"): + for j in range(1,8): + if await currentPattern.getCollidingBorder() == []: + break + currentPattern.position.x -= 64 + #for i in range(1,8): + #print(await currentPattern.getCollidingBorder()) + #if await currentPattern.getCollidingBorder() == []: + #break + #currentPattern.position.x -= 64 + #currentPattern.position.x = 0 + #for i in range(1,8): + #if await currentPattern.getCollidingBorder() == []: + #break + #currentPattern.position.x += 64 + #if await currentPattern.getCollidingBorder() != []: + #currentPattern.position.y += 64 + + #if await currentPattern.getCollidingBorder() != []: + #currentPattern.position.x -= 64 + for i in getBlockGroupsList()[GLOBAL.currentUID].size(): + getBlockGroupsList()[GLOBAL.currentUID][i].global_position = currentPattern.getPositions()[i].global_position - Vector2(GLOBAL.GRID, GLOBAL.GRID) + getBlockGroupsList()[GLOBAL.currentUID][i].set_scale(Vector2(2,2)) + for i in await currentPattern.getCollidingBlocks(): + i.queue_free() + #for i in blocks.get_children(): + #if i.get_scale() != Vector2(2,2): + #i.set_scale(Vector2(2,2)) + #i.move(-64,-64) + #var turningPointBlock + #for g in currentPattern.getPositions().size(): + #if not getBlockGroupsList()[GLOBAL.currentUID][g].turningPoint: + #getBlockGroupsList()[GLOBAL.currentUID][g].global_position = currentPattern.getPositions()[g].global_position- Vector2(32,32) + #else: + #turningPointBlock = getBlockGroupsList()[GLOBAL.currentUID][g] + #for g in currentPattern.getPositions(): + #if g.turningPoint: + #turningPointBlock.global_position = g.global_position- Vector2(32,32) + #if i.turningPoint: + #currentPattern.global_position = i.global_position- Vector2(32,32) + + for i in $RowTests.get_children(): + if i.isCompleted(): + for j in i.getRow(): + splitOphansUID(j.UID) + GLOBAL.points += j.type + j.queue_free() + PlacePattern() diff --git a/scenes/Grid/grid.tscn b/scenes/Grid/grid.tscn index 1948e51..5d5bc9b 100644 --- a/scenes/Grid/grid.tscn +++ b/scenes/Grid/grid.tscn @@ -1,9 +1,19 @@ -[gd_scene load_steps=8 format=3 uid="uid://dwl4lotl1d3ij"] +[gd_scene load_steps=19 format=3 uid="uid://dwl4lotl1d3ij"] [ext_resource type="Script" path="res://scenes/Grid/grid.gd" id="1_vie5m"] [ext_resource type="PackedScene" uid="uid://bm7rshwf6pjb" path="res://scenes/Grid/border.tscn" id="4_3j08q"] [ext_resource type="PackedScene" uid="uid://duubii5uu3lgq" path="res://scenes/Grid/row_test.tscn" id="4_si3v6"] [ext_resource type="PackedScene" uid="uid://dvrotjxom4u6d" path="res://scenes/Grid/bottom.tscn" id="5_14njh"] +[ext_resource type="PackedScene" uid="uid://d2m5xvw4ucwfw" path="res://scenes/Grid/lose_area.tscn" id="5_u5wlg"] +[ext_resource type="Script" path="res://scenes/Grid/camera_2d.gd" id="6_mbeib"] +[ext_resource type="Theme" uid="uid://1nebbd65iyce" path="res://Theme/main.tres" id="7_38u5s"] +[ext_resource type="Script" path="res://scenes/Main/control.gd" id="8_4bfjb"] +[ext_resource type="LabelSettings" uid="uid://cd783ubpcytc8" path="res://Theme/label.tres" id="9_i2h5u"] +[ext_resource type="Texture2D" uid="uid://bfji7a4suq6a1" path="res://assets/Buttons/LeftArrow.png" id="10_vgg21"] +[ext_resource type="Texture2D" uid="uid://dsg7p035f3g52" path="res://assets/Buttons/RightArrow.png" id="11_pa3jp"] +[ext_resource type="Texture2D" uid="uid://ct4dkk00pyv6v" path="res://assets/Buttons/RotationLeft.png" id="12_qk3ju"] +[ext_resource type="Texture2D" uid="uid://5gbnb7gtwww3" path="res://assets/Buttons/RotationRight.png" id="13_kls78"] +[ext_resource type="Texture2D" uid="uid://cevua7g7nsrfj" path="res://assets/Buttons/DownArrow.png" id="14_i1yud"] [sub_resource type="QuadMesh" id="QuadMesh_qfjsc"] @@ -13,6 +23,9 @@ size = Vector2(128, 1536) [sub_resource type="RectangleShape2D" id="RectangleShape2D_rxd0s"] size = Vector2(896, 128) +[sub_resource type="RectangleShape2D" id="RectangleShape2D_m21a1"] +size = Vector2(640, 256) + [node name="Grid" type="Node2D"] script = ExtResource("1_vie5m") @@ -104,19 +117,19 @@ one_shot = true [node name="Borders" type="Node2D" parent="."] -[node name="Border" parent="Borders" instance=ExtResource("4_3j08q")] +[node name="Border" parent="Borders" groups=["LeftBorder"] instance=ExtResource("4_3j08q")] [node name="CollisionShape2D" parent="Borders/Border" index="0"] position = Vector2(-64, 512) shape = SubResource("RectangleShape2D_flipi") -[node name="Border2" parent="Borders" instance=ExtResource("4_3j08q")] +[node name="Border2" parent="Borders" groups=["RightBorder"] instance=ExtResource("4_3j08q")] [node name="CollisionShape2D" parent="Borders/Border2" index="0"] position = Vector2(704, 512) shape = SubResource("RectangleShape2D_flipi") -[node name="Bottom" parent="." instance=ExtResource("5_14njh")] +[node name="Bottom" parent="." groups=["Floor"] instance=ExtResource("5_14njh")] position = Vector2(320, 1312) collision_mask = 2 @@ -124,8 +137,167 @@ collision_mask = 2 position = Vector2(0, 32) shape = SubResource("RectangleShape2D_rxd0s") +[node name="LoseArea" parent="." instance=ExtResource("5_u5wlg")] + +[node name="CollisionShape2D" type="CollisionShape2D" parent="LoseArea"] +position = Vector2(320, -128) +shape = SubResource("RectangleShape2D_m21a1") + +[node name="GameTimer" type="Timer" parent="."] +autostart = true + +[node name="Camera2D" type="Camera2D" parent="."] +position = Vector2(320, 640) +script = ExtResource("6_mbeib") + +[node name="CanvasLayer" type="CanvasLayer" parent="Camera2D"] + +[node name="Control" type="Control" parent="Camera2D/CanvasLayer"] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +theme = ExtResource("7_38u5s") +script = ExtResource("8_4bfjb") + +[node name="HBoxContainer" type="HBoxContainer" parent="Camera2D/CanvasLayer/Control"] +layout_mode = 1 +offset_left = 56.0 +offset_top = 64.0 +offset_right = 320.0 +offset_bottom = 152.0 + +[node name="Score" type="Label" parent="Camera2D/CanvasLayer/Control/HBoxContainer"] +layout_mode = 2 +text = "Score: " +label_settings = ExtResource("9_i2h5u") +horizontal_alignment = 1 +vertical_alignment = 1 + +[node name="ScoreValue" type="Label" parent="Camera2D/CanvasLayer/Control/HBoxContainer"] +layout_mode = 2 +label_settings = ExtResource("9_i2h5u") +horizontal_alignment = 1 + +[node name="HBoxContainer2" type="HBoxContainer" parent="Camera2D/CanvasLayer/Control"] +layout_mode = 1 +anchors_preset = 1 +anchor_left = 1.0 +anchor_right = 1.0 +offset_left = -312.0 +offset_top = 64.0 +offset_right = -56.0 +offset_bottom = 152.0 +grow_horizontal = 0 +alignment = 2 + +[node name="TimeValue" type="Label" parent="Camera2D/CanvasLayer/Control/HBoxContainer2"] +layout_mode = 2 +label_settings = ExtResource("9_i2h5u") +horizontal_alignment = 1 +vertical_alignment = 1 + +[node name="Time" type="Label" parent="Camera2D/CanvasLayer/Control/HBoxContainer2"] +layout_mode = 2 +text = " :Time" +label_settings = ExtResource("9_i2h5u") +horizontal_alignment = 1 +vertical_alignment = 1 + +[node name="HBoxContainer3" type="HBoxContainer" parent="Camera2D/CanvasLayer/Control"] +visible = false +modulate = Color(1, 1, 1, 0.588235) +layout_mode = 1 +anchors_preset = 2 +anchor_top = 1.0 +anchor_bottom = 1.0 +offset_left = 64.0 +offset_top = -240.0 +offset_right = 252.0 +offset_bottom = -148.0 +grow_vertical = 0 +scale = Vector2(2, 2) +alignment = 2 + +[node name="left_Button" type="Button" parent="Camera2D/CanvasLayer/Control/HBoxContainer3"] +layout_mode = 2 +action_mode = 0 +icon = ExtResource("10_vgg21") +icon_alignment = 1 + +[node name="right_Button" type="Button" parent="Camera2D/CanvasLayer/Control/HBoxContainer3"] +layout_mode = 2 +action_mode = 0 +icon = ExtResource("11_pa3jp") +icon_alignment = 1 + +[node name="HBoxContainer4" type="HBoxContainer" parent="Camera2D/CanvasLayer/Control"] +visible = false +modulate = Color(1, 1, 1, 0.588235) +layout_mode = 1 +anchors_preset = 3 +anchor_left = 1.0 +anchor_top = 1.0 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_left = -432.0 +offset_top = -240.0 +offset_right = -244.0 +offset_bottom = -148.0 +grow_horizontal = 0 +grow_vertical = 0 +scale = Vector2(2, 2) + +[node name="rotate_left_Button" type="Button" parent="Camera2D/CanvasLayer/Control/HBoxContainer4"] +layout_mode = 2 +action_mode = 0 +icon = ExtResource("12_qk3ju") +icon_alignment = 1 + +[node name="rotate_right_Button" type="Button" parent="Camera2D/CanvasLayer/Control/HBoxContainer4"] +layout_mode = 2 +action_mode = 0 +icon = ExtResource("13_kls78") +icon_alignment = 1 + +[node name="HBoxContainer5" type="HBoxContainer" parent="Camera2D/CanvasLayer/Control"] +visible = false +modulate = Color(1, 1, 1, 0.588235) +layout_mode = 1 +anchors_preset = 7 +anchor_left = 0.5 +anchor_top = 1.0 +anchor_right = 0.5 +anchor_bottom = 1.0 +offset_left = -92.0 +offset_top = -240.0 +offset_right = 4.0 +offset_bottom = -148.0 +grow_horizontal = 2 +grow_vertical = 0 +scale = Vector2(2, 2) + +[node name="down_Button" type="Button" parent="Camera2D/CanvasLayer/Control/HBoxContainer5"] +layout_mode = 2 +action_mode = 0 +icon = ExtResource("14_i1yud") +icon_alignment = 1 + +[node name="CoyoteTimer" type="Timer" parent="."] +one_shot = true + [connection signal="timeout" from="Ticker" to="." method="_on_ticker_timeout"] [connection signal="timeout" from="TurnTick" to="." method="_on_turn_tick_timeout"] +[connection signal="timeout" from="GameTimer" to="." method="_on_game_timer_timeout"] +[connection signal="pressed" from="Camera2D/CanvasLayer/Control/HBoxContainer3/left_Button" to="Camera2D/CanvasLayer/Control" method="_on_left_button_pressed"] +[connection signal="pressed" from="Camera2D/CanvasLayer/Control/HBoxContainer3/right_Button" to="Camera2D/CanvasLayer/Control" method="_on_right_button_pressed"] +[connection signal="pressed" from="Camera2D/CanvasLayer/Control/HBoxContainer4/rotate_left_Button" to="Camera2D/CanvasLayer/Control" method="_on_rotate_left_button_pressed"] +[connection signal="pressed" from="Camera2D/CanvasLayer/Control/HBoxContainer4/rotate_right_Button" to="Camera2D/CanvasLayer/Control" method="_on_rotate_right_button_pressed"] +[connection signal="button_down" from="Camera2D/CanvasLayer/Control/HBoxContainer5/down_Button" to="Camera2D/CanvasLayer/Control" method="_on_down_button_button_down"] +[connection signal="button_up" from="Camera2D/CanvasLayer/Control/HBoxContainer5/down_Button" to="Camera2D/CanvasLayer/Control" method="_on_down_button_button_up"] +[connection signal="timeout" from="CoyoteTimer" to="." method="_on_coyote_timer_timeout"] [editable path="Borders/Border"] [editable path="Borders/Border2"] diff --git a/scenes/Grid/lose_area.tscn b/scenes/Grid/lose_area.tscn new file mode 100644 index 0000000..c249bd4 --- /dev/null +++ b/scenes/Grid/lose_area.tscn @@ -0,0 +1,5 @@ +[gd_scene format=3 uid="uid://d2m5xvw4ucwfw"] + +[node name="LoseArea" type="Area2D"] +collision_layer = 64 +collision_mask = 2 diff --git a/scenes/Main/control.gd b/scenes/Main/control.gd new file mode 100644 index 0000000..31f31ff --- /dev/null +++ b/scenes/Main/control.gd @@ -0,0 +1,47 @@ +extends Control + +@onready var buttonContainer1 = $HBoxContainer3 +@onready var buttonContainer2 = $HBoxContainer4 +@onready var buttonContainer3 = $HBoxContainer5 +# Called when the node enters the scene tree for the first time. +func _ready() -> void: + print(DisplayServer.mouse_get_position() != Vector2i()) + if DisplayServer.mouse_get_position() == Vector2i(): + buttonContainer1.show() + buttonContainer2.show() + buttonContainer3.show() + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta: float) -> void: + pass + + +func _on_left_button_pressed() -> void: + Input.action_press("left") + Input.action_release("left") + + +func _on_right_button_pressed() -> void: + Input.action_press("right") + Input.action_release("right") + + +func _on_rotate_left_button_pressed() -> void: + Input.action_press("rotate_left") + Input.action_release("rotate_left") + + + +func _on_rotate_right_button_pressed() -> void: + Input.action_press("rotate_right") + Input.action_release("rotate_right") + + + +func _on_down_button_button_down() -> void: + Input.action_press("down") + + +func _on_down_button_button_up() -> void: + Input.action_press("down") + Input.action_release("down") diff --git a/scenes/Main/main.gd b/scenes/Main/main.gd index 7068f02..b489a64 100644 --- a/scenes/Main/main.gd +++ b/scenes/Main/main.gd @@ -1,17 +1,5 @@ extends Node -@onready var gameTimer = $GameTimer -@onready var scoreLabel = $Camera2D/CanvasLayer/Control/HBoxContainer/ScoreValue -@onready var timeLabel = $Camera2D/CanvasLayer/Control/HBoxContainer2/TimeValue - # Called when the node enters the scene tree for the first time. func _ready() -> void: pass # Replace with function body. - -func _physics_process(delta: float) -> void: - scoreLabel.text = str(GLOBAL.points) - timeLabel.text = str(GLOBAL.time) - -func _on_game_timer_timeout() -> void: - GLOBAL.time += 1 - gameTimer.start(1) diff --git a/scenes/Main/main.tscn b/scenes/Main/main.tscn index bee062c..1ef11e0 100644 --- a/scenes/Main/main.tscn +++ b/scenes/Main/main.tscn @@ -1,10 +1,8 @@ -[gd_scene load_steps=6 format=3 uid="uid://bq5hrqgv0f6hp"] +[gd_scene load_steps=4 format=3 uid="uid://bq5hrqgv0f6hp"] [ext_resource type="PackedScene" uid="uid://dwl4lotl1d3ij" path="res://scenes/Grid/grid.tscn" id="1_88eap"] [ext_resource type="Script" path="res://scenes/Main/main.gd" id="1_dtde6"] [ext_resource type="PackedScene" uid="uid://c03h0nwewolfx" path="res://scenes/Grid/SpeedScale.tscn" id="2_mnoeo"] -[ext_resource type="LabelSettings" uid="uid://cd783ubpcytc8" path="res://Theme/label.tres" id="3_jopb4"] -[ext_resource type="Script" path="res://scenes/Main/score_value.gd" id="3_vtvng"] [node name="main" type="Node"] script = ExtResource("1_dtde6") @@ -15,66 +13,3 @@ position = Vector2(128, 256) [node name="Node2D" parent="." instance=ExtResource("2_mnoeo")] visible = false position = Vector2(960, 896) - -[node name="Camera2D" type="Camera2D" parent="."] -position = Vector2(448, 896) - -[node name="CanvasLayer" type="CanvasLayer" parent="Camera2D"] - -[node name="Control" type="Control" parent="Camera2D/CanvasLayer"] -layout_mode = 3 -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -grow_horizontal = 2 -grow_vertical = 2 - -[node name="HBoxContainer" type="HBoxContainer" parent="Camera2D/CanvasLayer/Control"] -layout_mode = 1 -offset_left = 56.0 -offset_top = 64.0 -offset_right = 320.0 -offset_bottom = 152.0 - -[node name="Score" type="Label" parent="Camera2D/CanvasLayer/Control/HBoxContainer"] -layout_mode = 2 -text = "Score: " -label_settings = ExtResource("3_jopb4") -horizontal_alignment = 1 -vertical_alignment = 1 - -[node name="ScoreValue" type="Label" parent="Camera2D/CanvasLayer/Control/HBoxContainer"] -layout_mode = 2 -label_settings = ExtResource("3_jopb4") -horizontal_alignment = 1 -script = ExtResource("3_vtvng") - -[node name="HBoxContainer2" type="HBoxContainer" parent="Camera2D/CanvasLayer/Control"] -layout_mode = 1 -anchors_preset = 1 -anchor_left = 1.0 -anchor_right = 1.0 -offset_left = -312.0 -offset_top = 64.0 -offset_right = -56.0 -offset_bottom = 152.0 -grow_horizontal = 0 -alignment = 2 - -[node name="TimeValue" type="Label" parent="Camera2D/CanvasLayer/Control/HBoxContainer2"] -layout_mode = 2 -label_settings = ExtResource("3_jopb4") -horizontal_alignment = 1 -vertical_alignment = 1 - -[node name="Time" type="Label" parent="Camera2D/CanvasLayer/Control/HBoxContainer2"] -layout_mode = 2 -text = " :Time" -label_settings = ExtResource("3_jopb4") -horizontal_alignment = 1 -vertical_alignment = 1 - -[node name="GameTimer" type="Timer" parent="."] -autostart = true - -[connection signal="timeout" from="GameTimer" to="." method="_on_game_timer_timeout"]