Families: Is This Even Possible?

For questions about using Classic.

Post » Fri Jul 09, 2010 9:36 am

I have recently been developing a side project for me and a friend to play. Its an interesting take on the Shmup genre. I developed it from the ground up to be fairly modular and easy to add in things such as new characters and attacks, etc.

However, I've seem to have run into a little snag...

All of the (some 10 different types for each player) bullets are grouped together in a family, 'Bullets'.

I need to set it so that the bullet with the lower PV 'Power' gets destroyed in the collision.
However...

"If 'Bullets' collides with 'Bullets'
If 'Bullets.Value('Power') > Bullets.Value('Power')'"

...obviously isn't going to cut it.

Any ideas on how to compare variables between two particular members of a family upon collision?

(If it's a step in the right direction, each type of bullet DOES have a unique 'ID' variable)
B
4
S
1
G
5
Posts: 98
Reputation: 1,648

Post » Fri Jul 09, 2010 10:39 am

Just use the private variable condition "pick with lowest value".

so your event would look like this:
[code:1ngnyzu7]+ Bullets: On collision between Bullets and Bullets
+ Bullets: Pick with lowest ''Power''
-> Sprite: Destroy
[/code:1ngnyzu7]
B
79
S
24
G
54
Posts: 4,749
Reputation: 40,761

Post » Fri Jul 09, 2010 5:23 pm

Or even easier, add all your bullet objects into two families: Bullets1 and Bullets2. Then just check for collision between Bullets1 and Bullets2, and it becomes a piece of cake to differentiate between the two colliding instances.
B
16
S
8
G
4
Posts: 136
Reputation: 3,144

Post » Sat Jul 10, 2010 12:22 am

@R0J0Hound: That method _ALMOST_ worked, except it also counts when the object collides with itself.

Basically:
P1 and P2 are shooting (pretty much rapidfire) bullets at each other, and we need to check when one players bullet collides with another players.
Each bullet DOES have a PV 'Player' that is set from 1 to 4, depending on which player used it.
That way if two players use the same character with the same attacks, it can still be differentiated.

@Daiz: That method didn't quite work, but I think I have an idea I'd like to try.

I'll post results after experimenting, for future reference.
B
4
S
1
G
5
Posts: 98
Reputation: 1,648

Post » Sun Jul 11, 2010 10:03 am

[quote="kaos":2lybd6aj]Basically:
P1 and P2 are shooting (pretty much rapidfire) bullets at each other, and we need to check when one players bullet collides with another players.
Each bullet DOES have a PV 'Player' that is set from 1 to 4, depending on which player used it.
That way if two players use the same character with the same attacks, it can still be differentiated.

@Daiz: That method didn't quite work, but I think I have an idea I'd like to try.[/quote:2lybd6aj]

How did it not work? It should work exactly as you want, since I've used the exact technique myself as well. In your case, the events would go something like this:

Conditions:
+ Bullets1 colldes with Bullets2
+ Bullets1 value 'player' is different to Bullets2 value 'player'
Actions:
- Destroy Bullets1
- Destroy Bullets2

No matter what the object is, as long as it's in two families differentiating between colliding instances is very easy.
B
16
S
8
G
4
Posts: 136
Reputation: 3,144

Post » Sun Jul 11, 2010 11:00 am

[quote="Daiz":12uk7btf]Or even easier, add all your bullet objects into two families: Bullets1 and Bullets2. Then just check for collision between Bullets1 and Bullets2, and it becomes a piece of cake to differentiate between the two colliding instances.[/quote:12uk7btf]

This method works well, but you need to use something like this as condition, using "is overlapping (advanced)" or "On collision (advanced)":

For each Bullet1
---For each Bullet2
------On collision between Bullet1 (Pick) and Bullet2 (Pick)
B
30
S
15
G
10
Posts: 285
Reputation: 7,144

Post » Sun Jul 11, 2010 12:59 pm

Ok, I ended up going with combining Aritz's and Daiz's ideas and it worked fine!
Thanks a ton guys, this was getting really frustrating :lol:
B
4
S
1
G
5
Posts: 98
Reputation: 1,648


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 0 guests