View difference between Paste ID: GBxcHCPS and eNZ9d38V
SHOW: | | - or go back to the newest paste.
1
extends KinematicBody2D
2
3
4
export var speed = 200.0
5
export var run_speed = 300.0
6
7
var rad_up = 0
8
var rad_down = PI
9
var rad_right = (PI*3)/2
10
var rad_left = PI/2
11
12
13
14
func process_movement(delta):
15
	var motion = Vector2(0,0)
16
	
17
	if Input.is_action_pressed("move_up"):
18
		motion += Vector2(0, -1)
19-
		motion = motion.normalized() * speed * delta
19+
20
		
21
	if Input.is_action_pressed("move_down"):
22
		motion += Vector2(0, 1)
23
		set_rot(rad_down)
24-
		motion = motion.normalized() * speed * delta
24+
25
	if Input.is_action_pressed("move_right"):
26
		motion += Vector2(1, 0)
27
		set_rot(rad_right)
28
29-
		motion = motion.normalized() * speed * delta
29+
30
		motion += Vector2(-1, 0)
31
		set_rot(rad_left)
32
	
33
        var velocity = speed	
34-
		motion = motion.normalized() * speed * delta
34+
        if Input.is_action_pressed("run"):
35
                velocity = run_speed
36
37-
	if Input.is_action_pressed("run_up"):
37+
38
	motion = motion.normalized() * velocity * delta
39-
		motion = motion.normalized() * run_speed * delta
39+
40
	move(motion)
41
42-
	if Input.is_action_pressed("run_down"):
42+
43
	set_fixed_process(true)
44-
		motion = motion.normalized() * run_speed * delta
44+
45
func _fixed_process(delta):
46
	process_movement(delta)