Sprite colision depending on color

For questions about using Classic.

Post » Wed Nov 11, 2009 10:08 am

Hello. Im have two sprite. One is shell from tank and second is tank. When shell sprite collide with tank sprite, then shell sprite is destroy. This is ok, but im need destroy shell sprite later, when is over specific color in tank sprite. Im make tank sim and im have color mask sprite, where every color have specific function. For example red is ammo, blue is armor, green is engine. It is possible make this in Construct? Thank you for answer.

PS: Sorry, but my English is bad, im not from US/UK.
B
1
G
4
Posts: 9
Reputation: 1,043

Post » Wed Nov 11, 2009 10:15 am

I'm not from US/UK either, but my English is not that bad. It pays off to practice it :)

Anyway, instead of using colour masks, why not use private variables to identify tank parts?

Like private variable named 'type', on collision check if it is "fuel", "armor", "ammo" etc.

It might make things easier.
B
62
S
21
G
12
Posts: 1,910
Reputation: 13,155

Post » Wed Nov 11, 2009 11:40 am

[quote="Mipey":2q67dy7n]

Anyway, instead of using colour masks, why not use private variables to identify tank parts?

Like private variable named 'type', on collision check if it is "fuel", "armor", "ammo" etc.

[/quote:2q67dy7n]

Thank you for reply.
Ok, but how ? Im dont known what you mean.

I don't want tons of sprites for each part of tank. Im want single sprite for single tank by reason that many sprites = low fps.
B
1
G
4
Posts: 9
Reputation: 1,043

Post » Wed Nov 11, 2009 12:59 pm

If I understand you right, you want to color pixels within tank sprite differently and use those colors for purposes of collision detection? For that have to check each pixel of the tank sprite, which uses more CPU than multiple sprites.

Maybe someone can advise you better, though.
B
62
S
21
G
12
Posts: 1,910
Reputation: 13,155

Post » Wed Nov 11, 2009 2:34 pm

[quote="Mipey":ml6bvgv3]use those colors for purposes of collision detection? [/quote:ml6bvgv3]

Yes
[quote="Mipey":ml6bvgv3]For that have to check each pixel of the tank sprite, which uses more CPU than multiple sprites.
[/quote:ml6bvgv3]
Really? :shock:

However, i must use many of sprites ... or any idea?
B
1
G
4
Posts: 9
Reputation: 1,043

Post » Wed Nov 11, 2009 3:32 pm

Just use many instances of the same sprite, with a private variable to differentiate part type. It won't slow things down. However, if you want instances of tanks with multiple hitboxes, then it will be more convenient to have many different sprites, so that you can just make the tank a single contained object (since you can only have 1 instance of a sprite per container).
B
25
S
3
G
6
Posts: 1,197
Reputation: 5,620

Post » Wed Nov 11, 2009 6:34 pm

Just go with several different sprites. This will also make complex interactions easier in the long run.
You could, for example, have several different collision masks or even images for each part. Run effects on them, spawn fire/particles from their exact location, etc.
B
3
S
2
G
4
Posts: 1,445
Reputation: 4,665

Post » Wed Nov 11, 2009 7:50 pm

Thank you for ideas.
I want make much tanks, infantry, layered buildings, etc in one moment on layer. The game will be strategy with penetration value/destroyable parts.
How many sprites manage Construct with good framerate on average computer? I don't know how realize this game with relative good fps.
B
1
G
4
Posts: 9
Reputation: 1,043

Post » Wed Nov 11, 2009 8:16 pm

Hundreds, thousands, hundreds of thousands, it all depends on the size of the sprite.
Creating multiple instances of the same sprite, organized by private variable, and image points is your best option.

sprite private variable = 1
>blank sprite set position to sprite at image point gas
Image Image
B
161
S
48
G
90
Posts: 7,354
Reputation: 66,763

Post » Thu Nov 12, 2009 3:06 am

[quote="newt":1uve3sej]Hundreds, thousands, hundreds of thousands, it all depends on the size of the sprite.[/quote:1uve3sej]
No, I wouldn't go over 2000-3000 regular size sprites onscreen at any given time, (<128x128) if you want to maintain good frame rate on modern non gaming pcs. Even with a 4x4 sprite, fps will slow down displaying over 15000 of them (on my fairly modern pc (8300 GS)), and that's without any events processing on them. Construct cannot handle hundreds of thousands of sprites effectively. However, fps all depends on your game. Start using shaders and you'll see slowdown a lot faster than displaying a lot of sprites.
B
25
S
3
G
6
Posts: 1,197
Reputation: 5,620

Next

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 1 guest