help - identifying too many sprites on screen

Get help using Construct 2

Post » Wed Feb 06, 2013 5:06 pm

First I'd like to say thank you to everyone who has contributed to these forums and the tutorials. I wouldn't have made much progress without the help I've found in your answers to others questions and in your tutorials.

Now on to my question:

I have a game where you have to stop sprites before they spawn. So, if you don't act fast the sprites spawn more sprites, and those sprites spawn more sprites,etc - until the screen is jam packed with sprites in which case - game over.

I'm trying to figure out how to have an event detect that there are too many sprites on the screen. All sprites are solid, and contained within the screen. So they are bouncing off each other, and bouncing back off another sprite, spawning endlessly.

The sprites are all different sizes, so I can't go by numbers of sprites. I'm currently attempting to record the location of a sprite in an instance variable and every 2 seconds compare the current location to the instance variable - but it isn't working very well (possibly because the sprites are still moving, even if they are just juttering in a tight area).

Is there a good way to test if the screen is overpopulated with sprites?

TIA!
B
10
S
3
G
3
Posts: 29
Reputation: 2,692

Post » Wed Feb 06, 2013 6:58 pm

How about giving each sprite type/size a numeric value based on the amount of pixels the sprite occupies. Let's say small sprite (16x16px) 256, medium (32x32px) 1024, big (64x64px) 4096.

Sprites don't have to be square - as long as you approximately know how big they are you'll be fine.

Create a variable in the layout, each time a sprite is spawned add it's value to the variable.

Check how big is your layout (800x600px has 480000 pixels) when the sprites occupy let's say 50% of the layout (so when the variable is equal or bigger to 240000) initiate GAME OVER.

Experiment with how much of the layout you want to be occupied both game-play and performance-wise.
VonBednar2013-02-06 22:54:45
B
16
S
3
G
5
Posts: 44
Reputation: 3,231

Post » Wed Feb 06, 2013 8:54 pm

Thanks. I will try that and report back! :o)
B
10
S
3
G
3
Posts: 29
Reputation: 2,692


Return to How do I....?

Who is online

Users browsing this forum: Colorfish and 4 guests