Hey everyone for my second tutorial in GameMaker. One thing I forgot to say is that for sprites, you can upload an image from your computer, by clicking "Load Sprite" instead of "Edit Sprite." This will allow you to save images from the web into your computer, then using them in your game. However, remember to give credit where credit is due!
Alright, enough digression. Time to start the actual game. In the last tutorial, we made a player and gave it moving commands. Now, we give him shooting commands. This tutorial will be relatively short and sweet.
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: Making the Bullet Sprite
Nothing too fancy here. Just like the Player sprite, we're going to make a bullet sprite. Make it smaller, around 3 times less than your player size (We don't want a bullet bigger than the player :P). Because my player is 32x32, I'll make my bullet 5x5.
For those of you who forgot how to do that, right click "Sprites," click "Create Sprite," and click "Edit Sprite."
For now, I will just make it a grey square; you guys can upload images from the web, make a cool bullet, whatever you want. Name this sprite BulletSprite. I also forgot to tell you guys to center the image last time. At the bottom right, there should be a button called "Center." Click it. Also, open up the Player Sprite by double clicking it and center it as well.
Next, we make the bullet object!
Step 2: Making the Bullet an Object
Now that we have the sprite, we are going to make the bullet something we can use in the game. If you are new, or have forgotten how to do it, right click "Objects" and click "Create Object." Name this Object "Bullet." Make the sprite "BulletSprite" (of course). We don't need any code in this at all for now, so just click "ok".
Step 3: Putting a Shooting Command in the Player
We didn't need code in the bullet, but we do need it for the Player. Open the Player object and click "Add Event." Click "Key Pressed Space." WARNING: DO NOT CLICK "KEYBOARD!!!!" CLICK ON "KEY PRESSED!!!!!" IMPORTANT!!!!
Okay, enough warning. Let's get on with it. In the "Key Pressed" add an "Action" that should be in the "main1" tab. The action we want is "Create Moving Instance." It looks kind of like a light-bulb with a green arrow. Drag it into the "Action," and you'll get what looks like a confusing menu. DON'T PANIC!
Let's go over each of the slots. For the object, we want the object of "Bullet." You can just leave x and y as 0. Speed is how fast your bullet will go, in my case, I made it 15. The bullet should always be faster than the Player. Lastly, for direction, just type "direction" . This means the bullet will go in whatever direction your Player is facing.
WARNING WARNING WARNING!!!!!!!!!!!!!!!!!!!!!!!! CLICK THE RELATIVE BUTTON AT THE BOTTOM!!!!!!!!!!!!!
Now press "OK" and run the program. Move with arrow keys, and shoot with space!