i'm not sure of the title myself...
anyway i'm trying to make a 3d virtual piano program. i already have the code and i'm sure i can do finish it in the way i'm working but i'm wondering if it could be done with less code. here's a sample code for the first key of the piano:
if keystate(30)>0
rotate object 1,-5,180,0
position object 1,object position x(1),-5,0
else
rotate object 1,0,180,0
position object 1,object position x(1),0,0
endif
what it basically does is if A is pressed on the keyboard, it will rotate and move the first key of the piano down. if not, nothing will happen. what i did was copy this piece of code and just change the keystate scancode and the object numbers. here are the others:
if keystate(30)>0
press1 = 1
else
press1 = 0
endif
if press2 = 1 and play2 = 0
play2 = 1
play sound 2
endif
if press2 = 1 and play2 = 1
play2 = 1
else
play2 = 0
stop sound 2
endif
after figuring out a way to make the sound play right (with the third code), i knew i was well on the way to finishing this, but i wonder if there is a way to lessen the amount of work that i would need to do if i pushed through with copy-pasting and changing numbers because there is a lot to be changed in the third code.
i guess an array could help but i don't know how that would look like, so does anybody have an idea? i know you can change numbers with a for-next loop but not numbers in variable names. i also don't want to use the same variable for all keys (such as press to indicate a key is pressed) because it should be possible to play multiple keys at once.