diff options
author | Daniel Weipert <code@drogueronin.de> | 2021-01-09 23:30:27 +0100 |
---|---|---|
committer | Daniel Weipert <code@drogueronin.de> | 2021-01-09 23:30:27 +0100 |
commit | 485cd463b22e12394cd232812e2c3789ef37ab1c (patch) | |
tree | 5c455ec9c80b59a9f71ba5827b9902f2beb6df88 /Character.gd | |
parent | 7920e8758506cd46c58ea4889c9f4fb704abfd16 (diff) |
Adds a bunch of characters and fixes things
Diffstat (limited to 'Character.gd')
-rw-r--r-- | Character.gd | 89 |
1 files changed, 0 insertions, 89 deletions
diff --git a/Character.gd b/Character.gd deleted file mode 100644 index 54bfdc5..0000000 --- a/Character.gd +++ /dev/null @@ -1,89 +0,0 @@ -extends KinematicBody2D - - -const SPEED = 130 -const JUMPFORCE = -500 -const GRAVITY = 20 - -var velocity = Vector2() -var direction = Enum.DIRECTION.RIGHT - -var canDoubleJump = false -var hasPlayedFallStop = false - - -func _physics_process(_delta): - if Input.is_action_pressed("ui_left"): - velocity.x = -SPEED - direction = Enum.DIRECTION.LEFT - $Sprite.play("walk") - $Sprite.flip_h = true - - if Input.is_action_pressed("ui_accept"): - velocity.x *=2 - $Sprite.play("slide") - elif Input.is_action_pressed("ui_right"): - velocity.x = SPEED - direction = Enum.DIRECTION.RIGHT - $Sprite.play("walk") - $Sprite.flip_h = false - - if Input.is_action_pressed("ui_accept"): - velocity.x *= 2 - $Sprite.play("slide") - else: - $Sprite.play("idle") - - # jump and fall animation - if not is_on_floor(): - $Sprite.play("jump") - if velocity.y > -JUMPFORCE: - $CheckFallLanding.set_enabled(true) - $CheckFallStop.set_enabled(true) - if $CheckFallLanding.is_colliding(): - $Sprite.play("fall_stop_landing") - elif $CheckFallStop.is_colliding(): - $Sprite.play("fall_stop") - else: - $Sprite.play("fall") - else: - $CheckFallLanding.set_enabled(false) - $CheckFallStop.set_enabled(true) - - - # fall down - velocity.y += GRAVITY - - # jump - if Input.is_action_just_pressed("ui_up"): - if is_on_floor(): - canDoubleJump = true - velocity.y = JUMPFORCE - elif not is_on_floor() and not is_on_wall() and canDoubleJump: - canDoubleJump = false - velocity.y = JUMPFORCE - - if is_on_wall(): - velocity.y *= 0.8 - $Sprite.play("wall") - - if Input.is_action_just_pressed("ui_up"): - Input.action_release("ui_left") - Input.action_release("ui_right") - velocity.y = JUMPFORCE * 0.75 - if direction == Enum.DIRECTION.LEFT: - velocity.x = 2000 - $Sprite.flip_h = false - elif direction == Enum.DIRECTION.RIGHT: - velocity.x = -2000 - $Sprite.flip_h = true - - velocity = move_and_slide(velocity, Vector2.UP) - - # stop - velocity.x = lerp(velocity.x, 0, 0.7) - - -func check_flag(): - # $Sprite.play("dance anim") - print("FLAG CHECKED") |