bonkjj st!

This commit is contained in:
Haze Weathers 2025-11-01 21:25:33 -06:00
parent dd66cc2a84
commit 7d20cb9bcc
4 changed files with 38 additions and 6 deletions

View file

@ -16,3 +16,8 @@ func _physics_process(delta: float) -> void:
velocity += global_position.direction_to(player.global_position) * force * delta
velocity -= velocity * damping * delta
move_and_slide()
func _on_hitbox_body_entered(body: Node2D) -> void:
if body.has_method(&"knock"):
body.knock(global_position.direction_to(body.global_position) * velocity.length())

View file

@ -3,17 +3,18 @@ extends CharacterBody2D
@export var walk_speed: float
@export var stun_factor: float
@export_group("Internal References")
@export var _animations: AnimationPlayer
var is_stunned := false
var stun_time: float = 0.0
func _physics_process(delta: float) -> void:
if is_stunned:
pass
if stun_time > 0.0:
stun_time -= delta
else:
var input_dir = Input.get_vector(&"move_left", &"move_right", &"move_up", &"move_down")
velocity = input_dir * walk_speed
@ -23,3 +24,15 @@ func _physics_process(delta: float) -> void:
_animations.play(&"walk")
move_and_slide()
func knock(force: Vector2) -> void:
velocity = force
stun_time = force.length() / stun_factor
#func _on_hurtbox_body_entered(body: Node2D) -> void:
#if body is Groove:
#var dir = body.global_position.direction_to(global_position)
#velocity = dir * body.velocity.length()
#stun_time = 0.5

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=11 format=3 uid="uid://djpowg53xsgux"]
[gd_scene load_steps=12 format=3 uid="uid://djpowg53xsgux"]
[ext_resource type="Script" uid="uid://by3eww6d7boay" path="res://objects/player/player.gd" id="1_cqmt1"]
[ext_resource type="Texture2D" uid="uid://b0myjj8ggu2gt" path="res://assets/graphics/splint.png" id="2_g7ett"]
@ -6,7 +6,6 @@
[ext_resource type="Texture2D" uid="uid://dgclvsxcplj81" path="res://assets/graphics/groove.png" id="3_ssrue"]
[sub_resource type="CircleShape2D" id="CircleShape2D_cqmt1"]
radius = 12.0
[sub_resource type="Animation" id="Animation_ssrue"]
length = 0.001
@ -67,10 +66,14 @@ _data = {
[sub_resource type="CircleShape2D" id="CircleShape2D_ssrue"]
[node name="Player" type="CharacterBody2D" node_paths=PackedStringArray("_animations")]
[sub_resource type="CircleShape2D" id="CircleShape2D_jnjyq"]
radius = 12.0
[node name="Player" type="CharacterBody2D" node_paths=PackedStringArray("_animations") groups=["knockable"]]
motion_mode = 1
script = ExtResource("1_cqmt1")
walk_speed = 100.0
stun_factor = 200.0
_animations = NodePath("AnimationPlayer")
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
@ -99,3 +102,10 @@ texture = ExtResource("3_ssrue")
[node name="CollisionShape2D" type="CollisionShape2D" parent="Node/Groove"]
shape = SubResource("CircleShape2D_ssrue")
[node name="Hitbox" type="Area2D" parent="Node/Groove"]
[node name="CollisionShape2D" type="CollisionShape2D" parent="Node/Groove/Hitbox"]
shape = SubResource("CircleShape2D_jnjyq")
[connection signal="body_entered" from="Node/Groove/Hitbox" to="Node/Groove" method="_on_hitbox_body_entered"]