summary refs log tree commit diff stats
path: root/tests/manyloc/keineschweine/lib/vehicles.nim
diff options
context:
space:
mode:
Diffstat (limited to 'tests/manyloc/keineschweine/lib/vehicles.nim')
-rw-r--r--tests/manyloc/keineschweine/lib/vehicles.nim35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/manyloc/keineschweine/lib/vehicles.nim b/tests/manyloc/keineschweine/lib/vehicles.nim
new file mode 100644
index 000000000..edbd84ff9
--- /dev/null
+++ b/tests/manyloc/keineschweine/lib/vehicles.nim
@@ -0,0 +1,35 @@
+import
+  sfml, chipmunk, 
+  sg_assets, sfml_stuff, keineschweine
+
+
+proc accel*(obj: PVehicle, dt: float) =
+  #obj.velocity += vec2f(
+  #  cos(obj.angle) * obj.record.handling.thrust.float * dt,
+  #  sin(obj.angle) * obj.record.handling.thrust.float * dt)
+  obj.body.applyImpulse(
+    vectorForAngle(obj.body.getAngle()) * dt * obj.record.handling.thrust,
+    vectorZero)
+proc reverse*(obj: PVehicle, dt: float) =
+  #obj.velocity += vec2f(
+  #  -cos(obj.angle) * obj.record.handling.reverse.float * dt,
+  #  -sin(obj.angle) * obj.record.handling.reverse.float * dt)
+  obj.body.applyImpulse(
+    -vectorForAngle(obj.body.getAngle()) * dt * obj.record.handling.reverse,
+    vectorZero)
+proc strafe_left*(obj: PVehicle, dt: float) =
+  obj.body.applyImpulse(
+    vectorForAngle(obj.body.getAngle()).perp() * obj.record.handling.strafe * dt,
+    vectorZero)
+proc strafe_right*(obj: PVehicle, dt: float) =
+  obj.body.applyImpulse(
+    vectorForAngle(obj.body.getAngle()).rperp()* obj.record.handling.strafe * dt,
+    vectorZero)
+proc turn_right*(obj: PVehicle, dt: float) =
+  #obj.angle = (obj.angle + (obj.record.handling.rotation.float / 10.0 * dt)) mod TAU
+  obj.body.setTorque(obj.record.handling.rotation)
+proc turn_left*(obj: PVehicle, dt: float) =
+  #obj.angle = (obj.angle - (obj.record.handling.rotation.float / 10.0 * dt)) mod TAU
+  obj.body.setTorque(-obj.record.handling.rotation)
+proc offsetAngle*(obj: PVehicle): float {.inline.} =
+  return (obj.record.anim.angle + obj.body.getAngle())