Comparing Bullet Count and STOP (Hammer Time!)

This forum is currently in read-only mode.
From the Asset Store
This pack contains 10 types of bullet effects, with different shapes and colors.
  • 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!

  • 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.

  • 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.

  • 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.

  • 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.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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.

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