unoragnize to merge

This commit is contained in:
2021-11-29 13:05:00 -06:00
parent 6bf3263115
commit 3a3d987ee3
50 changed files with 1072 additions and 46 deletions

41
Player/Player.gd Normal file
View File

@@ -0,0 +1,41 @@
extends KinematicBody2D
const ACCELERATION = 1000
const MAX_SPEED = 120
const FRICTION = 1000
var velocity: Vector2 = Vector2.ZERO
var isDash = false
var counter = 0
func _physics_process(delta) -> void:
var input_vector: Vector2 = Vector2.ZERO
input_vector.x = Input.get_action_strength('player_right') - Input.get_action_strength('player_left')
input_vector.y = Input.get_action_strength('player_down') - Input.get_action_strength('player_up')
input_vector = input_vector.normalized()
if input_vector != Vector2.ZERO:
$AnimationTree.set('parameters/Idle/blend_position', input_vector)
velocity = velocity.move_toward(input_vector * MAX_SPEED, ACCELERATION * delta)
else:
velocity = velocity.move_toward(Vector2.ZERO, FRICTION * delta)
# if dashing, increase velocity by 4 for one frame
if Input.is_action_just_pressed("player_dash") and input_vector != Vector2.ZERO and isDash == false:
velocity = velocity * 4
isDash = true
# If the dash was previously pressed, start a counter
if isDash:
counter += 1
# wait time before you can dash again
if counter > 60:
counter = 0
isDash = false
velocity = move_and_slide(velocity)
return