First we'll create a bullet object
We'll set it up so it'll be destroyed if it hits a wall or goes outside the room.
We'll also set it to kill the monsters when the bullet hits it. Create the Collision with one of the monsters:
Then duplicate it for the flying monster...
To make things a bit more interesting, the player first needs to find some ammunition to be able to shoot. To this end we introduce a variable we call ammo that indicates how much ammunition the player has - it has to be this name, it can't be the same name as the object/sprite so ammunition won't work.
Create the ammunition object: has a simple sprite and does nothing. It just waits to be picked up by the player. Give it a depth of 10.
Go into your character object and add a Create event.
Then add a Collision with ammunition event.
Add a <Space> Key Press (not Key Board) and make it so every time the player presses the Space Bar, they can shoot.
Add Start & End blocks...
We have to do some testing - which direction is the character facing? That's the direction we want to shoot the bullets...
It should end up looking like this...
Put the gun in the room near the character and test it out - if you pick it up, can you shoot to the right and kill the monster? does it disappear? can you shoot to the left?