Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. var motion = Vector2(0,0)
  2.  
  3. var speed = 800
  4. var acc = 0.6
  5. var dec = 0.9
  6. var turn_speed = 150
  7.  
  8. func _physics_process(delta):
  9. get_input()
  10. var movedir = Vector2(1, 0).rotated(rotation)
  11. move_and_slide(motion * speed * delta)
  12.  
  13.  
  14. func get_input():
  15. if Input.is_action_pressed("forward"):
  16. motion = motion.lerp(movedir, acc)
  17. elif Input.is_action_pressed("backward"):
  18. motion = motion.lerp(movedir, -acc)
  19. else:
  20. motion = motion.lerp(Vector2(0,0), dec)
  21. if Input.is_action_pressed("forward") and Input.is_action_pressed("left"):
  22. rotation_degrees += turn_speed * delta #maybe lerp it with motion to make more accurate turning
  23. elif Input.is_action_pressed("forward") and Input.is_action_pressed("right"):
  24. rotation_degrees += turn_speed * delta #refer to line 22
  25. else:
  26. pass
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39. func gear1():
  40. print("Gear one engaged!")
  41. speed = -800
  42. turn_speed = 5
  43. $Camera2D.smoothing_speed = 5
  44.  
  45. func gear2():
  46. print("Gear two engaged!")
  47. speed = -1500
  48. turn_speed = 7
  49. $Camera2D.smoothing_speed = 10
  50.  
  51. func gear3():
  52. print("Gear three engaged!")
  53. speed = -2000
  54. turn_speed = 10
  55. $Camera2D.smoothing_speed = 12.5
  56.  
  57. func barracade_hit():
  58. modulate = Color(.2, .2, .4)
  59. input_enabled = false
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement