Zagaroo's Forum Posts

  • No problem :-)

    int(random(maxSpriteNo))+1 returns a random number of sprites to spawn and works as follows:

    -"maxSpriteNo" is the maximum number of sprites you want to spawn.

    -"random(maxSpriteNo)" generates a random float between 0 and maxSpriteNo, not including maxSpriteNo.

    -"int(random(maxSpriteNo)" removes any numbers after the decimal point of the randomly generated float, returning just the whole number - it's important to note that "int" doesn't round up, so 0.999999 will still return 0.

    -By this stage we will have whole number between 0 and maxSpriteNo-1, so we add 1 to provide a number between 1 and maxSpriteNo.

    Thank you so much for the detailed response, I understand it now! Thanks alot and have a great day! :)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • No worries, here's an example to show it in practice:

    https://www.dropbox.com/s/fpgqh7g9w87hndy/randomSpawn.c3p?dl=0

    thank u so much! Could u explain this pls: int(random(maxSpriteNo))+1 ?

    thank u again!!

  • + Condition: System: If variable = 0

    + Condition: System: Trigger Once

    ++ Sub-condition: System: Repeat int(random(yourNumber))+1 times

    -> Action: System: Create object sprite on layer 0 at (random(maxXvalue), random(maxYvalue))

    Will try later, thank u!!

  • Thanks for the reply,

    so the conditional statements would be if variable = 0 and trigger once, then the actions would be what exactly?

  • I would like to make it so that when a variable hits 0, a random amount of a sprite appear in random locations across the screen. How would I do this pls?

    -Thanks in advance ;)

  • Hi, there is probably an event interfering with the HP substract one, can you post a screen of your code or share a capx please?

    Dont worry man, I realized what it was - I had left an event that kept resetting it lol. Thanks for the help anyways!

  • Also, in case it helps, whenever I try using the randomized approach, (the one which I have the issue with), the enemies health bar appears to flicker as if it is being subtracted for a split second then reset.

  • I am testing something and am trying to make it so that when a button is clicked, 50 is subtracted from the enemies hp. The enemy's hp could either be 100 or 500, (it is randomized). For some reason, the value refuses to change. When I try with a defined enemy it works fine, however when I try to make the enemy randomized, the value refuses to go down. I have tried using both global and local variables.

    Any help would be greatly appreciated, thanks in advance! ;)

    Tagged:

  • Oh ok, thank u so much!

  • I am trying to make a demo, which consists of pressing a button. Every time u press the button, the enemy on screen, (1 at a time) would take damage until it reaches 0. Once the enemy dies, I would like to spawn an enemy with the same 'behavior', (takes damage when I press the button), but with different values for its health, (instead of 100 max hp, 200 max hp). How would I do this?

    Thanks in advance ;)