diff --git a/graphics/player/palettes/default.tex b/graphics/player/palettes/default.tex index b583807..92edf23 100644 Binary files a/graphics/player/palettes/default.tex and b/graphics/player/palettes/default.tex differ diff --git a/graphics/player/sg.png b/graphics/player/sg.png index 88aaab2..03cd2dc 100644 Binary files a/graphics/player/sg.png and b/graphics/player/sg.png differ diff --git a/objects/player/player.gd b/objects/player/player.gd index 22b8818..9a5c1d9 100644 --- a/objects/player/player.gd +++ b/objects/player/player.gd @@ -35,6 +35,10 @@ export var double_jump_force: float = 122.0 export var underwater = false ## old player controls export var beta_gameplay = false +## upward effect of air dash +export var dash_ascension: float = 50.0 +## side momentum of dash +export var dash_speed: float = 80.0 # velocity var velocity: Vector2 = Vector2.ZERO @@ -70,6 +74,7 @@ onready var edge_detector = $Graphics/EdgeDetector onready var body_shape: CollisionShape2D = $"%BodyShape" onready var cfox: Sprite = $"%CFox" onready var hitbox: Area2D = $"%Hitbox" +onready var shoot_hitbox: Area2D = $"%ShootHitbox" # OVERRIDES # func _ready() -> void: @@ -602,3 +607,29 @@ func _on_ShieldCooldown_timeout(): func _on_BetaFalling_state_entered() -> void: velocity.x = 0.0 + + +func _on_ShootHitbox_area_entered(area: Area2D) -> void: + if area.is_in_group("enemy_hitbox"): + area.get_parent().die() + state_chart.send_event("bounce") + + +func _on_AfterDashFall_state_entered() -> void: + animation_player.play("double_jump") + + +func _on_AirDash_state_entered() -> void: + velocity.x = dash_speed * sign(graphics.scale.x) + velocity.y = -dash_ascension + shoot_hitbox.monitoring = true + animation_player.play("shoot_airborne") + + +func _on_AirDash_state_exited() -> void: + shoot_hitbox.monitoring = false + + +func _process_airdash(delta) -> void: + if abs(velocity.x) < 4.0: + state_chart.send_event("grounded") diff --git a/objects/player/player.tscn b/objects/player/player.tscn index a05b632..a143bfd 100644 --- a/objects/player/player.tscn +++ b/objects/player/player.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=52 format=2] +[gd_scene load_steps=53 format=2] [ext_resource path="res://objects/player/player.gd" type="Script" id=1] [ext_resource path="res://graphics/player/sg_zap.png" type="Texture" id=2] @@ -81,6 +81,9 @@ shader_param/border_color = Color( 0, 0, 0, 1 ) shader_param/border_corners = true shader_param/palette = ExtResource( 12 ) +[sub_resource type="RectangleShape2D" id=35] +extents = Vector2( 8.5, 6.5 ) + [sub_resource type="RectangleShape2D" id=2] extents = Vector2( 2.5, 5 ) @@ -649,7 +652,7 @@ tracks/5/keys = { [sub_resource type="Animation" id=11] resource_name = "shoot_airborne" -length = 0.001 +length = 0.2 tracks/0/type = "value" tracks/0/path = NodePath("Graphics/Sprite:frame") tracks/0/interp = 1 @@ -657,10 +660,10 @@ tracks/0/loop_wrap = true tracks/0/imported = false tracks/0/enabled = true tracks/0/keys = { -"times": PoolRealArray( 0 ), -"transitions": PoolRealArray( 1 ), +"times": PoolRealArray( 0, 0.1 ), +"transitions": PoolRealArray( 1, 1 ), "update": 1, -"values": [ 48 ] +"values": [ 48, 49 ] } tracks/1/type = "value" tracks/1/path = NodePath("Graphics/Sprite:rotation_degrees") @@ -882,6 +885,8 @@ walk_acceleration_frames = 4.0 gravity = 700.0 jump_force = 140.0 double_jump_force = 124.0 +dash_ascension = 124.0 +dash_speed = 124.0 [node name="Graphics" type="Node2D" parent="."] @@ -998,6 +1003,15 @@ material = SubResource( 24 ) position = Vector2( 0, -10 ) texture = ExtResource( 4 ) +[node name="ShootHitbox" type="Area2D" parent="Graphics" groups=["arrow"]] +unique_name_in_owner = true +position = Vector2( 9, -6 ) +collision_mask = 5 + +[node name="CollisionShape2D" type="CollisionShape2D" parent="Graphics/ShootHitbox"] +position = Vector2( -8.5, 0.5 ) +shape = SubResource( 35 ) + [node name="BodyShape" type="CollisionShape2D" parent="."] unique_name_in_owner = true position = Vector2( 0.5, -5 ) @@ -1132,9 +1146,8 @@ initial_state = NodePath("Still") [node name="On Shoot" type="Node" parent="StateChart/Root/Movement/Grounded/CanWalk"] script = ExtResource( 10 ) -to = NodePath("../../Shooting") +to = NodePath("../../../Airborne/AirDash") event = "shoot" -guard_expression = "can_shoot" [node name="On PushStart" type="Node" parent="StateChart/Root/Movement/Grounded/CanWalk"] script = ExtResource( 10 ) @@ -1212,9 +1225,8 @@ event = "duck_released" [node name="On Shoot" type="Node" parent="StateChart/Root/Movement/Grounded/Ducking"] script = ExtResource( 10 ) -to = NodePath("../../Shooting") +to = NodePath("../../../Airborne/AirDash") event = "shoot" -guard_expression = "can_shoot" [node name="On Jump" type="Node" parent="StateChart/Root/Movement/Grounded/Ducking"] script = ExtResource( 10 ) @@ -1265,9 +1277,8 @@ event = "grounded" [node name="On Shoot" type="Node" parent="StateChart/Root/Movement/Airborne"] script = ExtResource( 10 ) -to = NodePath("../AirShooting") +to = NodePath("../AirDash") event = "shoot" -guard_expression = "can_shoot" [node name="On LadderTouched" type="Node" parent="StateChart/Root/Movement/Airborne"] script = ExtResource( 10 ) @@ -1345,9 +1356,17 @@ script = ExtResource( 11 ) [node name="DoubleJump" type="Node" parent="StateChart/Root/Movement/Airborne"] script = ExtResource( 11 ) -[node name="AirShooting" type="Node" parent="StateChart/Root/Movement/Airborne"] +[node name="AfterDashFall" type="Node" parent="StateChart/Root/Movement/Airborne"] script = ExtResource( 11 ) +[node name="AirDash" type="Node" parent="StateChart/Root/Movement/Airborne"] +script = ExtResource( 11 ) + +[node name="On Bounce" type="Node" parent="StateChart/Root/Movement/Airborne/AirDash"] +script = ExtResource( 10 ) +to = NodePath("../../Jump/NormalJump") +event = "bounce" + [node name="Climbing" type="Node" parent="StateChart/Root/Movement"] script = ExtResource( 11 ) __meta__ = { @@ -1539,6 +1558,7 @@ wait_time = 2.0 one_shot = true [connection signal="tree_exited" from="." to="." method="_on_Player_tree_exited"] +[connection signal="area_entered" from="Graphics/ShootHitbox" to="." method="_on_ShootHitbox_area_entered"] [connection signal="body_entered" from="Hitbox" to="." method="_on_Hitbox_body_entered"] [connection signal="state_physics_processing" from="StateChart/Root/Movement" to="." method="_process_movement"] [connection signal="state_entered" from="StateChart/Root/Movement/Grounded" to="." method="_on_Grounded_state_entered"] @@ -1555,8 +1575,8 @@ one_shot = true [connection signal="state_entered" from="StateChart/Root/Movement/Grounded/Shooting" to="." method="_on_Shooting_state_entered"] [connection signal="state_entered" from="StateChart/Root/Movement/Grounded/Pushing" to="." method="_on_Pushing_state_entered"] [connection signal="state_physics_processing" from="StateChart/Root/Movement/Grounded/Pushing" to="." method="_process_pushing"] -[connection signal="state_entered" from="StateChart/Root/Movement/Airborne" to="." method="reset_fall_speed"] [connection signal="state_entered" from="StateChart/Root/Movement/Airborne" to="." method="_on_Airborne_state_entered"] +[connection signal="state_entered" from="StateChart/Root/Movement/Airborne" to="." method="reset_fall_speed"] [connection signal="state_physics_processing" from="StateChart/Root/Movement/Airborne" to="." method="_process_gravity"] [connection signal="state_physics_processing" from="StateChart/Root/Movement/Airborne/Jump" to="." method="_process_horizontal_movement"] [connection signal="state_physics_processing" from="StateChart/Root/Movement/Airborne/Jump" to="." method="_process_jump"] @@ -1570,11 +1590,14 @@ one_shot = true [connection signal="state_entered" from="StateChart/Root/Movement/Airborne/Falling/BetaFalling" to="." method="_on_NormalFalling_state_entered"] [connection signal="state_entered" from="StateChart/Root/Movement/Airborne/Falling/BetaFalling" to="." method="_on_BetaFalling_state_entered"] [connection signal="state_entered" from="StateChart/Root/Movement/Airborne/Falling/ScaredFalling" to="." method="_on_ScaredFalling_state_entered"] -[connection signal="state_entered" from="StateChart/Root/Movement/Airborne/DoubleJump" to="." method="_on_DoubleJump_state_entered"] [connection signal="state_entered" from="StateChart/Root/Movement/Airborne/DoubleJump" to="." method="reset_fall_speed"] +[connection signal="state_entered" from="StateChart/Root/Movement/Airborne/DoubleJump" to="." method="_on_DoubleJump_state_entered"] [connection signal="state_physics_processing" from="StateChart/Root/Movement/Airborne/DoubleJump" to="." method="_process_horizontal_movement"] -[connection signal="state_entered" from="StateChart/Root/Movement/Airborne/AirShooting" to="." method="_on_AirShooting_state_entered"] -[connection signal="state_physics_processing" from="StateChart/Root/Movement/Airborne/AirShooting" to="." method="_process_horizontal_movement"] +[connection signal="state_entered" from="StateChart/Root/Movement/Airborne/AfterDashFall" to="." method="_on_AfterDashFall_state_entered"] +[connection signal="state_physics_processing" from="StateChart/Root/Movement/Airborne/AfterDashFall" to="." method="_process_horizontal_movement"] +[connection signal="state_entered" from="StateChart/Root/Movement/Airborne/AirDash" to="." method="_on_AirDash_state_entered"] +[connection signal="state_exited" from="StateChart/Root/Movement/Airborne/AirDash" to="." method="_on_AirDash_state_exited"] +[connection signal="state_physics_processing" from="StateChart/Root/Movement/Airborne/AirDash" to="." method="_process_airdash"] [connection signal="state_entered" from="StateChart/Root/Movement/Climbing" to="." method="_on_Climbing_state_entered"] [connection signal="state_exited" from="StateChart/Root/Movement/Climbing" to="." method="_on_Climbing_state_exited"] [connection signal="state_physics_processing" from="StateChart/Root/Movement/Climbing" to="." method="_process_climbing"]