Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Chat / [Tier 1] trouble with pixel particles

Years of Service
User Offline
Joined: 7th Jun 2017
Posted: 5th Jan 2018 20:35
I was trying to make a simple toy for a 1½ year old kid, but got stuck on how to make the best pixel particles.

Since pixels are way small, I need a LOT of particles! But it looks like SetParticlesFrequency () only accept a max of 500 particles per second. Of course I can always create several sets of particles, but I don't like trying to hack it to support way more particles than it seem to be designed for.

I guess a 1x1 pixel sprite will take less effort to draw than a 16x16 pixel one. But I don't know where the bottleneck is. Perhaps it would be more effecient to create a larger sprite, like 16x16 pixels with 7 pixels in it, instead of seven 1x1 pixel sprites?

And when I run the app, it sometimes just goes black at startup. No idea what that is about!


Login to view attachments
AGK Developer
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 7th Jan 2018 02:38
I never got the built in particle system - it never seemed to do what I wanted it for.

It's easy enough to make your own system though and i think it's more flexible to do so.

In your example though, the actual number of particles are probably the issue. For such amounts, it may be better to write your own pixels to the draw buffer - the particle engine in AppGameKit isn't really going to cut it, as it's just going to be a bunch of optimised sprites.
I always found the inbuilt particles to be quite expensive to use and therefore stopped using them some time ago.
Years of Service
User Offline
Joined: 7th Jun 2017
Posted: 8th Jan 2018 22:23
Good idea!

To start out, I will need a Type to keep track of each individual particle. Something like this:

type _pixelParticles
x as Float
y as Float
speed as Float
dir as Float
life as Integer
// Lotsa more things, I guess

global pxFX as _pixelParticles[2000]

The color change over time could be hardcoded into an array. This could save some calculations.

I guess DrawLine() is the most efficient way to create a single pixel. I have a bit of trouble determining if it draws a nice looking pixel, as I can't get it to save to a screenshot.

I need to create the particle movement
I need to keep track of used particles. (this one's a biggie)
Valued Member
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 8th Jan 2018 22:37
here is an example. agk have also drawsprite or clonesprite command.

you need once ParticleInit()
then in loop ParticleUpdate()
after loop / next level ParticleRemove()
at end ParticleFreeAll()
AGK (Steam) V2017.12.12 : Windows 10 Pro 64 Bit : AMD (17.12.1) Radeon R7 265 : Mac mini OS High Sierra (10.13)
Years of Service
User Offline
Joined: 7th Jun 2017
Posted: 11th Jan 2018 00:55
Hi Markus, thanks a lot for sharing your code! I'm still reading up on it, but the charger cable of my Surface PC died (again) so I'm not as active as I could be. I just got a friend to charge it, so I'm in power now, even though much of it will be consumed by a heavy-duty Photoshop script.

Anyways, your code is reasonably easy to understand! Still, I screw up something when I tried to implement it. Can I trouble you for a fully working example? (It is sometimes a bit uphill to implement and trying to understand a piece of code at the same time!)

Login to post a reply

Server time is: 2019-01-19 07:55:36
Your offset time is: 2019-01-19 07:55:36