Next we're going to create the moveBullets() function. This function will be called repeatedly, which we will write the code for later on.
Line 14 - When this function is call first of all bulletReady is checked to to see if it's set to "true" and if the Space key is pressed.
Line 15 - If these conditions are met bulletReady is set to false, so that there is a delay between the next bullet fired bullet fire. In this case it will be 0.150 seconds, as we decalred at the top.
Line 16 - The the time, the space key is pressed, is then recorded in "currentTime"
Line 17 - A bullet is created using the creatBullets() function.
Line 18 - If bulletReady is false and the space key isn't down....
Line 19 - We check to see if the time has reach the currentTime plus the delay
Line 20 - If the delay is over we set bulletReady to false again so that another bullet can be fired. |