I actually use python for everything except the always sensor and the physics. Here’s the whole script :
import bge
def main():
cont = bge.logic.getCurrentController()
player = cont.owner
keyboard = bge.logic.keyboard
scene = bge.logic.getCurrentScene()
movSpeed = 0.1
rushSpeed = 0.5
rotSpeed = 0.25
bulletSpeed = 2500
if bge.logic.KX_INPUT_ACTIVE == keyboard.events[bge.events.LEFTSHIFTKEY]:
#rushavant
player.applyMovement((rushSpeed, 0, 0), True)
if bge.logic.KX_INPUT_ACTIVE == keyboard.events[bge.events.ZKEY] :
#deplbas
player.applyMovement((0, 0, -movSpeed), True)
if bge.logic.KX_INPUT_JUST_ACTIVATED == keyboard.events[bge.events.ZKEY] :
#rotbas
player.applyRotation((0, rotSpeed, 0), True)
if bge.logic.KX_INPUT_JUST_RELEASED == keyboard.events[bge.events.ZKEY] :
#antirotbas
player.applyRotation((0, -rotSpeed, 0), True)
if bge.logic.KX_INPUT_ACTIVE == keyboard.events[bge.events.SKEY] :
#deplhaut
player.applyMovement((0, 0, movSpeed), True)
if bge.logic.KX_INPUT_JUST_ACTIVATED == keyboard.events[bge.events.SKEY] :
#rothaut
player.applyRotation((0, -rotSpeed, 0), True)
if bge.logic.KX_INPUT_JUST_RELEASED == keyboard.events[bge.events.SKEY] :
#antirothaut
player.applyRotation((0, rotSpeed, 0), True)
if bge.logic.KX_INPUT_JUST_ACTIVATED == keyboard.events[bge.events.QKEY] :
#rotgauche
player.applyRotation((-rotSpeed, 0, 0), True)
if bge.logic.KX_INPUT_ACTIVE == keyboard.events[bge.events.QKEY] :
#deplgauche
player.applyMovement((0, movSpeed, 0), True)
if bge.logic.KX_INPUT_JUST_RELEASED == keyboard.events[bge.events.QKEY] :
#antirotgauche
player.applyRotation((rotSpeed, 0, 0), True)
if bge.logic.KX_INPUT_JUST_ACTIVATED == keyboard.events[bge.events.DKEY] :
#rotdroite
player.applyRotation((rotSpeed, 0, 0), True)
if bge.logic.KX_INPUT_ACTIVE == keyboard.events[bge.events.DKEY] :
#depldroite
player.applyMovement((0, -movSpeed, 0), True)
if bge.logic.KX_INPUT_JUST_RELEASED == keyboard.events[bge.events.DKEY] :
#antirotdroite
player.applyRotation((-rotSpeed,0 ,0), True)
if bge.logic.KX_INPUT_JUST_ACTIVATED == keyboard.events[bge.events.SPACEKEY] :
#tir
bullet = scene.addObject('Bullet', 'Barrel', 150)
bullet.applyForce((-bulletSpeed, 0, 0), True)
bullet.color = (1, 0, 0, 1)
main()
By the way is there an other way to write the moving part : i need an event as long input is active, an event that run once when the input is active (JUST_ACTIVATED) and one when the input is released which make three if for each direction.
No need for applause since the game is awkardly short and simplist 