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