Comparing Bullet Count and STOP (Hammer Time!)

For questions about using Classic.

Post » Sun Aug 14, 2011 12:42 am

I am trying to do some sort of loop or comparison bit here but not working out. I have read some posts but some either not worked for me (they were based on time) or for Construct 2.

My ship can fire two types of bullets at this time. Its default and then the first power up:

+ MouseKeyboard: On key Space pressed

+ Hero: Value 'Weapons' Equal to 0
-> System: Create object Bullet on layer 1 at (0, 0) from Hero 's image point 1
-> XAudio2: Autoplay resource "imphenzia_soundtrack_laser36.wav" (No loop)

+ Hero: Value 'Weapons' Equal to 1
-> System: Create object Bullet2 on layer 1 at (0, 0) from Hero 's image point 2
-> System: Create object Bullet2 on layer 1 at (0, 0) from Hero 's image point 3
-> XAudio2: Autoplay resource "imphenzia_soundtrack_laser36.wav" (No loop)

What I am trying to do is make it that only X shots can be present on the screen at anytime, like 10 or 20 bullets. This way, stronger weapons, like bullet2 will be, will not make the player near invincible.

I figured i would use some sort of comparison, making a global variable for each bullet type, but just not working out when I am looking at the options and trying to figure it out.

Thank you for any help.

=========
Christian, ninja, warrior, Borg, Time Lord... I am that hero!
B
5
S
1
G
1
Posts: 157
Reputation: 1,219

Post » Sun Aug 14, 2011 12:52 am

The easiest would be to add a condition to both Hero conditions. It will compare against Bullet.Count and Bullet2.Count:

+ Hero: Value 'Weapons' Equal to 0
+ System: Bullet.Count + Bullet2.Count less than n

where n = any number of bullets you want as max.tulamide2011-08-14 00:53:14
Image
B
23
S
8
G
10
Posts: 1,820
Reputation: 8,242

Post » Fri Sep 02, 2011 6:48 am

See, I got to learn these THING.THING bits. Never could figure those conditions out in C++ either.

I will try this out, tulamide, and let you know.

Thanks.
B
5
S
1
G
1
Posts: 157
Reputation: 1,219

Post » Fri Sep 02, 2011 7:36 am

I just tried this and then realized I may not have clarified myself and confused the matter with the two different weapons. It does not fire both weapons at the same time. Bullet2 is an upgrade. Let me just clarify with focusing on only one weapon to not confuse anyone anymore.

The default weapon is "Bullet" when the game starts, and Hero's private variable "Weapons" is 0 (this is for upgraded weapons).

So, game starts and Hero uses main weapons:

+ Hero: Value 'Weapons' Equal to 0
-> System: Create object Bullet on layer 1 at (0, 0) from Hero 's image point 1

Okay, I do not want player being able to pound on SPACEBAR. I want to make it where only X beams are on the screen at a time. I tried a modification of your example above, using just Bullet:

+ Hero: Value 'Weapons' Equal to 0
-> System: Create object Bullet on layer 1 at (0, 0) from Hero 's image point 1
-> XAudio2: Autoplay resource "imphenzia_soundtrack_laser36.wav" (No loop)
+ System: Bullet.Count Lower than 5

But if this is it, then I must be missing something because I can still shoot more than the 5 limit I put above.

Obviously, am still learning. I only get a few hours a month playing on Construct.

Thanks.
B
5
S
1
G
1
Posts: 157
Reputation: 1,219

Post » Fri Sep 02, 2011 7:59 am

If your code example is exactly what you've done, then you are setting an event with a condition and no action after the event where the bullets are spawned. That doesn't work.
You need to have one event with 2 conditions, like so:

+ Hero: Value 'Weapons' Equal to 0
+ System: Bullet.Count Lower than 5

This is one event with two conditions, and both of them need to be true, before the actions of that event (Creating the bullet and playing the sound) are performed.

Edit: btw, you are generating one bullet per tick, when using the events without some timing. So the four bullets you allow, will be created within 4 ticks. If your game runs with 60 fps, that's a timespan of 0.067 seconds. It is most likely that you will see them very close to each other, if not one above the other (giving the impression of having only one bullet)
If you want them to fire at a certain rate, you should consider adding a time counting method.tulamide2011-09-02 08:04:50
Image
B
23
S
8
G
10
Posts: 1,820
Reputation: 8,242

Post » Sat Sep 03, 2011 6:57 pm

That seems to have worked. Events 7-9 with actions 9.1 & 9.2:

+ MouseKeyboard: On key Space pressed
+ Hero: Value 'Weapons' Equal to 0
+ System: Bullet.Count Lower than 5
-> System: Create object Bullet on layer 1 at (0, 0) from Hero 's image point 1
-> XAudio2: Autoplay resource "imphenzia_soundtrack_laser36.wav" (No loop)

Thank you.
B
5
S
1
G
1
Posts: 157
Reputation: 1,219


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 7 guests