This commit is contained in:
Haze Weathers 2025-03-06 14:22:02 -05:00
parent d77ed8a49f
commit 20f35ab240
5 changed files with 33 additions and 19 deletions

View file

@ -1,23 +1,26 @@
extends Node2D
@export var bounce_power = 240.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
@export var horizontal_boost = 20.0
func _on_area_2d_body_entered(body: Node2D) -> void:
if body is Player:
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
var dir = Vector2(
1.0 if body.velocity.x >= 0.0 else -1.0,
-1.0 if body.velocity.y >= 0.0 else 1.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()
%AnimationPlayer.play("bounce")