diff options
Diffstat (limited to 'Racing-Game/KinematicBody2D.gd')
| -rw-r--r-- | Racing-Game/KinematicBody2D.gd | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/Racing-Game/KinematicBody2D.gd b/Racing-Game/KinematicBody2D.gd new file mode 100644 index 0000000..e024ffc --- /dev/null +++ b/Racing-Game/KinematicBody2D.gd @@ -0,0 +1,21 @@ +extends KinematicBody2D + +const UP = Vector2(0, -1) +var motion = Vector2() + +func _physics_process(delta): + + if Input.is_action_pressed("ui_right"): + motion.x = 100 + elif Input.is_action_pressed("ui_left"): + motion.x = -100 + else: + motion.x = 0 + + if is_on_floor(): + if Input.is_action_just_pressed("ui_up"): + motion.y = -325 + + motion.y += 10 + motion = move_and_slide(motion, UP) + pass
\ No newline at end of file |
