From 99d5016ac2bd0dcde73aad86d627b070732da1ed Mon Sep 17 00:00:00 2001 From: Exobyt Date: Fri, 20 Sep 2024 22:46:27 +0200 Subject: [PATCH] Test --- icon.png | Bin 0 -> 1852 bytes icon.png.import | 2 +- project.godot | 10 +++- scenes/Globals/global.gd | 4 +- scenes/Grid/row_test.gd | 51 +++++++++++------ scenes/Grid/row_test.tscn | 72 ++++-------------------- scenes/NewBlocks/block.gd | 111 ++++++++++++++++++++++++++----------- scenes/NewBlocks/part.gd | 33 ++++++++--- scenes/NewBlocks/part.tscn | 37 ++++--------- 9 files changed, 171 insertions(+), 149 deletions(-) create mode 100644 icon.png diff --git a/icon.png b/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..a84bf2b6688ece99f224e45e068db444905d0fc0 GIT binary patch literal 1852 zcmb7FX*ipS7XFe(ltE0@S~Ely;})%`rIFaHR8etJF+$bWK~kZX5kiY;Embwd)Y2)s z8C8wgC5S3TRke1a!o(U&5~QfnyFB+#f6V=Hmgk&5@B6&xIqywpM_Wm8C2;@%B<;>x zyX;r;mpBOB&rGy$_kIy0oV`c{04e5|0KLLLzPvwFjIi;Dz~BQSqI|>sfvBh`-QcjF zhYB(a{H(uvo%YLt`ZcsxXddHo& zxzuOx_DfZD`4!e?{Xk>jCJMPyLJf@CINM?JD*myn_Q*3G(hzYYommKc56T2nw@;G~ z$)BInSjAtjKSWt=w({NeqIn87snnP(;1!*;-U;V4gPNpr&TyY)Ln05XT&qC-yu0vH zu=in=4pv5PSfVj=O}+)flg_`CG(6LwyVbYQMBV{9uv?ZlkqPYv9IjJ)7Z>T4eM)Gb6iGLxVUB+tRI~ z-mKo>wShB+?n=rcx1wozI=ZGZ8E!e~y zQ$NM%X^sFUV}ENHgAJ5Fz8Yi@fYNK#{lV_ivUz9*_PIGL-AUzBX&#)WbA^^%0zPOf zBAqF&sw``6tW74k0v{g(Z5Kc{zP_;Q-Nq3!&gTxfb47+!$7CY~If7i2R6sBIHROoX~aPTQ4;i1gpw|wM73PuwP-} z0w*JK)mi|Nk3`$QN5eOLJ49aYHFmX#)n1e~d& z-@}=+FGpKEuNIk^ZL4L_{<&VIC#6Gmx%j{kDSs}r)GiqyxF-=carqHO4>Mi8z&Y0u zHQ)NYTjZ5-%(VRe)2Sp^@gx5=QxQ;(BIX6ccf8we9uNxuQ{24J7L}`}@V7+x3a@|5 zrkDoY^)A*!?P;aYYW=sfA=_2<fKqRVIDpxC9x#$ zOW(O<`{P3=Qch74&RC7bBfnhai$^sbUR8-=thA0ehK++BOi&tn1 zSaMM$9@NOTQs6(vPeS>gS4K7)m^3%4Vck6b8FKT@ z8&S3z<}+I}SA~kwB_ow4m{i5}GLvfk}TvhoJVutCF^#Kz^JSz>%K zV6`1{PE&Hjsikdda*)><5SZUJyA}dnjG>&Yz_?4L5aGVk(hyY5t|6VJ{K;Ubg#-Tx zL+@S|xZvWP0rIP2G%ZU^h@x=Viw)VT<%WFkAF+)DKLYb@<%*zOeyDMIyxVvZ9v*ey z;k)xE@Qq=@WZ##m+v&gsZYK24^HY)LnxFxTUY|)x{ep@7W!7y`@#j`$E?pa5LRt2j zl`;#oZxSGC$)>wvB9tIAE^o|(iLUeo?80<$^rq(GLI${lKmAbi@Yuc$0)U;3qxCaO HpQOJ4eU)nn literal 0 HcmV?d00001 diff --git a/icon.png.import b/icon.png.import index bd87d5f..7f73e7f 100644 --- a/icon.png.import +++ b/icon.png.import @@ -16,9 +16,9 @@ dest_files=["res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.cte [params] compress/mode=0 +compress/high_quality=false compress/lossy_quality=0.7 compress/hdr_compression=1 -compress/bptc_ldr=0 compress/normal_map=0 compress/channel_pack=0 mipmaps/generate=false diff --git a/project.godot b/project.godot index d1e2035..8a068f5 100644 --- a/project.godot +++ b/project.godot @@ -12,7 +12,7 @@ config_version=5 config/name="Texpand" config/description="Tetris with special Blocks that expands" -config/version="2.0.0" +config/version="2.0.1" config/tags=PackedStringArray("game_jam") run/main_scene="res://scenes/Main/main.tscn" config/features=PackedStringArray("4.3", "GL Compatibility") @@ -24,8 +24,8 @@ boot_splash/minimum_display_time=1 [autoload] -DebugMenu="*res://addons/debug_menu/debug_menu.tscn" GLOBAL="*res://scenes/Globals/global.gd" +DebugMenu="*res://addons/debug_menu/debug_menu.tscn" [display] @@ -44,11 +44,17 @@ version_control/autoload_on_startup=true enabled=PackedStringArray("res://addons/debug_menu/plugin.cfg") +[github_to_itch] + +config/itch_username="Exobyt" +config/itch_project_name="" + [global_group] Block="Block" ExpandBlock="" Border="" +Part="" [input] diff --git a/scenes/Globals/global.gd b/scenes/Globals/global.gd index 62f0804..1e0ef62 100644 --- a/scenes/Globals/global.gd +++ b/scenes/Globals/global.gd @@ -4,7 +4,7 @@ var points = 0 enum SPEED {MIN=20, MAX=80} -var currentSpeed := SPEED.MIN +var currentSpeed = SPEED.MIN var hasSelectedSpeed = false @@ -85,6 +85,6 @@ func convertIntToTime(value) -> String: func speedUp(): if currentSpeed + 1 <= SPEED.MAX: - currentSpeed += 1 + currentSpeed += 0.5 else: currentSpeed = SPEED.MAX diff --git a/scenes/Grid/row_test.gd b/scenes/Grid/row_test.gd index c1f1199..cd87452 100644 --- a/scenes/Grid/row_test.gd +++ b/scenes/Grid/row_test.gd @@ -1,15 +1,19 @@ -extends Node2D +extends Area2D static var rowRemoved = false func isFull(): - var full = true - for i in get_children(): - i.force_raycast_update() - #print(i.get_collider()) - if not i.is_colliding(): - full = false - return full + var amount = 0 + for i in get_overlapping_areas(): + if i.is_in_group("Part"): + if i.get_parent().get_parent().expand: + amount += 2 + else: + amount += 1 + if amount >= 10: + return true + else: + return false func check(): if not GLOBAL.rowRemoved: @@ -18,16 +22,29 @@ func check(): GLOBAL.rowRemoved = true var blocksSplit = [] var removeBlock = [] - for i in get_children(): - i.force_raycast_update() - if i.get_collider() != null: - blocksSplit.append(i.get_collider().get_parent().get_parent()) + for i in get_overlapping_areas(): + if i.is_in_group("Part"): + var block = i.get_parent().get_parent() + blocksSplit.append(block) + i.free() if GLOBAL.currentMode == GLOBAL.MODES.TIME: - GLOBAL.time += i.get_collider().get_parent().get_parent().type - if i.get_collider().get_parent().get_parent().expand: - GLOBAL.points += i.get_collider().get_parent().get_parent().type * 2 + GLOBAL.time += block.type + if block.expand: + GLOBAL.points += block.type * 2 else: - GLOBAL.points += i.get_collider().get_parent().get_parent().type - i.get_collider().free() + GLOBAL.points += block.type for j in blocksSplit: j.splitParts() + #for i in get_children(): + #i.force_raycast_update() + #if i.get_collider() != null: + #blocksSplit.append(i.get_collider().get_parent().get_parent()) + #if GLOBAL.currentMode == GLOBAL.MODES.TIME: + #GLOBAL.time += i.get_collider().get_parent().get_parent().type + #if i.get_collider().get_parent().get_parent().expand: + #GLOBAL.points += i.get_collider().get_parent().get_parent().type * 2 + #else: + #GLOBAL.points += i.get_collider().get_parent().get_parent().type + #i.get_collider().free() + #for j in blocksSplit: + #j.splitParts() diff --git a/scenes/Grid/row_test.tscn b/scenes/Grid/row_test.tscn index 598270f..aab5caa 100644 --- a/scenes/Grid/row_test.tscn +++ b/scenes/Grid/row_test.tscn @@ -1,66 +1,16 @@ -[gd_scene load_steps=2 format=3 uid="uid://ibyhtfpc52vc"] +[gd_scene load_steps=3 format=3 uid="uid://ibyhtfpc52vc"] [ext_resource type="Script" path="res://scenes/Grid/row_test.gd" id="1_2nxxe"] -[node name="RowTest" type="Node2D"] +[sub_resource type="RectangleShape2D" id="RectangleShape2D_t04sr"] +size = Vector2(624, 48) + +[node name="RowTest" type="Area2D"] +collision_layer = 16 +collision_mask = 8 +input_pickable = false script = ExtResource("1_2nxxe") -[node name="RayCast2D" type="RayCast2D" parent="."] -position = Vector2(32, 24) -target_position = Vector2(0, 16) -collision_mask = 24 -hit_from_inside = true - -[node name="RayCast2D2" type="RayCast2D" parent="."] -position = Vector2(96, 24) -target_position = Vector2(0, 16) -collision_mask = 24 -hit_from_inside = true - -[node name="RayCast2D3" type="RayCast2D" parent="."] -position = Vector2(160, 24) -target_position = Vector2(0, 16) -collision_mask = 24 -hit_from_inside = true - -[node name="RayCast2D4" type="RayCast2D" parent="."] -position = Vector2(224, 24) -target_position = Vector2(0, 16) -collision_mask = 24 -hit_from_inside = true - -[node name="RayCast2D5" type="RayCast2D" parent="."] -position = Vector2(288, 24) -target_position = Vector2(0, 16) -collision_mask = 24 -hit_from_inside = true - -[node name="RayCast2D6" type="RayCast2D" parent="."] -position = Vector2(352, 24) -target_position = Vector2(0, 16) -collision_mask = 24 -hit_from_inside = true - -[node name="RayCast2D7" type="RayCast2D" parent="."] -position = Vector2(416, 24) -target_position = Vector2(0, 16) -collision_mask = 24 -hit_from_inside = true - -[node name="RayCast2D8" type="RayCast2D" parent="."] -position = Vector2(480, 24) -target_position = Vector2(0, 16) -collision_mask = 24 -hit_from_inside = true - -[node name="RayCast2D9" type="RayCast2D" parent="."] -position = Vector2(544, 24) -target_position = Vector2(0, 16) -collision_mask = 24 -hit_from_inside = true - -[node name="RayCast2D10" type="RayCast2D" parent="."] -position = Vector2(608, 24) -target_position = Vector2(0, 16) -collision_mask = 24 -hit_from_inside = true +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +position = Vector2(320, 32) +shape = SubResource("RectangleShape2D_t04sr") diff --git a/scenes/NewBlocks/block.gd b/scenes/NewBlocks/block.gd index 5e5979d..e0084d0 100644 --- a/scenes/NewBlocks/block.gd +++ b/scenes/NewBlocks/block.gd @@ -38,18 +38,49 @@ func _physics_process(delta: float) -> void: elif Input.is_action_just_pressed("right"): if not isRightColliding(): global_position.x += GLOBAL.GRID - if Input.is_action_pressed("down"): - velocity = get_gravity() * delta * GLOBAL.SPEED.MAX - else: - velocity = get_gravity() * delta * GLOBAL.currentSpeed + else: + if stopped and not isBottomColliding(): + position.y += GLOBAL.GRID + snapPosition() + if Input.is_action_pressed("down") and isCurrent(): + velocity = get_gravity() * delta * GLOBAL.SPEED.MAX + else: + velocity = get_gravity() * delta * GLOBAL.currentSpeed + #if isBottomColliding(): + #print(global_position) + #print(global_position.snapped(Vector2(64,64))) + #print(global_position.snapped(Vector2(64,64)) - Vector2(32,32)) + #print(int((global_position.snapped(Vector2(64,64)) - Vector2(32,32)).y)) + #print(int((global_position.snapped(Vector2(64,64)) - Vector2(32,32)).x)) + #print(int(global_position.x-32) % GLOBAL.GRID) + #print(int(global_position.y-32) % GLOBAL.GRID) + #print(name + ": " + str(not isBottomColliding() and not isCurrent())) + #print(global_position) + #print(int(global_position.x-32) % GLOBAL.GRID) + #print(int(global_position.y-32) % GLOBAL.GRID) + #if isBottomColliding(): + # + #if not int(global_position.x-32) % GLOBAL.GRID == 0: + #global_position.x = global_position.snapped(Vector2(64,64)).x -32 + #if not int(global_position.y-32) % GLOBAL.GRID == 0: + #global_position.y = global_position.snapped(Vector2(64,64)).y -32 + #global_position = global_position.snapped(Vector2(64,64)) + + #position.y += GLOBAL.GRID - if is_on_floor(): - position = position.snapped(Vector2(32,32)) + #if is_on_floor(): + #position = position.snapped(Vector2(32,32)) + #if not is_on_floor() and not isCurrent() and not isBottomColliding(): + #position += Vector2(0,64) + #print(not isBottomColliding()) + #if stopped and not isBottomColliding(): + #position += Vector2(0,64) if isCurrent() and not expanding and not GLOBAL.blockStopped: move_and_slide() else: + velocity = Vector2.ZERO func expandBlocks(): @@ -77,10 +108,10 @@ func expandBlocks(): position.x += GLOBAL.GRID if isCollidingBorder(): position.y -= GLOBAL.GRID - + for i in partsContainer.get_children(): - if i != null: - i.removeOverlapp() + #print(i) + i.removeOverlapp() #splitParts() func addParts(): @@ -96,31 +127,11 @@ func addParts(): look = 3 newPart.init(i.position,look) -func splitParts(): - for i in $PartsContainer.get_children(): - var newBlock = load(block1x1).instantiate() - get_parent().add_child(newBlock) - newBlock.init(i.global_position, expand) - newBlock.setColor(modulate) - queue_free() + func setColor(color): modulate = color -func init(pos, scaler=null): - - if scaler != null: - if scaler: - expand = scaler - #$AnimationPlayer.play("Expand") - scale = Vector2(2,2) - addParts() - id = GLOBAL.getNewID() - GLOBAL.currentID = id - snapPosition() - global_position = pos - if offset: - snapPosition() func setNewID(): id = GLOBAL.getNewID() @@ -129,7 +140,11 @@ func isCurrent(): return GLOBAL.currentID == id func snapPosition(): #x :bool, y: bool - position = position.snapped(Vector2(64,64)) + if not offset and not expand: + global_position = global_position.snapped(Vector2(64,64)) - Vector2(32,32) + else: + global_position = global_position.snapped(Vector2(64,64)) + #position = position.snapped(Vector2(64,64)) func rotateBlock(direction): match direction: @@ -232,7 +247,41 @@ func _on_animation_player_animation_finished(anim_name: StringName) -> void: func _on_coyote_timer_timeout() -> void: if isBottomColliding(): + snapPosition() stopped = true GLOBAL.blockStopped = true if expand: expandBlocks() + +func init(pos): + if expand and stopped: + #$AnimationPlayer.play("Expand") + scale = Vector2(2,2) + addParts() + id = GLOBAL.getNewID() + GLOBAL.currentID = id + snapPosition() + global_position = pos + if offset: + snapPosition() + + +func splitParts(): + for i in $PartsContainer.get_children(): + var newBlock = load(block1x1).instantiate() + get_parent().add_child(newBlock) + newBlock.clone(expand, type, stopped) + newBlock.init(i.global_position) + newBlock.setColor(modulate) + queue_free() + +func clone(newExpand=false, newType=GLOBAL.BLOCKTYPES.LIGHT, newStopped=false): + expand = newExpand + stopped = newStopped + type = newType + #if not expand and type == GLOBAL.BLOCKTYPES.HEAVY: + #look = 1 + #elif expand and not type == GLOBAL.BLOCKTYPES.HEAVY: + #look = 2 + #elif expand and type == GLOBAL.BLOCKTYPES.HEAVY: + #look = 3 diff --git a/scenes/NewBlocks/part.gd b/scenes/NewBlocks/part.gd index 44191b7..cceeab4 100644 --- a/scenes/NewBlocks/part.gd +++ b/scenes/NewBlocks/part.gd @@ -1,4 +1,4 @@ -extends Node2D +extends Area2D @onready var spriteBlock = $Sprites/Block @onready var spriteSpecialBlock = $Sprites/SpecialBlock @@ -27,15 +27,32 @@ func isOverlapping() -> bool: func removeOverlapp(): var blocksSplit = [] - for i in get_children(): - if is_instance_of(i,RayCast2D): - i.force_raycast_update() - var collider = i.get_collider() - if collider != null and collider.get_parent().get_parent().id != GLOBAL.currentID: - blocksSplit.append(i.get_collider().get_parent().get_parent()) - collider.free() + var removeBlock = [] + for i in $Area2D.get_overlapping_areas(): + + + if i.is_in_group("Part") and i.get_parent().get_parent().id != GLOBAL.currentID: + print(i) + var block = i.get_parent().get_parent() + blocksSplit.append(block) + i.free() + #if GLOBAL.currentMode == GLOBAL.MODES.TIME: + #GLOBAL.time += block.type + #if block.expand: + #GLOBAL.points += block.type * 2 + #else: + #GLOBAL.points += block.type for j in blocksSplit: j.splitParts() + #for i in get_children(): + #if is_instance_of(i,RayCast2D): + #i.force_raycast_update() + #var collider = i.get_collider() + #if collider != null and collider.get_parent().get_parent().id != GLOBAL.currentID: + #blocksSplit.append(i.get_collider().get_parent().get_parent()) + #collider.free() + #for j in blocksSplit: + #j.splitParts() func init(pos, look=0): position = pos diff --git a/scenes/NewBlocks/part.tscn b/scenes/NewBlocks/part.tscn index 8928829..dc33cda 100644 --- a/scenes/NewBlocks/part.tscn +++ b/scenes/NewBlocks/part.tscn @@ -9,35 +9,11 @@ [sub_resource type="RectangleShape2D" id="RectangleShape2D_ix7xn"] size = Vector2(48, 48) -[node name="Part" type="StaticBody2D"] -collision_layer = 24 -collision_mask = 24 +[node name="Part" type="Area2D" groups=["Part"]] +collision_layer = 8 +collision_mask = 16 script = ExtResource("1_hlmu7") -[node name="Overlap Test" type="RayCast2D" parent="."] -position = Vector2(-16, -16) -target_position = Vector2(8, 0) -collision_mask = 24 -hit_from_inside = true - -[node name="Overlap Test2" type="RayCast2D" parent="."] -position = Vector2(-16, 16) -target_position = Vector2(8, 0) -collision_mask = 24 -hit_from_inside = true - -[node name="Overlap Test3" type="RayCast2D" parent="."] -position = Vector2(16, -16) -target_position = Vector2(-8, 0) -collision_mask = 24 -hit_from_inside = true - -[node name="Overlap Test4" type="RayCast2D" parent="."] -position = Vector2(16, 16) -target_position = Vector2(-8, 0) -collision_mask = 24 -hit_from_inside = true - [node name="CollisionShape2D" type="CollisionShape2D" parent="."] shape = SubResource("RectangleShape2D_ix7xn") @@ -84,3 +60,10 @@ position = Vector2(-32, 0) target_position = Vector2(0, 0) collision_mask = 3 hit_from_inside = true + +[node name="Area2D" type="Area2D" parent="."] +collision_layer = 16 +collision_mask = 8 + +[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"] +shape = SubResource("RectangleShape2D_ix7xn")