How do I make the bullet amount equate to food amount?

  • Hi,

    Sorry if the pro frantic nature of this offends anyone I have tried to censor where necessary.

    http://picpaste.com/problem-nTQDsYSD.png

    First of all the food amount is defined by how many I place on the level so for food I have added a instance variable of 1 so say if I paste two food sprites on the level 1 + 1 = 2 from the instance variable.

    As per the image how do I equate that to the amount of bullets? I added a instance variable also of 1 to S*** which is my bullet, so when it spawns a bullet I want it to shoot out the same amount of bullets as there is food in the level?

    If anyone is interested I am trying to create a feeding mechanism as I thought it would be an interesting project to help me learn Construct 2 better.

    Don't know if this is making it to complex say you had 2 bits of food equal two bullets, how would I say make bullet one shoot out of blob at say 35 degree and then say bullet 2 shoot out at double that angle which is 70 degrees and so on, perhaps global variable increments of 1?

    If anyone could tell me what I am doing wrong or correct my attempt would be much appreciated, I feel like I am getting no where and this is the best solution I have come up with so far. I think I am getting very confused with my logic and variables.

  • Use the Sprite object's Count like..

    global variable TotalFood

    START OF LAYOUT

    • TotalFood = Food.Count

    and go from there.

    The easiest method for shooting your bullets is to do bulletangle = 360 / TotalFood

    That will give you the perfect spacing no matter how many food instances are on the level.

    I may have more time later, but hopefully this helps you get started.

  • Ok thats a good start thanks. Additionally hows can I get the bullets magnetising now to the Player sprite, I noticed when I drop 6 food pellets it only generated 2 bullets?

  • global var bullet_angle_inc = 0

    global var TotalFood = 0

    START OF LAYOUT

    • TotalFood = Food.Count
    • bullet_angle_inc = 360 / TotalFood

    PLAYER ON COLLISION WITH FOOD

    • For "count" = 1 to TotalFood

    -- Spawn bullet

    -- Set bullet angle to loopindex * bullet_angle_inc

    Hopefully this helps a little more.

  • Ok for the last bit:

    PLAYER ON COLLISION WITH FOOD

    • For "count" = 1 to TotalFood

    -- Spawn bullet

    -- Set bullet angle to loopindex * bullet_angle_inc

    If you could please be a bit more specific as having trouble seeing how to put this into construct 2 event sheet?

    Many thanks for your help so far.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • PoopyShoot

    I believe that's what you're after. There are a few issues with it, like if you collect one food, and then you collect another before the first has a chance to spawn bullets, then the 2nd pickup number of bullets will be the exact same as the first.. if that makes sense :} So count that as some homework for you ;p

  • All the food is collected at the same time, it is dropped from a trap door and reaches the mouth all at the same time instantly. I am more lost now.

  • hmmm seems I misread... :}

    POOPY SPAWNER

    That what you mean?

  • based on your example going to have to think about this further looks like it is what I need, many thanks!

  • No problem

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