samedi 14 avril 2018

Checking if an integer value is inside an array

I got an array which contains key inputs, and also mouse coordinates inputs.

This array consists of: [W, A, D, X, mouseX, mouseY].

Below I got code which checks if a specific choice have been done; therefore if the user presses W, the array adds [0,1,0,0,mouseX, mouseY].

My question is: How can I get Python to declare that mouseX and mouseY can be any value unless it is an integer, so I can append those values as well?

mouseX = 0
mouseY = 0
for data in train_data:
img = data[0]
choice = data[1]
if choice == [1,0,0,0, mouseX, mouseY]:
    left.append([img,choice])
elif choice == [0,0,1,0,mouseX, mouseY]:
    right.append([img,choice])
elif choice == [0,0,0,1,mouseX, mouseY]:
    shoot.append([img,choice])
elif choice == [0,1,0,0,mouseX, mouseY]:
    forward.append([img,choice])

Thanks!

Aucun commentaire:

Enregistrer un commentaire