The player - Shooting
The player has to have someway to destroy the enemy! I had to be careful how I coded the shooting as the player can pick up powerups which changed what shot he used. As he started of with a single shot, this was what I coded first but there was a number of problems to overcome even for single shooting.
The first problem encountered, to be fair, has nothing to do with my game but either Game Maker or Windows itself:- for some reason (and a few people have come up against this problem), when using the SPACEBAR to fire, you can't have two cursor keys pressed at the same time as well as SPACE. You can't move the player diagonal AND fire, it's diagonal OR fire and this is certainly no good in a fast paced shoot-em-up so I decided to use the LEFT MOUSE BUTTON for fire which solved the problem.
The next problem was the continuous stream of bullets that came from the player when firing, I needed someway to time the shots so he fired one every few moments, this was achieved be the use of an alarm which changed a variable to 'on' so the player could fire, and in the FIRE event, after the player fired, the variable was set to 'off'. The timing of the alarm was also a variable (like the ships speed) so that it could be changed with powerups to have faster shots.
So now the player could move and shoot (about 2 shots every second) and as the player's shots would always go to the right, I checked whether it was out of view so I could destroy it when it couldn't be seen anymore.
The first problem encountered, to be fair, has nothing to do with my game but either Game Maker or Windows itself:- for some reason (and a few people have come up against this problem), when using the SPACEBAR to fire, you can't have two cursor keys pressed at the same time as well as SPACE. You can't move the player diagonal AND fire, it's diagonal OR fire and this is certainly no good in a fast paced shoot-em-up so I decided to use the LEFT MOUSE BUTTON for fire which solved the problem.
The next problem was the continuous stream of bullets that came from the player when firing, I needed someway to time the shots so he fired one every few moments, this was achieved be the use of an alarm which changed a variable to 'on' so the player could fire, and in the FIRE event, after the player fired, the variable was set to 'off'. The timing of the alarm was also a variable (like the ships speed) so that it could be changed with powerups to have faster shots.
So now the player could move and shoot (about 2 shots every second) and as the player's shots would always go to the right, I checked whether it was out of view so I could destroy it when it couldn't be seen anymore.


0 Comments:
Post a Comment
<< Home