Supression du joystick USB

This commit is contained in:
Philippe Roy 2023-05-10 08:10:01 +02:00
parent b7e2ccbd4b
commit 7124771214
3 changed files with 2 additions and 75 deletions

View File

@ -127,7 +127,8 @@ def victoire_fermer(cont):
scene.objects['Bille']['z']= -21 # On provoque le redémarrage si la bille est ressortie
###############################################################################
# Gestion du Joystick
# Gestion du Joystick (Joystick USB)
# Partie non abordée dans le tutoriel
###############################################################################
def joystick(cont):

View File

@ -204,40 +204,3 @@ def victoire_fermer(cont):
scene.objects['Panneau victoire'].setVisible(False,True) # Cacher le panneau de la victoire
scene.objects['Panneau victoire - plan'].suspendPhysics (True) # Suspendre la physique du panneau cliquable
scene.objects['Bille']['z']= -21 # On provoque le redémarrage si la bille est ressortie
###############################################################################
# Gestion du Joystick USB
###############################################################################
def joystick(cont):
obj = cont.owner
joystickIndex = 0 #int from 0 to 6
joy = bge.logic.joysticks[joystickIndex]
events = joy.activeButtons
axis = joy.axisValues[0:4]
resolution = 0.01
leftStick_x = axis[0]; leftStick_y = axis[1]
rightStick_x = axis[2]; rightStick_y = axis[3]
#if any button is pressed
# if events:
# print(events) #spit out integer index of pressed buttons
# if 0 in events:
# doSomething()
# Up
if leftStick_y <-0.1 :
obj.applyRotation((-resolution,0,0), False)
# Down
if leftStick_y >0.1 :
obj.applyRotation((resolution,0,0), False)
# Left
if leftStick_x <-0.1 :
obj.applyRotation((0, -resolution,0), False)
# Right
if leftStick_x >0.1 :
obj.applyRotation((0, resolution,0), False)

View File

@ -234,40 +234,3 @@ def victoire_fermer(cont):
serial_msg_out = "90\n" # Afficher image de début (flèches) sur la matrice de leds
serial_comm.write(serial_msg_out.encode())
# scene.objects['Bille']['z']= -21 # On provoque le redémarrage si la bille est ressortie
###############################################################################
# Gestion du Joystick USB
###############################################################################
def joystick(cont):
obj = cont.owner
joystickIndex = 0 #int from 0 to 6
joy = bge.logic.joysticks[joystickIndex]
events = joy.activeButtons
axis = joy.axisValues[0:4]
resolution = 0.01
leftStick_x = axis[0]; leftStick_y = axis[1]
rightStick_x = axis[2]; rightStick_y = axis[3]
#if any button is pressed
# if events:
# print(events) #spit out integer index of pressed buttons
# if 0 in events:
# doSomething()
# Up
if leftStick_y <-0.1 :
obj.applyRotation((-resolution,0,0), False)
# Down
if leftStick_y >0.1 :
obj.applyRotation((resolution,0,0), False)
# Left
if leftStick_x <-0.1 :
obj.applyRotation((0, -resolution,0), False)
# Right
if leftStick_x >0.1 :
obj.applyRotation((0, resolution,0), False)