From 0fdf6eebba1723f3d05e668d78bdc7669e679486 Mon Sep 17 00:00:00 2001 From: Andrew Lee Date: Fri, 5 Aug 2022 20:27:02 -0400 Subject: Fixed switching scene problem --- game/characters/player/Player.gd | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 game/characters/player/Player.gd (limited to 'game/characters/player/Player.gd') diff --git a/game/characters/player/Player.gd b/game/characters/player/Player.gd new file mode 100644 index 0000000..f764015 --- /dev/null +++ b/game/characters/player/Player.gd @@ -0,0 +1,34 @@ +extends KinematicBody2D + +const UP = Vector2(0,-1) +export var GRAVITY = 20 +export var MAXFALLSPEED = 200 +export var MAXSPEED = 80 +export var JUMPFORCE = 300 +export var ACCEL = 10 + +var motion = Vector2() + +# Called when the node enters the scene tree for the first time. +func _ready(): + pass # Replace with function body. + + +func _physics_process(_delta): + + motion.y += GRAVITY + + if motion.y > MAXFALLSPEED: + motion.y = MAXFALLSPEED + + if is_on_floor(): + if Input.is_action_just_released("jump"): + motion.y = -JUMPFORCE + pass + + motion.x = clamp(motion.x,-MAXSPEED,MAXSPEED) + + motion.x += ACCEL + motion = move_and_slide(motion,UP) + + pass -- cgit v1.2.3