Is This Termination Method Acceptable?

This forum is currently in read-only mode.
  • In my space shooter, I so far have a single powerup weapon.

    (event 66)

    + Hero: On collision between Hero and poweruplevel2

    -> Hero: Set 'Weapons' to 1

    -> poweruplevel2: Destroy

    When the item is grabbed, and the weapon enabled, this was the only way I figured to stop it from continuing to drop.

    (event 67)

    + Hero: Value 'Weapons' Equal to 1

    -> poweruplevel2: Destroy

    Then I would allow other powerups to fall and the already enabled ones to not fall. This acceptable or there is a cleaner way?

    These are the weapon events for the ship when the above value changes from 0 to 1:

    (events 7, 8, 9)

    + MouseKeyboard: On key Space pressed

    + Hero: Value 'Weapons' Equal to 0

    + System: Bullet.Count Lower than 20

    -> XAudio2: Autoplay resource "imphenzia_soundtrack_laser36.wav" (No loop)

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

    (events 10, 11)

    + Hero: Value 'Weapons' Equal to 1

    + System: Bullet2.Count Lower than 10

    -> XAudio2: Autoplay resource "imphenzia_soundtrack_laser36.wav" (No loop)

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

  • Seems ok to me...

    I would have most likely done the same thing, but why do you repeat the "destroy" action in each event? Does it not trigger "on collide"?

    I often use collisions (or other events) to adjust a variable, then perform the actual action based on the variable change. This is probably a more common practice than most people realise.


  • I only found stopping the powerup from coming back on the screen was by constantly destroying it when the global variable was set. This is so I figure other powerups will fall except the active one to keep clutter off. As the variable changes with other powerups, it could start coming back on screen. It probably does not have to be destroyed on event 66. Just makes it look a pinch nicer than going through the ship.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Ah right, of course I guess I failed to process that correctly the first time.

    Yes I think that your method is acceptable, however you can have the condition of spawning based on the variable 'weapons'.

    [pseudo code]

    <Condition> =/= (negate) Global('Weapons') equal 1

    <Condition> Every X seconds (or whatever)

    <ACTION---> Do stuff

    [/pseudo code]

    Rather than deleting it when the conditions are met, make it so it doesn't even spawn if the conditions are met instead.

    Either way, it will be unnoticeably different in my opinion anyway, unless you are dealing with hundreds or thousands of powerups per second... so either method would be fine, I would say.


  • I see what you mean, SoldjahBoy. Thank you. Your method might be more efficient so I will give that a try and see how well it works for me. Thank you.

    EDITED to fix spelling errors.

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