Skip to content

Instantly share code, notes, and snippets.

@hodgej
Created June 4, 2019 21:56
Show Gist options
  • Save hodgej/59d82ab48fe0f69597eff20c93603014 to your computer and use it in GitHub Desktop.
Save hodgej/59d82ab48fe0f69597eff20c93603014 to your computer and use it in GitHub Desktop.
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment