Wednesday, February 11, 2009

Not dead (again)

Im just buzzy working ;)

I'll be posting a tile engine soon (hopefully)

..Kenneth Christensen

Tuesday, December 2, 2008

Flash 10 3d functions...

There is nothing better than playing around with a fresh set of functions in a nice API (that almost sounded like something entirely different).. the last couple of night I've been playing around with the new 3d functions in flash 10, trying to figure what's new, and what's good..

Conclusions so far..

Flash 10 does not provide Hardware accelerated 3d ...
Flash 10 does not provide Hardware pixel shaders (or vertex shaders)
Flash 10's drawtriangles work in a 2d NOT 3d coordinate space
Flash 10's not RotateX/RotateY/RotateZ functions ARE cool

As always i ended up playing around with a few things, the following code loads up a bitmap inside a sprite and spins it around in a 3d cordinate system. not exactly a "3d engine" but hey, it's moving right !

currently in working on a more "correct" apropoch to the 3d functions in flash 10, as well as a small 3d engine which will stresstest the 3d sprites ability of flash 10 to the limit ;)

code for spinning surface (download)
package 
{
import flash.display.Bitmap;
import flash.display.Sprite;
import flash.events.Event;

/**
* ...
* @author Kenneth Christensen
*/
[SWF(width = '640', height = '480', backgroundColor = '#000000', framerate = '30')]
public class Main extends Sprite
{
[Embed(source = "..\\picture.png")]
private var pictureclass:Class;

private var surface:Sprite = null;
public function Main():void
{

surface = new Sprite();
this.addChild(surface);

var bitmap:Bitmap = new pictureclass();
surface.addChild(bitmap);

bitmap.x = (bitmap.width / 2) * -1;
bitmap.y = (bitmap.height / 2) * -1;

surface.x = 320;
surface.y = 240;

addEventListener(Event.ENTER_FRAME, renderframe);
}

private function renderframe(e:Event = null):void
{
surface.rotationX++;
surface.rotationZ++;
}
}
}

Sunday, November 30, 2008

Embedding pictures in flashmovies using FlashDevelop

Embedding resources such as pictures,sounds & even other swf files was one of the first issues when I started looking into writing actionscript 3 using Flexbuilder (and now later FlashDevelop) having no previous flash experience it was a shot in the dark, but luck behold, embedding resources in actionscript 3 is just as easy as scratching your bum :)

have a look at the following code:

package
{
import flash.display.Bitmap;
import flash.display.Sprite;
/**
* ...
* @author Kenneth Christensen
*/
[SWF(width = '640', height = '480', backgroundColor = '#ffffff', framerate = '25')]
public class Main extends Sprite
{
[Embed(source = "..\\picture.png")]
private var pictureclass:Class;

public function Main():void
{
// lets declare a new bitmap based in the pictureclass above
var mypicture:Bitmap = new pictureclass();

// add it to the current stage.
this.addChild(mypicture);

// that's it really .. pretty easy no ? ;)
}
}
}


Pretty easy stuff eh ? the metadata statements in the Actionscript 3 really makes it easy for an old developer like me.

Regarding the use of FlashDevelop, a HUGE thanks flies out to Laurence Muller for posting his quickguide on developing flash 10 with debugger in FlashDevelop




I'm currently reading up on the Flash 10 3d features, and hopefully doing this week i'll be posting a few examples..




..Kenneth Christensen

Saturday, November 29, 2008

what a timeout....

Sorry guys.. this sort of thing seems to happen EVERY time I promise something..

long story short.. I quit my old job after almost 10 years (and being part owner of the company) .. and that caused "a bit of a stir" for reasons that in not going to mention here...

but, bottomline is, I'm now in a much more relaxed job which allows me to only work the allotted 37hours/week instead of doing +50 ..


future of this blog ? hopefully a lot more updates, with a few more complete projects. And also i've started using the FlashDevelop instead of FlexBuilder (was company license) so in the near future I'll make a tutorial of how to write towards Flash 10 in the FlashDevelop (so easy :))

...K Christensen

Sunday, March 23, 2008

Particle Engine - first attempt

So, time wen't by, and friends/family/kids/work came in the way of finishing the particle engine (read: I prioritized real life over this blog, so sue me ;) )

First attempt contains a rather "amputated" version of a linked list which doesn't implement any search functions or other methods normaly implemented, for the sake of "pretty design" I could of course write these methods, but it would be a waste of time.

My main focus from here on is to optimize the engine, currently I've spottede a few design flaws that could be different, and I've got a few idea's for futher optimizing.










Click here to download the source

Stay tuned ...

Thursday, March 13, 2008

Particle Engine.. theory behind it..

A particle engine, as explained in a latter post, is basically just a class/engine that can managed a large number of sprites with different alpha values.

Imagine having to control 100-150 sprites fading from 1 to 0 in alpha while moving in different directions in a normal Actionscript function...

A way to solve this is to create a generic Particle class that manages the life (and death) of each particle and does so in a way that you only once call the "AddParticle" method and from there on doesn't worry about it anymore.

First issue that arose while developing the 0.1 version of the engine was ActionScript 3.0 lack of a fast Array class for storing the particles. After googling around a bit I stumble across this project evolving around generic Game development datastructures in ActionScript 3.0

http://lab.polygonal.de/ds/

The obvious candidate for our particle engine is the "Linked list" structure... the internal Update() method in our engine class will iterate through our particles 1 at a time, but it will also need to be able to remove a given particle in the middle of our list .. so using a normal Array class would create an enormous overhead when splitting and joining the Array's after deletion.

So tonight I'll be written my own implementation of the classic Linked list structure in ActionScript 3.0 and hopefully completing the first 0.1 release of the particle engine within this week.

Tuesday, March 11, 2008

It's all just a smoke screen !

A few months ago I was given a challenge by one of our designers. They wanted a trail of smoke rising slowly from a pie as a part of a design on a customers site.

Click here to see my first draft

Needless to say it sounded like a fun little job, since it was basicly a particle engine with a few tweaks.

What is a particle engine you might ask, well the short and easy way to explain it would be that it's a engine/coding class that can keep track of multiple sprites with fading alpha values.

The sprites used can be anything from crude solid boxes to circles with higher intesity in the center.

Over the next few posts I'll be building a standard particle engine that can be tweaked into pretty much any 2d job. (3d particles is a whole other ballgame)

- Kenneth C