After adding the basics of the weapons system yesterday, this evening I attempted to add some more polish to the system, including environmental collisions. I started off by adding a new sprite for the player bullets (the one I'd chosen was a little weedy), and then added a routine that allows the player to fire bullets to the left and right (depending on where the mouse pointer is on-screen).
I hit a snag with the bullet generation, and thus a little time was spent reading various articles to work out the source of the issue. Essentially, every time a bullet is fired, an alarm is set; this counts down to zero, during which time another bullet cannot be fired (a simple system to stop bullets being spewed every frame).
The problem with Game Maker's alarms is that unless the alarm is checked by an event, it doesn't function (this seems lame until you consider that it's just the engine being ruthlessly efficient). The solution is pretty simple - just add a code segment that is triggered when the alarm fires, but leave the file blank.
After fixing the alarm issue, I took the next step of adding vertical firing, then rounded off the bullet routines by adding collision states (so that the bullets explode when they hit a wall). The next step was to bring the pieces together and allow the enemies to be taken out by bullets, which was a matter of 30 second's work. I then reaped the rewards of the evening's session as I wandered around the map firing bullets and taking out any enemy that dared get in my way! :)
Interestingly enough, I came up with an idea while roaming the maze and flinging out bullets, and wrapped up the night's session by creating a crate entity; these will litter the levels, and act as either bonus repositories (a la Half Life), or simply allow the player to nudge them around the map to provide useful - if temporary - cover from enemy fire.
