sproing
This commit is contained in:
parent
d77ed8a49f
commit
20f35ab240
5 changed files with 33 additions and 19 deletions
|
@ -85,4 +85,4 @@ scale = Vector2(1.09184, 27.4543)
|
||||||
position = Vector2(96, 176)
|
position = Vector2(96, 176)
|
||||||
|
|
||||||
[node name="Spring2" parent="." instance=ExtResource("9_dtd3x")]
|
[node name="Spring2" parent="." instance=ExtResource("9_dtd3x")]
|
||||||
position = Vector2(80, 88)
|
position = Vector2(96, 88)
|
||||||
|
|
|
@ -49,6 +49,11 @@ func kill() -> void:
|
||||||
state_chart.send_event(&"killed")
|
state_chart.send_event(&"killed")
|
||||||
|
|
||||||
|
|
||||||
|
func launch(impulse: Vector2) -> void:
|
||||||
|
velocity = impulse
|
||||||
|
state_chart.send_event(&"launched")
|
||||||
|
|
||||||
|
|
||||||
#region Idle
|
#region Idle
|
||||||
func _slow_to_stop(delta: float) -> void:
|
func _slow_to_stop(delta: float) -> void:
|
||||||
velocity.x = move_toward(velocity.x, 0.0, stopping_force * delta)
|
velocity.x = move_toward(velocity.x, 0.0, stopping_force * delta)
|
||||||
|
|
|
@ -73,9 +73,9 @@ collision_layer = 16
|
||||||
collision_mask = 3
|
collision_mask = 3
|
||||||
floor_snap_length = 3.0
|
floor_snap_length = 3.0
|
||||||
script = ExtResource("1_xs4s5")
|
script = ExtResource("1_xs4s5")
|
||||||
run_acceleration = 150.0
|
run_acceleration = 200.0
|
||||||
max_run_speed = 100.0
|
max_run_speed = 100.0
|
||||||
turn_acceleration = 250.0
|
turn_acceleration = 300.0
|
||||||
stopping_force = 200.0
|
stopping_force = 200.0
|
||||||
gravity = 450.0
|
gravity = 450.0
|
||||||
jump_power = 180.0
|
jump_power = 180.0
|
||||||
|
@ -157,6 +157,12 @@ to = NodePath("../Grounded")
|
||||||
event = &"killed"
|
event = &"killed"
|
||||||
delay_in_seconds = "0.0"
|
delay_in_seconds = "0.0"
|
||||||
|
|
||||||
|
[node name="on Launched" type="Node" parent="StateChart/Root"]
|
||||||
|
script = ExtResource("7_rgjdc")
|
||||||
|
to = NodePath("../Airborne/Missile")
|
||||||
|
event = &"launched"
|
||||||
|
delay_in_seconds = "0.0"
|
||||||
|
|
||||||
[node name="Grounded" type="Node" parent="StateChart/Root"]
|
[node name="Grounded" type="Node" parent="StateChart/Root"]
|
||||||
editor_description = "Player is standing on a floor."
|
editor_description = "Player is standing on a floor."
|
||||||
script = ExtResource("6_jnxnd")
|
script = ExtResource("6_jnxnd")
|
||||||
|
|
|
@ -1,23 +1,26 @@
|
||||||
extends Node2D
|
extends Node2D
|
||||||
|
|
||||||
@export var bounce_power = 240.0
|
@export var bounce_power = 240.0
|
||||||
|
@export var horizontal_boost = 20.0
|
||||||
# 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:
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
func _on_area_2d_body_entered(body: Node2D) -> void:
|
func _on_area_2d_body_entered(body: Node2D) -> void:
|
||||||
if body is Player:
|
if body is Player:
|
||||||
if body.velocity.y == 0:
|
var dir = Vector2(
|
||||||
body.velocity.x = (body.jump_force * 1.5) * sign(-body.velocity.x)
|
1.0 if body.velocity.x >= 0.0 else -1.0,
|
||||||
else:
|
-1.0 if body.velocity.y >= 0.0 else 1.0,
|
||||||
body.velocity.y = (body.jump_force * 1.5) * sign(-body.velocity.y)
|
)
|
||||||
body.velocity.x += body.graphics.scale.x * 20.0
|
|
||||||
|
body.launch(Vector2(
|
||||||
|
body.velocity.x + (dir.x * horizontal_boost),
|
||||||
|
dir.y * bounce_power
|
||||||
|
))
|
||||||
|
|
||||||
|
#body.velocity.y = bounce_power * signf(-body.velocity.y)
|
||||||
|
#body.velocity.x += signf(body.velocity.x) * 20.0
|
||||||
|
##if body.velocity.y == 0:
|
||||||
|
##body.velocity.x = (body.jump_force * 1.5) * sign(-body.velocity.x)
|
||||||
|
##else:
|
||||||
|
##body.velocity.y = (body.jump_force * 1.5) * sign(-body.velocity.y)
|
||||||
|
##body.velocity.x += body.graphics.scale.x * 20.0
|
||||||
%AudioStreamPlayer.play()
|
%AudioStreamPlayer.play()
|
||||||
%AnimationPlayer.play("bounce")
|
%AnimationPlayer.play("bounce")
|
||||||
|
|
|
@ -55,7 +55,7 @@ hframes = 4
|
||||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
libraries = {
|
libraries = {
|
||||||
"": SubResource("AnimationLibrary_2p5yk")
|
&"": SubResource("AnimationLibrary_2p5yk")
|
||||||
}
|
}
|
||||||
|
|
||||||
[node name="Area2D" type="Area2D" parent="."]
|
[node name="Area2D" type="Area2D" parent="."]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue