mirror of
https://github.com/JHDev2006/Super-Mario-Bros.-Remastered-Public.git
synced 2025-10-22 23:48:11 +00:00
added the game
This commit is contained in:
20
Scripts/Classes/Components/BasicStaticMovement.gd
Normal file
20
Scripts/Classes/Components/BasicStaticMovement.gd
Normal file
@@ -0,0 +1,20 @@
|
||||
class_name BasicStaticMovement
|
||||
extends Node
|
||||
|
||||
@export var auto_call := true
|
||||
|
||||
@export var visuals: Node2D = null
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
if auto_call:
|
||||
handle_movement(delta)
|
||||
|
||||
func handle_movement(delta: float) -> void:
|
||||
apply_gravity(delta)
|
||||
if owner.is_on_floor():
|
||||
owner.velocity.x = lerpf(owner.velocity.x, 0, delta * 20)
|
||||
owner.move_and_slide()
|
||||
|
||||
func apply_gravity(delta: float) -> void:
|
||||
owner.velocity.y += (Global.entity_gravity / delta) * delta
|
||||
owner.velocity.y = clamp(owner.velocity.y, -INF, Global.entity_max_fall_speed)
|
Reference in New Issue
Block a user