Types of Guns / Weapons

Weapon Guide

You can set up a system where the player is capable of having different kinds of guns that fire different kinds of bullets, lasers, (whatever) by using a state variable. A state variable is an ordinary variable which flags the state of something. For example, if you set the state variable named gun to 2, that would mean the player was using a shotgun. If gun was set to 3 that would mean the player was using a laser rifle.

When the player fires his weapon, you can check the gun variable to see what kind of bullet to create.


(Main article: projectile)

A projectile is a game object which is thrown, shot, or otherwise propelled from another object with the express purpose of "doing damage" to another object, or, at least, registering a "hit". To do this, first make an event for pressing whichever key you want to use to shoot the projectile. Create an object for the projectile. Specify for the object which direction to move when created, and when to destroy itself (when it hits another object maybe) . Under your new key press event, put the "create an object" action down. Then erase the numbers in the "x" and "y" boxes and check the relative box. test the game. When you press the key you set, the projectile will start at the person, and move in the direction you set it to move. Once you get the hang of this, create another identical projectile that goes the other way. have this one shoot when the object is facing the other way. Now your person will shoot both ways.