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

Get help using Construct 2

Post » Sat Apr 04, 2015 12:52 pm

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.
B
10
S
3
Posts: 109
Reputation: 1,080

Post » Sat Apr 04, 2015 3:41 pm

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.
B
15
S
5
G
7
Posts: 876
Reputation: 5,650

Post » Sat Apr 04, 2015 3:49 pm

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?
B
10
S
3
Posts: 109
Reputation: 1,080

Post » Sat Apr 04, 2015 4:07 pm

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.
B
15
S
5
G
7
Posts: 876
Reputation: 5,650

Post » Sat Apr 04, 2015 4:11 pm

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.
B
10
S
3
Posts: 109
Reputation: 1,080

Post » Sat Apr 04, 2015 4:43 pm

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
B
15
S
5
G
7
Posts: 876
Reputation: 5,650

Post » Sat Apr 04, 2015 4:46 pm

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.
B
10
S
3
Posts: 109
Reputation: 1,080

Post » Sat Apr 04, 2015 5:01 pm

hmmm seems I misread... :}

POOPY SPAWNER

That what you mean?
B
15
S
5
G
7
Posts: 876
Reputation: 5,650

Post » Sat Apr 04, 2015 5:04 pm

based on your example going to have to think about this further looks like it is what I need, many thanks!
B
10
S
3
Posts: 109
Reputation: 1,080



Return to How do I....?

Who is online

Users browsing this forum: No registered users and 14 guests