Click to See Complete Forum and Search --> : Jotaf - Particle Systems Help
Mushroom Realm
Aug 18th, 2002, 11:29 AM
I read ur paper on particle systems, and i downloaded all the forms, and i tried to understand as much as i could. But some of it i just cant make sense of. I was wondering how u got it to draw so fast? And i was always wondering if u could try to explain how it works a little. I wanted to make some of my own custom systems, but i just cant make sense of it.
Sastraxi
Aug 18th, 2002, 12:35 PM
He uses SetPixel which is pretty fast - I can get loads of effects running on a GF2mx/cel 533, which is great. But it's not the fastest way... Basically his particle systems loop through the particles, do math on them to update the position, and then draw them. They follow that loop until they "die" (different for every particle system, for example if they're offscreen), and then they're created again. It's quite simple really.
Mushroom Realm
Aug 18th, 2002, 02:15 PM
Ive been trying to understand the rain system for a game im making. But i want the rain to run in front of all the pictureboxes. If i copy and paste the code it will go behind all my pictureboxes except picfront.
Sastraxi
Aug 18th, 2002, 05:09 PM
That's because the picturebox itself is behind all the pictureboxes... Look up a technology called BitBlt. BitBlt all your pictureboxes to one FRONT picturebox, and then use the particles over it. In this way, you can have animated pictures, transparency (ex. a colour in the bitmap is seethrough), etc.
It's a real evolutionary step in games development.
Mushroom Realm
Aug 18th, 2002, 06:05 PM
so should i blit the background, then the pictureboxes, and then the rain, that way it will have background in back pics in middle and rain up front? How could i blit the rain with transparency.
Sastraxi
Aug 18th, 2002, 06:27 PM
If you're using his code, it already does it.
And yes, that's the order you do it in.
Jotaf98
Aug 18th, 2002, 06:53 PM
*phew* Sorry I'm so late :D
Ok, huh it's like Sas says it's really simple... I can't explain the effect better than him. You have a lot of particles, each one is a rain drop. Every frame, the code just loops trough each one of them, moves it a bit down or to the left or whatever, if it's reached the bottom of the screen it moves the rain drop back up, and then draws it to the screen.
The main reason why it's fast is because it doesn't have to draw a lot of pixels. If you think about it, an image that is 100 pixels by 100 pixels in size has to draw 10,000 pixels. If you have a rain effect with 100 rain drops, 3 pixels each, you only draw 300 pixels!
Anyways... I don't get it, how are your pictureboxes set up, what are you trying to do with them? Usually you only have one big picturebox where you draw everything...
Sastraxi
Aug 18th, 2002, 07:18 PM
Yeah, I explained it to him, about Bitblt, I think he's all set now :)
Jotaf98
Aug 18th, 2002, 07:28 PM
Heh ok thanks Sas :)
Sastraxi
Aug 18th, 2002, 11:48 PM
Hrm? Thanks for what?
Jotaf98
Aug 20th, 2002, 04:23 PM
You explained all the bitblt stuff to him, so I don't have to explain anything :p
Sastraxi
Aug 20th, 2002, 05:47 PM
I doubt you would've if I hadn't :D
Hehe :)
Jotaf98
Aug 20th, 2002, 06:01 PM
Yeah you're right... I would probably do like most people here and give him some links ;)
Amithran
Aug 20th, 2002, 06:26 PM
Youve got PM's jotaf.
Btw, does any one know if theres a way to "bitBlt" from an array to an hdc? If i've got an array the size of the screen with rgb info, and rather then setpixel each onto an hdc is there a way to "bitblt" it.. ??
Jotaf98
Aug 20th, 2002, 08:08 PM
I know, I checked my PMs like 5 minutes ago :p
Use StretchDIBits, they use it to convert from an array to a DC and from a DC to an array ;)
Sastraxi
Aug 20th, 2002, 09:30 PM
StretchDIBits is an amazing call :) I suggest you learn all of its ins and outs.
Mushroom Realm
Aug 20th, 2002, 09:33 PM
Just curios is this technology really called particle systems??
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.