#Code Review

4 messages · Page 1 of 1 (latest)

rugged ravine
#

Hi there! I've started to write a player controller script for a 2D Sidescrolling Platformer. Nothing's wrong with it as far as I can tell, but I thought it would be nice to get it reviewed for things like how well named are the varibles and if there is a cleaner implementation

extends CharacterBody2D

##export varibles
@export_category("Physics Properties")
@export var jumpForce : float = 100.0
@export var maxSpeed : float = 100.0
@export var acceleration : float = 100.0
@export var friction : float = 100.0
@export var weight : float = 100.0

@export_category("Camera Properties")
@export var movingCamOffset : float = 0.0

##enum for all the player's states
enum playerStates{standing, running, sprinting, jumping, crouching}

##references to children
@onready var spriteHandle = $SpriteHandle
@onready var hitBox = $HitBox
@onready var audioPlayer = $AudioPlayer
@onready var camera = $PlayerCamera

##misc global varibles


#_physics_process(delta) runs at a fixed rate every cycle

func _physics_process(delta):
    
    var direction : float = Input.get_axis("move_left" , "move_right")
    if direction != 0:
        velocity.x = clamp(velocity.x + direction * acceleration * delta, -maxSpeed, maxSpeed)
    elif direction == 0:    
        velocity.x = direction * max(abs(velocity.x) - friction, 0)
    
    move_and_slide()
mental dust
rugged ravine
#

What on earth is linting?