Coin I guess
This commit is contained in:
1 parent
dc11398846
commit
a73609b86b
31 files changed
+488
-46
No files matched your search
+27
-6
@@ -1,14 +1,19 @@
|
||||
extends CharacterBody2D
|
||||
|
||||
const SPEED = 380.0
|
||||
|
||||
const DASH_SPEED = 600
|
||||
const FRICTION = 100
|
||||
const GRAVITY_MULT = 0.8
|
||||
|
||||
const JUMP_VELOCITY = -410.0
|
||||
|
||||
const DASH_LENGTH = 0.2
|
||||
|
||||
var fall_timer = 0.0
|
||||
var teleport_cooldown = 0
|
||||
var jumps = 0
|
||||
var dashes = 1
|
||||
var dashing = false
|
||||
var death_threshold = 1000
|
||||
var coins = 0
|
||||
|
||||
@@ -27,6 +32,9 @@ func on_teleport():
|
||||
$Camera2D.position_smoothing_enabled = true
|
||||
await get_tree().create_timer(1).timeout
|
||||
teleport_cooldown = 0
|
||||
|
||||
func on_death():
|
||||
position = %LevelStart.position
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if Input.is_action_just_pressed("jump"):
|
||||
@@ -42,20 +50,33 @@ func _process(delta: float) -> void:
|
||||
#velocity.x = 0
|
||||
|
||||
var direction = Input.get_axis("move_left","move_right")
|
||||
|
||||
if direction < 0:
|
||||
$Sprite2D.flip_h = true
|
||||
elif direction > 0:
|
||||
$Sprite2D.flip_h = false
|
||||
|
||||
if direction:
|
||||
|
||||
if Input.is_action_just_pressed("dash"):
|
||||
dashing = true
|
||||
velocity = Vector2(
|
||||
Input.get_axis("dash_left","dash_right"),
|
||||
Input.get_axis("dash_up","dash_down")
|
||||
) * DASH_SPEED
|
||||
await get_tree().create_timer(DASH_LENGTH).timeout
|
||||
dashing = false
|
||||
|
||||
elif direction and !dashing:
|
||||
velocity.x = direction * SPEED
|
||||
else:
|
||||
velocity.x = move_toward(velocity.x, 0, SPEED)
|
||||
$Sprite2D.play("running")
|
||||
|
||||
elif !dashing:
|
||||
velocity.x = move_toward(velocity.x, 0, FRICTION)
|
||||
$Sprite2D.play("idle")
|
||||
|
||||
#print("PLAYER X POSITION: " + str(position.y))
|
||||
if position.y >= death_threshold:
|
||||
print("SLASH KILL")
|
||||
get_tree().reload_current_scene()
|
||||
on_death()
|
||||
|
||||
fall_timer += 1*delta
|
||||
if is_on_floor():
|
||||
|
||||
Reference in new issue
Block a user