Rajout des diagonnales

Le premier joystick est complété
This commit is contained in:
Thomas Lavocat
2019-09-04 01:43:24 +02:00
parent 06af034b3d
commit 75985456bc

View File

@@ -238,10 +238,8 @@ t1.start()
absx = -1
prev_absx = -1
state_absx=False
absy = -1
prev_absy = -1
state_absy=False
prev_action = -1
@@ -251,32 +249,36 @@ while (True) :
for event in events:
if event.code =="ABS_X":
absx = raffine_entree(event.state)
if (absx > 0 and absx>DEAD_ZONE) or (absx <0 and absx<-DEAD_ZONE):
state_absx = True
if event.code =="ABS_Y":
absy = raffine_entree(event.state)
if (absy > 0 and absy>DEAD_ZONE) or (absy <0 and absy<-DEAD_ZONE):
state_absy = True
if abs(absx) < DEAD_ZONE and abs(absy) < DEAD_ZONE :
neutral = 2
action_voulue = -1
if state_absx == True :
if abs(absx) > DEAD_ZONE :
if absx < -80 :
action_voulue = 13
elif absx > 80 :
action_voulue = 14
#print("absx : {}".format(absx))
state_absx = False
if state_absy == True :
if abs(absy) > DEAD_ZONE :
if absy < -80 :
action_voulue = 2
elif absy > 80 :
action_voulue = 7
#print("absy : {}".format(absx))
state_absy = False
if abs(absx) > DEAD_ZONE and abs(absy) > DEAD_ZONE :
print("absy : {}".format(absx))
print("absx : {}".format(absy))
if (absx <0 and absx < -40) and (absy <0 and absy < -40) :
action_voulue = 5
elif (absx >0 and absx > 40) and (absy <0 and absy < -40) :
action_voulue = 6
elif (absx >0 and absx > 40) and (absy >0 and absy > 40) :
action_voulue = 11
elif (absx <0 and absx < -40) and (absy >0 and absy > 40) :
action_voulue = 10
if neutral == 2 :