From 0d052e8f5c878709c0868352b85dc0a437b02091 Mon Sep 17 00:00:00 2001 From: Jakob Feldmann Date: Tue, 25 Apr 2023 21:56:50 +0200 Subject: [PATCH] feat: Gate blocks with button, refined jump accel --- assets/contraption/gateBlock.png | Bin 0 -> 190 bytes assets/contraption/gateBlock.png.import | 35 ++++++++ assets/neutral object/gates.aseprite | Bin 0 -> 2031 bytes src/Actors/Blobby/Blobby.gd | 8 +- src/Actors/Blobby/BlobbyStateMachine.gd | 4 +- src/Contraptions/GateBlock.gd | 21 +++++ src/Contraptions/GateBlock.tscn | 18 ++++ src/Contraptions/Triggers/GateButton.gd | 31 +++++++ src/Contraptions/Triggers/GateButton.tscn | 95 ++++++++++++++++++++++ src/Levels/Level 4.tscn | 56 ++++++++++++- src/Utilities/SignalManager.gd | 1 + 11 files changed, 259 insertions(+), 10 deletions(-) create mode 100644 assets/contraption/gateBlock.png create mode 100644 assets/contraption/gateBlock.png.import create mode 100644 assets/neutral object/gates.aseprite create mode 100644 src/Contraptions/GateBlock.gd create mode 100644 src/Contraptions/GateBlock.tscn create mode 100644 src/Contraptions/Triggers/GateButton.gd create mode 100644 src/Contraptions/Triggers/GateButton.tscn diff --git a/assets/contraption/gateBlock.png b/assets/contraption/gateBlock.png new file mode 100644 index 0000000000000000000000000000000000000000..f7a77ec54f1ca42c31a166d14b55ae6ad4dbffe6 GIT binary patch literal 190 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM1|%Pp+x`GjjKx9jP7LeL$-D$|Dm+~rLp(Z@ zFBoq8alV1&!p|ukFK0yjNp}i&$vx0XGeCMbu=wz2X6 zfjjR!;ipDPR|R{RWre%{%LhOCKY4NA3yTf=6g;OSZ(OOIad4`!y2QlHpsT%UCQWI) le-GuEOyZp7`dNXA;l`HOv(@iizXILB;OXk;vd$@?2>{aGM7sb0 literal 0 HcmV?d00001 diff --git a/assets/contraption/gateBlock.png.import b/assets/contraption/gateBlock.png.import new file mode 100644 index 0000000..6f3f2c1 --- /dev/null +++ b/assets/contraption/gateBlock.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/gateBlock.png-d194896fb3570f729d35956d8cac4082.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/contraption/gateBlock.png" +dest_files=[ "res://.import/gateBlock.png-d194896fb3570f729d35956d8cac4082.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=false +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=false +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=false +svg/scale=1.0 diff --git a/assets/neutral object/gates.aseprite b/assets/neutral object/gates.aseprite new file mode 100644 index 0000000000000000000000000000000000000000..778bc771cdc9d814b56168e3cbd3e7d003b8cb93 GIT binary patch literal 2031 zcmb`Idr(wm96&FML(>pW4l3kh@iBuaN<2i7mzat#GAI>f)DQ$DkwkDHO)W-QRs$Va zP+??9C}cnbb6k=~psb-hM<6C&C=&=Ouu`}pvYn5$bo!&ex(sJ7cbEJ4e&_7=8c9-H zj)7#xkA-9)Nm3BMueWr`KpY%-{q@oRZ!d!D4{D4?uF9@7fnOtwkxRaDk&@ApWNwlE z>d2`#UXi3RhNE?oWMXU#=T4dm11zV(;$>5yCP)T{az2N;wo8I+urC2>s}{kB3P<>Z zzcmbTvW1qiNpOwpJa}k}6TF$`0ks25Ve@Tq<^q)iJdh}k_y*30_AWD_*<^EQ~B4R-LV#tJs*x?$Rr>(H-087|58gRT)DKueFg&~%)*%A}c|aL$KHaXg_G zE-8NqclQcvo{DFwZh8q7Sp#rcWIJ5x@imMIQp1cRw_sh~6FAr+-rsXE12!GJ43GJg zz=`80zy60cHV%8)#Ch{ z(qrL@P;pn*&Q5TmnYq|^5NBKdi8y~y{86a5dIg^Ex(9D}_dr!mE0muR&$xM4B3$9K z70$ADfy+I`{`O$8R;SX6Vb!%eu%ojN_H>9DwbzQXmFHB$_}xix{aSx$XCo%=IBO2v zwo=?fYN#CkeC#Z2QmJ5fn>d^1ky!sbb>*-$`y`a_41<1NUeMlhHY`fn1MioQIN5%J zeO;HBd&cX@YYa{xGZvoHuK(x8-2wJIE>g5u|t%#c(JHM zrHg`bUBZ0*bVQrCh}lqlvZV7DnQ}D(<-WKb(Iru`^(D|EAyOd;(jW0r9@)_x!BHEJ zMQ21tVdO(MNh;;Nn}Jr1VlZgLpMZ2G2}ukghC}GLLbCI8Dv2d1VIg?KnFxX z0qBqWh>!IskMGEi>1dAQ2#(#Tjn_zx(ddlJh>XQ3jK9c>xoC^C2+Mk)DxM-KhN35K zviw+ylK6;>n23frh=ACKdU%I)7>91ShGJ3s?cT2_Yck5#*s#|l#Z-Q; zp|St1RhuiEefsm_OjGll&;2@4q0C>pU{6N$&Jy<*+ODXw9W$!3d~fW%^ddU*x~5Z?U$b~s#H&|bFQfW@|s`m-dqz|y?<#{vs2Pjzw?`97b47My7P&>cSD1m zbnANM-Ny%83Z454?$+nsOH3**+jzLTBaDY1^Xg0Q-z#y`woqGt&@ie&n8+j=!O z+^s velocity.x and direction.x > 0: + var movementFactor = (0.3 + abs(velocity.x)/(max_velocity["fall"].x * 1.43 )) linear_velocity.x = PhysicsFunc.two_step_euler( - linear_velocity.x, acceleration_force[state].x * direction.x, + linear_velocity.x, acceleration_force[state].x * movementFactor * direction.x, mass, delta ) @@ -315,8 +316,9 @@ func calculate_fall_velocity( if -max_velocity["fall"].x < velocity.x and direction.x < 0 || \ max_velocity["fall"].x > velocity.x and direction.x > 0: # TODO This is poop + var movementFactor = (0.3 + abs(velocity.x)/(max_velocity["fall"].x * 1.43)) linear_velocity.x = PhysicsFunc.two_step_euler( - linear_velocity.x, acceleration_force[state].x * direction.x, + linear_velocity.x, acceleration_force[state].x * movementFactor * direction.x, mass, delta ) @@ -441,13 +443,11 @@ func _on_BlobbySkin_area_entered(area: Area2D) -> void: if area.is_in_group("pit"): $PitfallTimer.start() - # When the Enemy collision BODY enters the enemy collision area -> die func _on_BlobbySkin_body_entered(body: Node) -> void: if body.is_in_group("harmful") && !levelState.is_dead: die() - # This problem stems from trying to decelerate a walk # that was caused by the moving environment and not by input # It is particularly usefull for moving floor physics diff --git a/src/Actors/Blobby/BlobbyStateMachine.gd b/src/Actors/Blobby/BlobbyStateMachine.gd index 51267b6..159ec30 100644 --- a/src/Actors/Blobby/BlobbyStateMachine.gd +++ b/src/Actors/Blobby/BlobbyStateMachine.gd @@ -138,8 +138,8 @@ func get_horizontal_direction() -> Vector2: func _get_transition(delta): parent.get_node("StateLabel").text = ( self.state - # + " x vel:" - # + String(round(parent.velocity.x)) + + " x vel:" + + String(round(parent.velocity.x)) # + " y vel/10:" # + String(round(parent.velocity.y / 10)) ) diff --git a/src/Contraptions/GateBlock.gd b/src/Contraptions/GateBlock.gd new file mode 100644 index 0000000..8d33c61 --- /dev/null +++ b/src/Contraptions/GateBlock.gd @@ -0,0 +1,21 @@ +extends StaticBody2D + +onready var signalManager := get_tree().root.get_child(1).get_node("%SignalManager") +onready var levelState := get_tree().root.get_child(1).get_node("%LevelState") + +export var locked := true + +# Called when the node enters the scene tree for the first time. +func _ready() -> void: + signalManager.connect("unlocked", self, "unlock") + # if locked: + # $CollisionShape2D.enabled = true + # visible = true + + +func unlock(key: String) -> void: + if key.to_lower() == "gateblock": + $CollisionShape2D.disabled = true + visible = false + + diff --git a/src/Contraptions/GateBlock.tscn b/src/Contraptions/GateBlock.tscn new file mode 100644 index 0000000..b114db2 --- /dev/null +++ b/src/Contraptions/GateBlock.tscn @@ -0,0 +1,18 @@ +[gd_scene load_steps=4 format=2] + +[ext_resource path="res://assets/contraption/gateBlock.png" type="Texture" id=1] +[ext_resource path="res://src/Contraptions/GateBlock.gd" type="Script" id=2] + +[sub_resource type="RectangleShape2D" id=1] +extents = Vector2( 12, 12 ) + +[node name="GateBlock" type="StaticBody2D"] +collision_layer = 8 +collision_mask = 0 +script = ExtResource( 2 ) + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +shape = SubResource( 1 ) + +[node name="Sprite" type="Sprite" parent="."] +texture = ExtResource( 1 ) diff --git a/src/Contraptions/Triggers/GateButton.gd b/src/Contraptions/Triggers/GateButton.gd new file mode 100644 index 0000000..1db5447 --- /dev/null +++ b/src/Contraptions/Triggers/GateButton.gd @@ -0,0 +1,31 @@ +extends Node2D + +onready var activatorArea = $"%ActivatorArea" +onready var indicatorPlayer = $"%IndicatorPlayer" +onready var signalManager := get_tree().root.get_child(1).get_node("%SignalManager") +onready var unactivatable_timer := $Timer + +var activatable = false + +func _process(delta): + if activatable && Input.is_action_just_released("interact"): + selfActivate() + signalManager.emit_signal("unlocked", "gateblock") + + +func selfActivate(): + indicatorPlayer.play("onning") + #TODO dis importante + activatorArea.set_deferred("monitoring", false) + + +func _on_ActivatorArea_area_entered(area:Area2D) -> void: + $Label.visible = true + activatable = true + +func _on_ActivatorArea_area_exited(area:Area2D) -> void: + unactivatable_timer.start() + +func _on_Timer_timeout(): + $Label.visible = false + activatable = false diff --git a/src/Contraptions/Triggers/GateButton.tscn b/src/Contraptions/Triggers/GateButton.tscn new file mode 100644 index 0000000..b4088af --- /dev/null +++ b/src/Contraptions/Triggers/GateButton.tscn @@ -0,0 +1,95 @@ +[gd_scene load_steps=8 format=2] + +[ext_resource path="res://assets/meta/digits.png" type="Texture" id=1] +[ext_resource path="res://assets/contraption/freeButtonSlider.png" type="Texture" id=2] +[ext_resource path="res://assets/contraption/freeButton.png" type="Texture" id=3] +[ext_resource path="res://src/Contraptions/Triggers/GateButton.gd" type="Script" id=4] + +[sub_resource type="Animation" id=19] +length = 0.001 +tracks/0/type = "value" +tracks/0/path = NodePath(".:position") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/keys = { +"times": PoolRealArray( 0 ), +"transitions": PoolRealArray( 1 ), +"update": 0, +"values": [ Vector2( 0, -7 ) ] +} + +[sub_resource type="Animation" id=13] +resource_name = "onning" +length = 0.809 +tracks/0/type = "value" +tracks/0/path = NodePath(".:position") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/keys = { +"times": PoolRealArray( 0, 0.8 ), +"transitions": PoolRealArray( 1, 2.73207 ), +"update": 0, +"values": [ Vector2( 0, -7 ), Vector2( 0, 7 ) ] +} + +[sub_resource type="CircleShape2D" id=18] +radius = 18.0 + +[node name="GateButton" type="Node2D"] +z_index = -1 +script = ExtResource( 4 ) + +[node name="Button" type="Sprite" parent="."] +z_index = -2 +texture = ExtResource( 3 ) +__meta__ = { +"_editor_description_": "YXNlcHJpdGVfd2l6YXJkX2NvbmZpZwpwbGF5ZXJ8PVNwcml0ZS9BbmltYXRpb25QbGF5ZXIKc291cmNlfD1yZXM6Ly9hc3NldHMvbmV1dHJhbCBvYmplY3QvYnV0dG9uLmFzZXByaXRlCmxheWVyfD0Kb3BfZXhwfD1GYWxzZQpvX2ZvbGRlcnw9Cm9fbmFtZXw9Cm9ubHlfdmlzaWJsZXw9RmFsc2UKb19leF9wfD0K" +} + +[node name="Digit" type="Sprite" parent="."] +visible = false +position = Vector2( 0.5, 0.5 ) +texture = ExtResource( 1 ) +hframes = 10 + +[node name="Indicator" type="Sprite" parent="."] +position = Vector2( 0, -7 ) +texture = ExtResource( 2 ) +__meta__ = { +"_editor_description_": "YXNlcHJpdGVfd2l6YXJkX2NvbmZpZwpwbGF5ZXJ8PUluZGljYXRvcjIvQW5pbWF0aW9uUGxheWVyCnNvdXJjZXw9cmVzOi8vYXNzZXRzL25ldXRyYWwgb2JqZWN0L2J1dHRvblN0YXRlSW5kaWNhdG9yLmFzZXByaXRlCmxheWVyfD0Kb3BfZXhwfD1GYWxzZQpvX2ZvbGRlcnw9Cm9fbmFtZXw9Cm9ubHlfdmlzaWJsZXw9RmFsc2UKb19leF9wfD0K" +} + +[node name="IndicatorPlayer" type="AnimationPlayer" parent="Indicator"] +unique_name_in_owner = true +anims/RESET = SubResource( 19 ) +anims/onning = SubResource( 13 ) + +[node name="ActivatorArea" type="Area2D" parent="."] +unique_name_in_owner = true +collision_layer = 32 +monitorable = false + +[node name="ActivatorAreaShape" type="CollisionShape2D" parent="ActivatorArea"] +unique_name_in_owner = true +shape = SubResource( 18 ) + +[node name="Timer" type="Timer" parent="."] +wait_time = 0.333 +one_shot = true + +[node name="Label" type="Label" parent="."] +visible = false +margin_left = -5.0 +margin_top = -26.0 +margin_right = 13.0 +margin_bottom = -12.0 +rect_scale = Vector2( 0.590909, 0.627907 ) +text = "[e]" + +[connection signal="area_entered" from="ActivatorArea" to="." method="_on_ActivatorArea_area_entered"] +[connection signal="area_exited" from="ActivatorArea" to="." method="_on_ActivatorArea_area_exited"] +[connection signal="timeout" from="Timer" to="." method="_on_Timer_timeout"] diff --git a/src/Levels/Level 4.tscn b/src/Levels/Level 4.tscn index d7b3fee..a74c368 100644 --- a/src/Levels/Level 4.tscn +++ b/src/Levels/Level 4.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=26 format=2] +[gd_scene load_steps=28 format=2] [ext_resource path="res://src/Environment/AlienShipTileSet.tres" type="TileSet" id=1] [ext_resource path="res://src/Utilities/SignalManager.tscn" type="PackedScene" id=2] @@ -14,6 +14,8 @@ [ext_resource path="res://src/Levels/Level 4.gd" type="Script" id=12] [ext_resource path="res://src/Platforms/SpringPlatform.tscn" type="PackedScene" id=13] [ext_resource path="res://src/Platforms/DropThroughPlatform.tscn" type="PackedScene" id=14] +[ext_resource path="res://src/Contraptions/GateBlock.tscn" type="PackedScene" id=15] +[ext_resource path="res://src/Contraptions/Triggers/GateButton.tscn" type="PackedScene" id=16] [sub_resource type="AnimationNodeStateMachinePlayback" id=4] @@ -212,18 +214,43 @@ drag_margin_top = 0.13 drag_margin_bottom = 0.3 [node name="AnimatedSprite" parent="BlobbyCam/ParallaxBackground/ParallaxLayer5" index="4"] -frame = 6 +frame = 0 [node name="AnimatedSprite2" parent="BlobbyCam/ParallaxBackground/ParallaxLayer5" index="5"] -frame = 6 +frame = 0 [node name="Blobby" parent="." instance=ExtResource( 8 )] unique_name_in_owner = true -position = Vector2( 924, -483 ) +position = Vector2( 21, -9 ) + +[node name="StateLabel" parent="Blobby" index="0"] +visible = true + +[node name="CollisionPolygon2D" parent="Blobby/BlobbySkin" index="0"] +position = Vector2( 0.0286326, -10.0053 ) + +[node name="BlobbySprite" parent="Blobby" index="3"] +scale = Vector2( -1, 1 ) +frame = 5 [node name="AnimationTree" parent="Blobby/BlobbySprite" index="0"] parameters/playback = SubResource( 4 ) +[node name="BlobbyBody" parent="Blobby" index="8"] +position = Vector2( 0.0392303, -10.002 ) + +[node name="Left_Wallcast1" parent="Blobby/WallRaycasts/LeftWallRaycast" index="0"] +position = Vector2( -11.9763, -5 ) + +[node name="Left_Wallcast2" parent="Blobby/WallRaycasts/LeftWallRaycast" index="1"] +position = Vector2( -11.9763, 5 ) + +[node name="Right_Wallcast1" parent="Blobby/WallRaycasts/RightWallRaycast" index="0"] +position = Vector2( 12.0551, -5 ) + +[node name="Right_Wallcast2" parent="Blobby/WallRaycasts/RightWallRaycast" index="1"] +position = Vector2( 12.0551, 5 ) + [node name="Coin" parent="." instance=ExtResource( 7 )] position = Vector2( 216, -216 ) @@ -317,6 +344,27 @@ frame = 1 anims/RESET = SubResource( 12 ) anims/onning = SubResource( 13 ) +[node name="GateButton" parent="." instance=ExtResource( 16 )] +position = Vector2( 108, -30 ) + +[node name="GateBlock" parent="." instance=ExtResource( 15 )] +position = Vector2( 156, -12 ) + +[node name="GateBlock2" parent="GateBlock" instance=ExtResource( 15 )] +position = Vector2( 0, -24 ) + +[node name="GateBlock3" parent="GateBlock" instance=ExtResource( 15 )] +position = Vector2( 0, -48 ) + +[node name="GateBlock4" parent="GateBlock" instance=ExtResource( 15 )] +position = Vector2( 0, -72 ) + +[node name="GateBlock5" parent="GateBlock" instance=ExtResource( 15 )] +position = Vector2( 0, -96 ) + +[node name="GateBlock6" parent="GateBlock" instance=ExtResource( 15 )] +position = Vector2( 0, -120 ) + [connection signal="ready" from="." to="BoundFrog" method="_on_Level_ready"] [connection signal="body_exited" from="Blobby/BlobbySkin" to="Blobby" method="_on_BlobbySkin_body_exited"] [connection signal="button_pushed" from="FrogFreeButton" to="BoundFrog" method="_on_FrogFreeButton_pushed"] diff --git a/src/Utilities/SignalManager.gd b/src/Utilities/SignalManager.gd index 940d1d9..f5ac496 100644 --- a/src/Utilities/SignalManager.gd +++ b/src/Utilities/SignalManager.gd @@ -10,6 +10,7 @@ signal player_died() signal level_completed() signal power_up_collected(kind) signal got_stomped() +signal unlocked(key) func _on_Timer_timeout() -> void: emit_signal("getback_timer_up")