Weapon selection?

Get help using Construct 2

Post » Fri May 17, 2013 11:06 pm

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:



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!
Phobos0022013-05-18 01:51:50
B
26
S
7
G
5
Posts: 202
Reputation: 5,235

Post » Sat May 18, 2013 1:51 am

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!
B
26
S
7
G
5
Posts: 202
Reputation: 5,235

Post » Wed Jul 03, 2013 1:26 am

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
B
3
Posts: 3
Reputation: 181

Post » Wed Jul 03, 2013 2:37 pm

[QUOTE=lareviera] 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[/QUOTE]

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. ;)
B
26
S
7
G
5
Posts: 202
Reputation: 5,235

Post » Fri Jul 05, 2013 7:59 pm

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?lareviera2013-07-05 20:01:52
B
3
Posts: 3
Reputation: 181

Post » Mon Jul 08, 2013 3:37 pm

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
B
26
S
7
G
5
Posts: 202
Reputation: 5,235


Return to How do I....?

Who is online

Users browsing this forum: GUN and 20 guests