Scrolling Game Development Kit Forum

SGDK Version 1 => Help/FAQ => Topic started by: Superjeep3 on 2005-07-19, 07:52:56 AM

Title: Weapon Cycle q's
Post by: Superjeep3 on 2005-07-19, 07:52:56 AM
Heya all, I have a little question if anyone could help me out.  I am currently in the beginning stages of making a game with the kit, and I have a question about the ability to cycle through weapons using <> or something, instead of 4 keys for 4 weapons.  Is this possible without script?  The reason I ask is because I have no idea how to script.  Thanx for any help yopu can give.
Title: Weapon Cycle q's
Post by: durnurd on 2005-07-19, 09:32:43 AM
Yes, it is possible, you would have to define < as, for example, button 1 and > as button 2.

Then, depending on how you want the weapons to work, the following is different.  If there is no visible difference in the player sprite when changing weapons (only difference is in bullets that the player fires), then all you have to do is have two special functions.  One that adds 1 to an inventory that keeps track of what weapon you're on, and one that subtracts one from the same inventory.  Setting the "Reset to Opposite Limit" option would be a nice way to not limit how far you can go.

Then, when shooting, just check to see how many of that inventory you have, and accordingly create the proper bullet sprite.  This may be a little difficult, because the way inventory works is that if you have AT LEAST 1, then it will activate a function that requires 1 of said inventory.  However, there are several ways to get around this.

One is to have each different type of bullet be defined as a class "Bullet" and a different template, then, have a collision defenition between two bullets that activates special function COL_<A_Template><B_Template>*.  Then create special functions called COL_Bullet1Bullet2 and COL_Bullet2Bullet3 and COL_Bullet1Bullet3 etc. (if the names of your bullet templates are Bullet1 Bullet2 Bullet3 etc.) and they would remove all of the first type of bullet from the map. (i.e. COL_Bullet1Bullet2 would remove all of Bullet1).

Another way is to have each bullet a different class, and then just define each collision between the bullets (Collision between Class Bullet1 and class Bullet2), then just destroy Sprite A.

Yet another way is to have many many more special functions and inventory items.  Pressing ">" would instead have 4 special functions associated with it.  Each would require 1 inventory of a different type.  Here, let me just show you:

Activation Parameters: Pressing Button 1
Requires (1) Weapon1Inv (Use it up)
Action: Add 1 to Weapon2Inv

Activation Parameters: Pressing Button 1
Requires (1) Weapon2Inv (Use it up)
Action: Add 1 to Weapon3Inv

Activation Parameters: Pressing Button 1
Requires (1) Weapon3Inv (Use it up)
Action: Add 1 to Weapon4Inv

Activation Parameters: Pressing Button 1
Requires (1) Weapon4Inv (Use it up)
Action: Add 1 to Weapon1Inv

Activation Parameters: Pressing Button 2
Requires (1) Weapon4Inv (Use it up)
Action: Add 1 to Weapon3Inv

Activation Parameters: Pressing Button 2
Requires (1) Weapon3Inv (Use it up)
Action: Add 1 to Weapon2Inv

Activation Parameters: Pressing Button 2
Requires (1) Weapon2Inv (Use it up)
Action: Add 1 to Weapon1Inv

Activation Parameters: Pressing Button 2
Requires (1) Weapon1Inv (Use it up)
Action: Add 1 to Weapon4Inv

Then when firing, each function would just check for 1 inventory of whatever type and create the propper bullet.

However, this would be immensely easier with scripting.  There are many resources to help you learn how.  I really, really reccommend you try learning just a few beginning scripts.  The help that comes with SGDK, the sample scripts on sourceforge, and the people on this forum will help if you get stuck or need help.
Title: Weapon Cycle q's
Post by: superjeep3 on 2005-07-19, 10:17:18 AM
The different weapons would have different looks.  Would that make it harder or could you do something where the function would also change the sprite for the char., as they all have the same sprite, but with different weapons.  I mean to say that the char. looks the same with each weapon, just that the weapon looks different.  Thanx for the help.
Title: Weapon Cycle q's
Post by: durnurd on 2005-07-19, 06:45:43 PM
That's also possible, but it will be a little harder, of course.  When activating each of those functions, it will instead activate a series of special functions, one which does what it used to (add 1 to proper inventory) and another which switches the sprite.
Title: Weapon Cycle q's
Post by: Superjeep3 on 2005-07-19, 07:10:37 PM
Ok, great, at least now I know it can be done, now I just have to do it (figure out how...heh).  Thanx so much for your help.
Title: Weapon Cycle q's
Post by: bluemonkmn on 2005-07-20, 06:02:53 AM
In case you change your mind about editing script, I bet it would have been shorter to show you what script to edit (based on the shooting wizard) to accomplish this ::).  Just because you don't know scripting doesn't mean you can't use it.  We can help you with scripting just as easily (in this case, maybe more easily) than with "non-scripting" :).

heh "Non-scripting: The real challenge" ;)
Title: weapon cycle q's
Post by: Superjeep3 on 2005-07-24, 02:13:02 PM
ok, I will look at how hard it will be to script, hopefully not to bad.  Thanx again for the help.
Title: Weapon Cycle q's
Post by: bluemonkmn on 2005-07-26, 05:21:41 AM
Well, if you're willing to script, just let us know and we can probably give you the script, then all you have to to is copy and paste (and maybe change a couple words to match your project).