Weapon selection?

0 favourites
  • 6 posts
From the Asset Store
Futuristics Weapons Vol 1 includes 8 different weapons, in a total of 216 sounds
  • Hello! My problem is that I am trying to allow the player to select different weapons via the mouse-wheel. While loops are dangerous bastards, because if you do it wrong, your game will lock-up in an endless loop. That is what happens when I try doing this:

    <img src="https://dl.dropboxusercontent.com/u/21499454/screenshots/support/howto_selectweapons.png" border="0" />

    cWeapon = Current Weapon

    I had this working at some point, but it has stopped now. Is there a better way to do this? Or if not, how can I get this to work?

    Thanks in advance! ;)

    Here is the capx: -SNIP-

    EDIT: I forgot to mention that the loop has condition checking, so it skips over weapons you don't have yet. It works after I get a shotgun, but then I cant get the pistol back. Again, a better way to do this would be appreciated!

  • Oh christ, I just realized my horrendous mistake. This works, but I had a an issue with setting variables in the pData array at the start of the layout, so I didn't have any weapons to cycle through. Oops!

  • hi there !very coolman

    did you make this work with an array ? can you explain to me how ?

    im triyng to make a weapon database like you that i can just select the weapons from, but i cant see how

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • hi there !very coolman

    did you make this work with an array ? can you explain to me how ?

    im triyng to make a weapon database like you that i can just select the weapons from, but i cant see how

    I have the array setup as a 10x4, but I'll only go over the first 2 y values as they're the more importaint for weapon selection:

    Cx1 = Weapon Name (Helps control actions when firing, like what bullets to use and how many, how much ammo to reduce, etc.)

    Cx2 = Weapon Ammo (How much ammo is left in inventory. You can use global variables if you want to have a common type of ammo to be used by different guns, however.)

    The 'C' stands for your current weapon, which you can increase or decrease by using the mouse-wheel. Doing this picks a different weapon in the array, first making sure the weapon you picked isn't "0" and ammo is greater than 0 (Otherwise skip to the next weapon and check that) and presto!

    If you need more help let me know, I'll do my best to explain it further. ;)

  • cool,i was asking more about , how , or what steps did you take to make the character pick up the weapons in the array.

    i can make an array and put my weapons there, but how do i make it so i can pick up my weapons from there ?

    is the variable cweapons connected to the array somehow?

  • The CWeapons variable is what dictates what weapon in the array you have, so yes.

    If you're talking about picking up weapons on the floor, it loops through the array until it finds an empty slot to use and puts the info in there.

    I haven't implemented dropping weapons yet, but I would do it by creating the weapon pickup object with variables storing what array values it had, and clear the values in the array it used with '0'.

    Hope this helps

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)