small racing game im working on
Diffstat (limited to 'classes/human_car.gd')
-rw-r--r--classes/human_car.gd39
1 files changed, 9 insertions, 30 deletions
diff --git a/classes/human_car.gd b/classes/human_car.gd
index f70c06d..335b604 100644
--- a/classes/human_car.gd
+++ b/classes/human_car.gd
@@ -1,40 +1,19 @@
class_name HumanCar
extends Car
-var device := -2 # -2 for any
-
-
-var steer_left := 0.0
-var steer_right := 0.0
-
-func _ready():
- super()
- $Engine.volume = 0.3
-
-static func attach(to: PackedScene, device: int = -2) -> HumanCar:
+static func attach(to: PackedScene) -> HumanCar:
var car := to.instantiate()
car.set_script(load("res://classes/human_car.gd"))
- car.device = device
return car
func _physics_process(delta: float) -> void:
- steer(steer_left - steer_right)
+ throttle = Input.get_action_strength("accel")
+ brake = Input.get_action_strength("brake") * MAX_BRAKE_FORCE
+ steer(Input.get_axis("left", "right"))
super(delta)
- shup = false
- shown = false
-func _input(event: InputEvent) -> void:
- if device != -2 and event.device != device:
- return
- if event.is_action("accel"):
- throttle = event.get_action_strength("accel")
- if event.is_action("brake"):
- brake = event.get_action_strength("brake") * MAX_BRAKE_FORCE
- if event.is_action("left"):
- steer_left = event.get_action_strength("left")
- if event.is_action("right"):
- steer_right = event.get_action_strength("right")
- if event.get_action_strength("shift_up") > .5:
- shup = true # process changes it to false after use because of a wierd bug i found
- if event.get_action_strength("shift_down") > .5:
- shown = true
+func shift_up():
+ return Input.is_action_just_pressed("shift_up")
+
+func shift_down():
+ return Input.is_action_just_pressed("shift_down")