Added WIP bouncy platform
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
extends CharacterBody2D
|
||||
class_name BoxBoy extends CharacterBody2D
|
||||
|
||||
@onready var _sprite = $AnimatedSprite2D
|
||||
|
||||
@@ -35,6 +35,7 @@ func _physics_process(_delta) -> void:
|
||||
|
||||
#move with a maximum value
|
||||
if move_dir:
|
||||
_sprite.flip_h = move_dir < 0 #fancy
|
||||
velocity.x += MOVE_FORCE * move_dir
|
||||
if abs(velocity.x) > MAX_MOVE_SPEED:
|
||||
velocity.x = MAX_MOVE_SPEED * sign(velocity.x)
|
||||
@@ -43,7 +44,6 @@ func _physics_process(_delta) -> void:
|
||||
elif velocity.x != 0:
|
||||
velocity.x = log(abs(velocity.x)) * sign(velocity.x)
|
||||
|
||||
print(velocity)
|
||||
#do the thing
|
||||
move_and_slide()
|
||||
|
||||
@@ -58,3 +58,7 @@ func _on_animation_finished() -> void:
|
||||
func is_airborne() -> bool: return !is_on_floor()
|
||||
func is_airborne_rising() -> bool: return !is_on_floor() and velocity.y < 0
|
||||
func is_airborne_falling() -> bool: return !is_on_floor() and velocity.y >= 0
|
||||
|
||||
#external actions
|
||||
func apply_bounce() -> void:
|
||||
velocity.y -= JUMP_FORCE
|
||||
|
||||
Reference in New Issue
Block a user