adjusted springs and player physics
This commit is contained in:
parent
58807ec142
commit
cbbf55a48a
4 changed files with 38 additions and 20 deletions
|
@ -49,9 +49,9 @@ expression = "player.velocity.y >= 0.0"
|
|||
[node name="Player" type="CharacterBody2D" node_paths=PackedStringArray("state_chart", "graphics")]
|
||||
floor_snap_length = 3.0
|
||||
script = ExtResource("1_jgave")
|
||||
gravity = 200.0
|
||||
run_speed = 64.0
|
||||
jump_force = 120.0
|
||||
gravity = 400.0
|
||||
run_speed = 76.0
|
||||
jump_force = 150.0
|
||||
state_chart = NodePath("StateChart")
|
||||
graphics = NodePath("Graphics")
|
||||
|
||||
|
|
|
@ -14,5 +14,9 @@ func _process(delta: float) -> void:
|
|||
|
||||
func _on_area_2d_body_entered(body: Node2D) -> void:
|
||||
if body is Player:
|
||||
body.velocity.y = -bounce_power
|
||||
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
|
||||
%AnimationPlayer.play("bounce")
|
||||
|
|
|
@ -3,6 +3,21 @@
|
|||
[ext_resource type="Script" path="res://objects/spring/spring.gd" id="1_05bif"]
|
||||
[ext_resource type="Texture2D" uid="uid://bobpl8pwm216q" path="res://assets/textures/spring/spring.png" id="1_s1olr"]
|
||||
|
||||
[sub_resource type="Animation" id="Animation_pa4d8"]
|
||||
length = 0.001
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("Sprite2D:frame")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 1,
|
||||
"values": [0]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_8kq4q"]
|
||||
resource_name = "bounce"
|
||||
length = 0.3
|
||||
|
@ -19,21 +34,6 @@ tracks/0/keys = {
|
|||
"values": [1, 2, 3, 2, 0]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_pa4d8"]
|
||||
length = 0.001
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("Sprite2D:frame")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 1,
|
||||
"values": [0]
|
||||
}
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_2p5yk"]
|
||||
_data = {
|
||||
"RESET": SubResource("Animation_pa4d8"),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue