Mejoras en el manejo del personaje, enemigo de pruebas
This commit is contained in:
1 parent
1b797a3e90
commit
e93efc533b
21 files changed
+774
-85
No files matched your search
@@ -18,7 +18,7 @@ class_name CharacterData
|
||||
|
||||
@export_category("Stats")
|
||||
@export_range(1, 100, 1) var max_health: int = 5
|
||||
@export var move_speed: float = 300.0
|
||||
@export var move_speed: float = 400.0
|
||||
@export var jump_velocity: float = -600.0
|
||||
@export_range(0, 100, 1) var basic_attack_damage: int = 1
|
||||
@export_range(0, 100, 1) var air_attack_damage: int = 3
|
||||
@@ -9,7 +9,7 @@ id = &"bassist"
|
||||
display_name = "Bassist"
|
||||
sprite_frames = ExtResource("2_frames")
|
||||
max_health = 5
|
||||
move_speed = 300.0
|
||||
move_speed = 400.0
|
||||
jump_velocity = -600.0
|
||||
basic_attack_damage = 1
|
||||
air_attack_damage = 3
|
||||
@@ -9,7 +9,7 @@ id = &"drummer"
|
||||
display_name = "Drummer"
|
||||
sprite_frames = ExtResource("2_frames")
|
||||
max_health = 5
|
||||
move_speed = 300.0
|
||||
move_speed = 400.0
|
||||
jump_velocity = -600.0
|
||||
basic_attack_damage = 1
|
||||
air_attack_damage = 3
|
||||
@@ -9,7 +9,7 @@ id = &"guitarist"
|
||||
display_name = "Guitarist"
|
||||
sprite_frames = ExtResource("2_frames")
|
||||
max_health = 5
|
||||
move_speed = 300.0
|
||||
move_speed = 400.0
|
||||
jump_velocity = -600.0
|
||||
basic_attack_damage = 1
|
||||
air_attack_damage = 3
|
||||
@@ -9,7 +9,7 @@ id = &"singer"
|
||||
display_name = "Singer"
|
||||
sprite_frames = ExtResource("2_frames")
|
||||
max_health = 5
|
||||
move_speed = 300.0
|
||||
move_speed = 400.0
|
||||
jump_velocity = -600.0
|
||||
basic_attack_damage = 1
|
||||
air_attack_damage = 3
|
||||
+27
-5
@@ -32,9 +32,20 @@ const ENEMY_HURTBOX_MASK: int = 1 << 4
|
||||
|
||||
@export_category("Movement")
|
||||
|
||||
@export var ground_acceleration: float = 2200.0
|
||||
@export var ground_friction: float = 2600.0
|
||||
@export var air_acceleration: float = 1000.0
|
||||
## Reaches full running speed quickly, but not instantly.
|
||||
@export var ground_acceleration: float = 3600.0
|
||||
|
||||
## Used when there is no horizontal input. Slightly stronger than acceleration
|
||||
## so releasing the controls feels precise instead of slippery.
|
||||
@export var ground_friction: float = 4800.0
|
||||
|
||||
## Braking used only when the player asks for the opposite direction. The
|
||||
## character loses the old momentum first and then accelerates the other way,
|
||||
## producing a small but readable turn delay.
|
||||
@export var turn_braking: float = 5600.0
|
||||
|
||||
## Air control stays responsive but weaker than movement on the floor.
|
||||
@export var air_acceleration: float = 1800.0
|
||||
|
||||
|
||||
# ============================================================================
|
||||
@@ -212,8 +223,19 @@ func _handle_horizontal_movement(delta: float) -> void:
|
||||
return
|
||||
|
||||
if is_on_floor():
|
||||
var acceleration: float = ground_acceleration if direction != 0.0 else ground_friction
|
||||
velocity.x = move_toward(velocity.x, target_speed, acceleration * delta)
|
||||
if direction == 0.0:
|
||||
velocity.x = move_toward(velocity.x, 0.0, ground_friction * delta)
|
||||
elif velocity.x != 0.0 and signf(velocity.x) != signf(direction):
|
||||
# Do not snap directly from full speed right to full speed left. Brake
|
||||
# the previous momentum first; on the next frames normal acceleration
|
||||
# takes over in the requested direction.
|
||||
velocity.x = move_toward(velocity.x, 0.0, turn_braking * delta)
|
||||
else:
|
||||
velocity.x = move_toward(
|
||||
velocity.x,
|
||||
target_speed,
|
||||
ground_acceleration * delta
|
||||
)
|
||||
else:
|
||||
velocity.x = move_toward(velocity.x, target_speed, air_acceleration * delta)
|
||||
|
||||
|
||||
+5
-2
@@ -1,14 +1,15 @@
|
||||
[gd_scene load_steps=6 format=3 uid="uid://nwbjxttgghpq"]
|
||||
[gd_scene load_steps=7 format=3 uid="uid://nwbjxttgghpq"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://dccfebno1gvh7" path="res://player/player.gd" id="1_player"]
|
||||
[ext_resource type="SpriteFrames" path="res://player/characters/shared/prototype_sprite_frames.tres" id="2_frames"]
|
||||
[ext_resource type="Script" uid="uid://kg3i7b0dj2p8" path="res://player/camera_2d.gd" id="3_camera"]
|
||||
[ext_resource type="Resource" path="res://player/characters/singer.tres" id="4_character"]
|
||||
[ext_resource type="PackedScene" path="res://ui/hud/player_health_hud.tscn" id="5_health_hud"]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="PlayerShape"]
|
||||
size = Vector2(65, 115)
|
||||
|
||||
[node name="Player" type="CharacterBody2D"]
|
||||
[node name="Player" type="CharacterBody2D" groups=["player"]]
|
||||
z_index = 1
|
||||
collision_layer = 2
|
||||
collision_mask = 1
|
||||
@@ -56,3 +57,5 @@ speed_scale = 2.0
|
||||
scale = Vector2(0.5, 0.5)
|
||||
zoom = Vector2(2, 2)
|
||||
script = ExtResource("3_camera")
|
||||
|
||||
[node name="PlayerHealthHUD" parent="." instance=ExtResource("5_health_hud")]
|
||||
Reference in new issue
Block a user