Game Devigner

Tag: design

Space ROX – Under Fire

by Paolo on Feb.03, 2009, under Experiments, Programming

Space ROX V 0.3

Space ROX V 0.3

Now, using a mix of local and global coordinate magic, we can put a laser blast on the correct firing points of the Space ROX ship – one on the left and one on the right using alternating fire. Rather than using some complex math to figure out the scale and rotation of the ship MovieClip, I can derive where I need to put the laser blast picture.

Check it out!

Leave a Comment :, , , more...

Space ROX – Local, Screen, and World

by Paolo on Feb.03, 2009, under Experiments, Programming

When it comes to displaying graphics, the most common question a program must ask is “Where is it?” It may seem like a straightforward question, but it has a lot of complex nuances. Take for instance the image below of the ship in Space ROX.

Space ROX's Local Coordinates

Space ROX's Local Coordinates

Now, the rotation point of the entire graphic is at the center of the ship. Right below the ship is the rear thrusters firing. When the ship is accelerating and I need to draw a particle effect, I need to find out where the tip of the rear thrusters are as the origin of the particle. When I ask ActionScript 3.0, what is the x,y coordinate of the RearThruster, it simply says it is at 0,190. But this is local coordinates – it doesn’t matter which way the ship is rotated or how much it has been scaled.

Space ROX Rotated and Scaled

Space ROX Rotated and Scaled

What Actionscript 3.0 offers is a function called “localToGlobal” which can tell me where a local point in this movie clip is in relation to the screen’s coordinates.

This is great, but it has one major flaw in terms of game programming.  The “localToGlobal” function only tells you the coordinate of the object in relation to the screen – not in relation to the world.  If the camera and background never move like in the first versions of Asteroids, then this is sufficient information that we need.  But once the camera starts moving around a world, then we need to convert Actionscript’s “global” coordinates to the “gameworld” coordinate plane to ensure that if the camera moves, the particles and effects, correctly shift along with the camera.

What is so painful about this is that my original approach to solving the local-to-screen-to-world coordinate system is that I was trying to figure it out using what little I remember of Trigonometry.  It was a relief to see that Adobe went through the trouble of creating a build-in and optimized version of what I was attempting to write.

Leave a Comment :, , more...

Space ROX – Particles and Polish

by Paolo on Jan.28, 2009, under Experiments, Programming

Space ROX V 0.2

Space ROX V 0.2

One of the markings of a professional game vs amateur game is the amount of polish is put into the final product.  Everything from the art, sound, game control must be fine-tuned into a mirror shine.  One of the simple ways of adding that touch to any game are particle effects.

For Space ROX, the first particle effect I added was a thruster trail.  Rather than simply turning on and off the rear thruster animation, I added an actual trail to show where the ship has been.  This is accomplished with a simple “particle” effect.

To create a particle in Flash you don’t need a complex library that some 3rd party sells you.  A particle can simply be a MovieClip object that is dynamically added to the scenegraph and then removed once the animation is over.  In this case, the thruster vapor trail is just a green ellipse that fades to zero opacity and then removes itself from its parent.

It’s a simple programming object, but you can already see the results - an effect that shows that more thought was put into the game, and a little polish that can make all the difference from appearing as an amateur – or a seasoned pro.

Check it out!

Leave a Comment :, , more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Blogroll