r3dux.org

A number-pimping side project from the valleys in *NEW* upside-down flavour.

  • Home
  • ABOUT
  • OLD SITE
  • SEARCH
  • FEEDBACK

How To: Create a Simple Fireworks Effect in OpenGL and SDL

r3dux | October 31, 2010

I’m teaching the programming stream for Diploma in I.T. – Multimedia at the moment, so we’re going to be making some simple games and things over the next couple of months, but to start them off we’re doing a little bit of work on particle effects because they’re simple and fun – you just write a single class which describes the properties and behavior of your particle, and then scale it up by adding a large number of particles to get some pretty nice effects.

So instead of doing a particle fountain, I thought some fireworks might be kinda neat… Take a swiz at the video below and see what you think!

YouTube Preview Image

Full C++ source-code available after the break for those of a curious nature =D

Read the rest of this entry »

Comments
8 Comments »
Categories
Coding, How-To
Tags
Accumulation, Blur, C++, Effects, Fireworks, Motion, OpenGL, Particle, SDL, Trails
Comments rss Comments rss
Trackback Trackback

ActionScript 3.0: Variable Size Particle Collisions

r3dux | January 25, 2010

Ha! I’ve cracked it! This really shouldn’t have taken me as long as it did to get working, but now I can have pegs and balls of any size I fancy, and the collision detection works flawlessly. No more cheaky bodges to avoid double collisions, proper trig. offsets all the way… In fact, the only bodge left is adding a slight horizontal speed jitter to a ball if it ends up with a horizontal velocity of < 0.01 after a collision, because if it's bang over over the centre of the peg it'll stay there happily bouncing away until it comes to rest otherwise - which I think is fair enough.

So after all the additional hours, does it look any better? Nope… If anything it looks worse – but she’s my baby, and I’ve finally got ‘er working properly, so I don’t care! :D

Update: And by flawlessly, I mean that I’ve just noticed a very small ball going fast will go through a very small peg, because they never intersect… Drats! Guess I’ll have to check for ranged collisions (or increase the minimal ball/peg size, or limit the movement speed). Nothing’s ever easy, is it?

Comments
No Comments »
Categories
Coding
Tags
ActionScript, Collisions, CS4, Flash, Particle, Size, Variable
Comments rss Comments rss
Trackback Trackback

ActionScript 3.0 Particle Systems #6: Particle Attraction

r3dux | January 19, 2010

More ActionScript… This time we’re attracting the particles towards the mouse cursor when the distance between them is low enough… Looks alright, just a kinda fun effect & dead simple to code.

Source code and flash files on the flipside…

Read the rest of this entry »

Comments
No Comments »
Categories
Coding
Tags
ActionScript, ActionScript 3.0, Adobe, Attraction, CS4, Effect, Flash, Motion, Particle, Systems
Comments rss Comments rss
Trackback Trackback

ActionScript 3.0 Particle Systems #5: Smoke Effect

r3dux | January 15, 2010

I’ve basically spent the day trying to get this one right, and it’s not too bad, although it’s pretty heavy on the CPU. Really, you want about 150 particles and a slower fade out, or 150 particles and add two per frame instead of just one, but on my rig it’s getting jerky with that many particles, so in the animation below we’ve got 80 particles as a compromise =( Also, because we’ve only got 80 particles I’ve deliberately ramped up the alpha decay (i.e. how quickly the particles fade out) and upped the vertical speed to get them off the stage before the particle is forced to vanish by our particle limit. If you put the mouse cursor right down near the bottom of the stage and look at the particles at the top you’ll just catch them vanishing instead of fading out fully, but these are the compromises we make for a smoother framerate ;)

If it’s running poorly on your machine, try right clicking on the stage and lowering the quality, or just grab the files from after the jump and mess around in Flash CS4 (free trials available) with all the different variables (especially the ones that start with min or max!!).

I’ve set the window-mode to use GPU acceleration on this one, so if nothing displays and you’ve got an older graphics card (and you want to see it), just view the source code for this page, grab the object section and change wmode=”gpu” to wmode=”direct”.

Credits: LearnFlash.com’s particle systems vids for the how-to, kaioa.com for the FPSCounter Class, and me for coding it up and running with it!

EnJoY!

Update: I’ve modified the above example to use the RateController Class I wrote yesterday. Aside from adding a RateController object, the only other modification was adding a listener to toggle the animation on a MOUSE_LEAVE event (cursor leaving the stage), and then changing the toggleAnimation function to wait for a click (and not MOUSE_MOVE i.e. cursor returns to stage) before adding particles again. Too easy… :)

Update 2: Many thanks to Joel for pointing out that in my zeal to optimise things I’d actually added some null pointer errors as well as some extra fps, and for correctly suggesting that using Sprites instead of MovieClips would result in a small speed boost, too. The swf file above and code & zip file below have received suitably stern words, and everything now works (relatively) swiftly and error free.

As usual, source code and flash files after the hop skip jump…

Read the rest of this entry »

Comments
3 Comments »
Categories
Coding
Tags
ActionScript, ActionScript 3.0, Adobe, CS4, Effect, Flash, Motion, Particle, Smoke, Systems
Comments rss Comments rss
Trackback Trackback

ActionScript 3.0 Particle Systems #4: Bubbles

r3dux | January 13, 2010

Yet more ActionScript 3.0 again! This time it’s a kind of 2D particle fountain. New in this iteration is code so we can pause and resume the animation instead of just start/stopping it, and each bubble’s colour gets subtley modified via colorTransforms.

Last one for the day methinks – I’m knackered. Happy, but knackered :)

As usual, source code and flash files after the jump for those of a particularly masochistic bent…

Read the rest of this entry »

Comments
No Comments »
Categories
Coding
Tags
ActionScript, ActionScript 3.0, Adobe, Bubbles, CS4, Effect, Flash, Motion, Particle, Systems
Comments rss Comments rss
Trackback Trackback

« Previous Entries

Translate

Categories

Archives

Tags

3D ActionScript ActionScript 3.0 Adobe AI Ballarat Bash C++ Class Convert CS4 Effect Error Film Flash GLSL Gnome Hack How-To install Jaunty Java Kinect Linkage Linux Mash-Up Microsoft Motion OpenGL Particle Problem PS3 Remix Retro script Slides Sound Systems Texture Ubuntu Video VirtualBox Wii Windows XBox

Gamercard

OpenR3dux

Misc.

Flattr this

RSS Feed

r3dux twitter feed



“Life reverses local entropy.”

rss Comments rss valid xhtml 1.1 design by jide powered by Wordpress get firefox