Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var motion = Vector2(0,0)
- var speed = 800
- var acc = 0.6
- var dec = 0.9
- var turn_speed = 150
- func _physics_process(delta):
- get_input()
- var movedir = Vector2(1, 0).rotated(rotation)
- move_and_slide(motion * speed * delta)
- func get_input():
- if Input.is_action_pressed("forward"):
- motion = motion.lerp(movedir, acc)
- elif Input.is_action_pressed("backward"):
- motion = motion.lerp(movedir, -acc)
- else:
- motion = motion.lerp(Vector2(0,0), dec)
- if Input.is_action_pressed("forward") and Input.is_action_pressed("left"):
- rotation_degrees += turn_speed * delta #maybe lerp it with motion to make more accurate turning
- elif Input.is_action_pressed("forward") and Input.is_action_pressed("right"):
- rotation_degrees += turn_speed * delta #refer to line 22
- else:
- pass
- func gear1():
- print("Gear one engaged!")
- speed = -800
- turn_speed = 5
- $Camera2D.smoothing_speed = 5
- func gear2():
- print("Gear two engaged!")
- speed = -1500
- turn_speed = 7
- $Camera2D.smoothing_speed = 10
- func gear3():
- print("Gear three engaged!")
- speed = -2000
- turn_speed = 10
- $Camera2D.smoothing_speed = 12.5
- func barracade_hit():
- modulate = Color(.2, .2, .4)
- input_enabled = false
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement