chore: snake_case

This commit is contained in:
SondreElg
2025-10-04 14:15:41 +02:00
parent e7cb8e39b3
commit 8e90d87e08

View File

@@ -5,92 +5,95 @@ enum ActionState {None, Deploying, Firing, Charging}
enum MoveState {Still, Moving, Dashing, Loading} enum MoveState {Still, Moving, Dashing, Loading}
@export var speed = 100 # How fast the player will move (pixels/sec). @export var speed = 100 # How fast the player will move (pixels/sec).
@export var dashSpeed = 200 @export var dash_speed = 200
@export var dashEnd = 0.8 @export var dash_end = 0.8
@export var dashCooldown = 0.5 @export var dash_cooldown = 0.5
const drawpile = [];
const hand = [];
const discard_pile = [];
var screen_size # Size of the game window. var screen_size # Size of the game window.
var actionState = ActionState.None var action_state = ActionState.None
var moveState = MoveState.Still var move_state = MoveState.Still
var chargeLevel = 0; var charge_level = 0;
var chargeRate = 1; var charge_rate = 1;
var charged = false; var charged = false;
var dashTime = 0; var dash_timer = 0;
var dashCooldownTime = 0; var dash_cooldown_timer = 0;
var dashOnCooldown = false; var dash_on_cooldown = false;
var dashEaseFactorMinimum = speed / float(dashSpeed) var dash_ease_factor_minimum = speed / float(dash_speed)
var moveDirection = Vector2.ZERO; var move_direction = Vector2.ZERO;
var velocity = Vector2.ZERO # The player's movement vector. var velocity = Vector2.ZERO # The player's movement vector.
func updateMoveDirection(): func update_move_direction():
if Input.is_action_pressed("move_right"): if Input.is_action_pressed("move_right"):
moveDirection.x += 1 move_direction.x += 1
if moveDirection.is_action_pressed("move_left"): if move_direction.is_action_pressed("move_left"):
moveDirection.x -= 1 move_direction.x -= 1
if Input.is_action_pressed("move_down"): if Input.is_action_pressed("move_down"):
moveDirection.y += 1 move_direction.y += 1
if Input.is_action_pressed("move_up"): if Input.is_action_pressed("move_up"):
moveDirection.y -= 1 move_direction.y -= 1
func charge(): func charge():
# Charge attack # Charge attack
if not charged and actionState == ActionState.Charging: if not charged and action_state == ActionState.Charging:
chargeLevel += chargeRate; charge_level += charge_rate;
if chargeLevel >= 100: if charge_level >= 100:
charged = false; charged = false;
chargeLevel = 0; charge_level = 0;
elif chargeLevel > 0: elif charge_level > 0:
# Gradual charge dropoff # Gradual charge dropoff
chargeLevel = max(chargeLevel - chargeRate * 2, 0); charge_level = max(charge_level - charge_rate * 2, 0);
func dash(delta): func dash(delta):
dashTime += delta; dash_timer += delta;
const easeFactor = 1; const easeFactor = 1;
velocity = moveDirection.normalize() * dashSpeed * easeFactor; velocity = move_direction.normalize() * dash_speed * easeFactor;
if (dashTime >= dashEnd): if (dash_timer >= dash_end):
dashOnCooldown = true; dash_on_cooldown = true;
dashTime = 0; dash_timer = 0;
func _ready(): func _ready():
screen_size = get_viewport_rect().size screen_size = get_viewport_rect().size
func _process(delta): func _process(delta):
if (moveState != MoveState.Dashing): if (move_state != MoveState.Dashing):
updateMoveDirection(); update_move_direction();
if (dashOnCooldown): if (dash_on_cooldown):
dashCooldownTime += delta; dash_cooldown_timer += delta;
if (dashCooldownTime >= dashCooldown): if (dash_cooldown_timer >= dash_cooldown):
dashOnCooldown = false; dash_on_cooldown = false;
dashCooldownTime = 0; dash_cooldown_timer = 0;
# handle moveState # handle move_state
if moveState == MoveState.Loading: if move_state == MoveState.Loading:
null pass
# Idk dude, thought it might be a fun effect when you take damage # Idk dude, thought it might be a fun effect when you take damage
elif Input.is_action_pressed("dash") or actionState == MoveState.Dashing: elif Input.is_action_pressed("dash") or action_state == MoveState.Dashing:
moveState = MoveState.Dashing; move_state = MoveState.Dashing;
dash(delta); dash(delta);
else: else:
velocity = moveDirection.normalize() * speed; velocity = move_direction.normalize() * speed;
if velocity.x || velocity.y: if velocity.x || velocity.y:
moveState = MoveState.Moving; move_state = MoveState.Moving;
else: else:
moveState = MoveState.Still; move_state = MoveState.Still;
# Handle action_state
# Handle actionState
if Input.is_action_pressed("deploy"): if Input.is_action_pressed("deploy"):
actionState = ActionState.Deploying; action_state = ActionState.Deploying;
# Deploy # Deploy
elif Input.is_action_pressed("fire"): elif Input.is_action_pressed("fire"):
actionState = ActionState.Firing; action_state = ActionState.Firing;
# Fire # Fire
elif Input.is_action_pressed("charge"): elif Input.is_action_pressed("charge"):
actionState = ActionState.Charging; action_state = ActionState.Charging;
charge(); charge();