aboutsummaryrefslogtreecommitdiff
path: root/game/characters/player/Player.gd
diff options
context:
space:
mode:
Diffstat (limited to 'game/characters/player/Player.gd')
-rw-r--r--game/characters/player/Player.gd18
1 files changed, 13 insertions, 5 deletions
diff --git a/game/characters/player/Player.gd b/game/characters/player/Player.gd
index f764015..ea87926 100644
--- a/game/characters/player/Player.gd
+++ b/game/characters/player/Player.gd
@@ -5,7 +5,7 @@ export var GRAVITY = 20
export var MAXFALLSPEED = 200
export var MAXSPEED = 80
export var JUMPFORCE = 300
-export var ACCEL = 10
+export var ACCEL = 20
var motion = Vector2()
@@ -20,15 +20,23 @@ func _physics_process(_delta):
if motion.y > MAXFALLSPEED:
motion.y = MAXFALLSPEED
+
+ motion.x = clamp(motion.x,-MAXSPEED,MAXSPEED)
+
+ if Input.is_action_pressed("left"):
+ motion.x -= ACCEL
+
+ elif Input.is_action_pressed("right"):
+ motion.x += ACCEL
+ else:
+ motion.x = lerp(motion.x,0,0.2)
if is_on_floor():
- if Input.is_action_just_released("jump"):
+ if Input.is_action_just_pressed("jump"):
motion.y = -JUMPFORCE
pass
-
- motion.x = clamp(motion.x,-MAXSPEED,MAXSPEED)
- motion.x += ACCEL
+
motion = move_and_slide(motion,UP)
pass