diff --git a/assets/contraption/gateBlock.png b/assets/contraption/gateBlock.png new file mode 100644 index 0000000..f7a77ec Binary files /dev/null and b/assets/contraption/gateBlock.png differ 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 0000000..778bc77 Binary files /dev/null and b/assets/neutral object/gates.aseprite differ diff --git a/src/Actors/Blobby/Blobby.gd b/src/Actors/Blobby/Blobby.gd index 73dc8c1..10c5ec4 100644 --- a/src/Actors/Blobby/Blobby.gd +++ b/src/Actors/Blobby/Blobby.gd @@ -289,8 +289,9 @@ func calculate_jump_velocity( # TODO This is poop too if -max_velocity["jump"].x < velocity.x and direction.x < 0 || \ max_velocity["jump"].x > 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")