IGM Tutorial: Projectiles

in Tutorials

Want to check out a PDF of this tutorial? Right click save as HERE.

Finally we shall cover projectiles! Let’s make our ship from the last tutorial shoot at some stuff. Resources!

So first you need something for it to shoot. Grab the dark ship and the dark bullets and we’ll make ourselves an enemy that shoots back. The first part of this is easy stuff. Just import the new graphics via the “Materials” tab then head to the “Animations” sub-tab to copy and paste the Player Ship we made last time. After that just replace its graphics with the new Enemy Ship and rename it if you like. Because this is an enemy and not our player gadget we’ll need to change the way its hit detection works a little bit. Use these to make the ship hurt our ship when they collide, and to take damage from our player gadget’s bullets.

Collision Detection With Other Gadgets
Horizontal Positioning % (top left box) = 3
Horizontal Size % (top right box) = 94
Vertical Positioning % (bottom left box) = 31
Vertical Size % (bottom right box) = 38

Collision Detection With Walls (Tiles)
None

Collision Detection For Attacks
Horizontal Positioning % (top left box) = 0
Horizontal Size % (top right box) = 100
Vertical Positioning % (bottom left box) = 28
Vertical Size % (bottom right box) = 44

Now we’ll need to set up a bullet animation for our Player Ship so “Create” a new animation and use the Player Bullet graphic we imported. No need for infinite looping or to set the origin at the character’s feet. Back on the “Per Frame Settings” sub-sub-tab under “Display Settings” we’ll want to set the horizontal Offset % to 100. This will make it appear as if the bullets are coming from the front of our ship. Here’s the hit detection for the Player Bullet:

Collision Detection With Other Gadgets
None

Collision Detection With Walls (Tiles)
Horizontal Positioning % (top left box) = 103
Horizontal Size % (top right box) = 19
Vertical Positioning % (bottom left box) = 47
Vertical Size % (bottom right box) = 6

Collision Detection For Attacks
Horizontal Positioning % (top left box) = 0
Horizontal Size % (top right box) = 25
Vertical Positioning % (bottom left box) = 44
Vertical Size % (bottom right box) = 12

In some cases you may want your bullets to interact with other gadgets beyond just attacking them, but for this example this is the best hit detection for what we want to do. Make sure to add in another “Invisible” action to this animation so that our bullets will have something to do when they disappear. If needed, you can just copy and paste the one we made for our ship. Now you should copy and paste our Player Bullet animation and rename this new one Enemy Bullet. Because our enemies are going the other way, the hit detection and offset of these bullets will be a bit different from our Player Bullet. Here’s what you want to do:

Offset
Horizontal % (left box) = -100
Vertical % (right box) = 0

Collision Detection With Other Gadgets
None

Collision Detection With Walls (Tiles)
Horizontal Positioning % (top left box) = -22
Horizontal Size % (top right box) = 19
Vertical Positioning % (bottom left box) = 47
Vertical Size % (bottom right box) = 6

Collision Detection For Attacks
Horizontal Positioning % (top left box) = 75
Horizontal Size % (top right box) = 25
Vertical Positioning % (bottom left box) = 44
Vertical Size % (bottom right box) = 12

Once you’re done with all of that, head over to the “Gadgets” sub-tab. Create a new gadget called Player Bullet using the animation we’ve set up. On the “Emergence Settings” sub-sub-tab set up the Layer For Display as 2, Set “The First Action Program”, and make this “Active – When Close To A Camera”. Now head back to the “Registering Actions” sub-tab. You’ll only need two “Action Programs”. Player Bullet, and Invisible. For Player Bullet don’t designate a direction of movement, set the speed for 200, and have it switch to Invisible when ANY of the following occur: Gadget Collided With A Wall, There Is A Wall Underfoot, Next Step Hits A Wall, Collided With Another Gadget. For the Invisible “Action Program” just have it not move and check the box for “Disappear”. Now head to the “Moving & Jumping Settings” sub-sub-tab and set your movement distances under “Basic Lateral/Verticle Movement” to 4. This when combined with the 200 movement speed will ensure that our bullets travel faster than our ship.

Now head to our Player Ship. We’re going to need two new “Action Programs” here. Standby Fire, and Fly Fire. You can copy/paste Standy and Fly if you like to save a little bit of time. The only thing we’re going to change about the actions themselves is that these will fire projects, so check the box for “Shoot Projectiles” and leave “Shot 1″ selected. If you copied and pasted these they are already set to go to Explosion when your health runs out, so that’s a huge time saver. Here’s all the things you’ll need to set up for how the Action Programs switch to each other. It may get complicated so take your time and try to watch out for any errors as this can get tricky if something goes wrong.

Standby > Standby Fire IF “B – Upon Pressing”
Standby > Fly IF “Up/Down/Left/Right – Upon Pressing”
Standby > Explosion IF “Gadget Collided With A Wall” OR “The Gadget’s Health Dropped To Zero”
(The conditions for Explosion should apply to all of the Ship’s Action Programs)
Standby Fire > Standy IF “Switch If Nothing Is Entered”
Standby Fire > Fly IF “Up/Down/Left/Right – Upon Pressing”
Standby Fire > Fly Fire IF “Up/Down/Left/Right – Upon Pressing” AND “B – Upon Pressing”
Fly > Standby IF “Switch If Nothing Is Entered”
Fly > Standby Fire IF “Up/Down/Left/Right – Upon Release” AND “B – Upon Pressing”
Fly > Fly Fire IF “B – Upon Pressing”
Fly Fire > Standby IF “B – Upon Release” AND “Up/Down/Left/Right – Upon Release”
Fly Fire > Standby Fire IF “B – Upon Pressing” AND “Up/Down/Left/Right – Upon Release”
Fly Fire > Fly IF “B – Upon Release” AND “Up/Down/Left/Right – Is Pressed”
Invisible > Standby IF “The Set Time Elapsed – 1.00 (Seconds)”

That is a lot! So basically this just allows us to fly around firing without any weird hiccups in our flight path, and if we lose all of our health we’ll explode and come back after one second has passed. But! If you tested that right now, you’d just keep exploding in an endless loop. So under the Invisible “Action Program”, have it “Switch Memories” and set the memory to “Player Health”. Set it to “Reset To Default”. This will refill our health everytime we explode.

Finally we get to set our Player Ship’s projectile settings, so head over to that sub-sub-tab. In the drop down menu for “Shot 1″ select our Player Bullet. Shots per burst can stay at 1, interval can stay at 0, but increase the “Shot Frequency Cap” to 16 (which is the max). Under “Projectile Trajectories” select “Fly In Designated Direction”, “In The Designated Direction”, and turn the dial to aim right. That’s it so far. Load up the game real quick and test out your ability to shoot.

Next let’s make the Enemy Ship gadget. You’ll need four “Action Programs”. Fly, Shoot, Explosion, and Invisible. For this we’ll need to set a direction of movement, so let’s set the dial for straight left. Set the movement speed for 10. Do the same thing for the Shoot “Action Program” only this time enable it to shoot projectiles and set it up for “Shot 1″. Explosion and Invisible don’t need a direction of movement or a speed, and Invisible should be checked to disappear. Setting up the way the “Action Programs” switch is a lot easier here.

Fly > Shoot IF “The Set Time Elapsed – 1.00 (Seconds)”
Fly > Explosion IF “The Gadget’s Health Dropped To Zero”
Shoot > Fly “Forcibly Branch Without Any Time Lapse”
Shoot > Explosion IF “The Gadget’s Health Dropped To Zero”
Explosion > Invisible IF “The Gadget Played All Animations”

After this I went to “Emergence Settings” and gave this gadget 2 health instead of 1 to make it a little harder to kill. The rest of the settings here should be standard for you all by now, but make sure you go with “Activation – When Close To A Camera” and check the box for “Don’t Flash On Taking Damage”. Don’t forget to set the Basic Vertical/Lateral Movement Distance to 4 under the “Moving & Jumping Settings” sub-sub-tab. Now you should make your Enemy Bullet gadget really quick. It’s going to be exactly the same as your Player Bullet, so just copy/paste that, rename it, and then head to the “Projectile Settings” sub-sub-tab for the Enemy Ship.

Shots Per Burst = 1
Interval Between Shots = .50
Shot Frequency Cap = 5
Check – Fly In Designated Direction
Check – In A Designated Direction
Dial – To The Left

Now you just need to put your enemy gadget onto your canvas and every second it’ll fire a bullet at you. If you run out of health or crash into the ground you’ll come back to life after a second.

Ready to start your own game in IGM? Purchase IGM at a 10% discount using the coupon code igmakerohyeah. Any questions, comments? Ask them in the comment section below.

0 comments… add one

Leave a Comment