summaryrefslogtreecommitdiffhomepage
path: root/Racing-Game/KinematicBody2D.gd
blob: e024ffc2cd6ad3982b88361d825955e0e74fb048 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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