scripts:
————
keymap.py
import bge
import antrieb
cont = bge.logic.getCurrentController()
own = cont.owner
keyboard = bge.logic.keyboard
inputs = keyboard.inputs
if inputs[bge.events.UPARROWKEY].values[-1]:
antrieb.apply_force()
if inputs[bge.events.DOWNARROWKEY].values[-1]:
antrieb.apply_brake()
if inputs[bge.events.RIGHTARROWKEY].values[-1]:
antrieb.steer_right()
if inputs[bge.events.LEFTARROWKEY].values[-1]:
antrieb.steer_left()
———————————
antrieb.py
import bge
import mathutils
NRGY = 10.0
NRGY_R = 0.06
scene = bge.logic.getCurrentScene()
player = scene.objects[« Player »]
def apply_force():
power = mathutils.Vector((0.0, -NRGY, 0.0))
player.applyForce(power, True)
def apply_brake():
power = mathutils.Vector((0.0, NRGY, 0.0))
player.applyForce(power, True)
def steer_right():
rotPower = mathutils.Vector((0.0, 0.0, -NRGY_R))
player.applyRotation(rotPower, True)
def steer_left():
rotPower = mathutils.Vector((0.0, 0.0, NRGY_R))
player.applyRotation(rotPower, True)
———-
Link zum aktuellen Projektfile: https://filehorst.de/d/dctFujua
Source