Posts Tagged Flash

Posted on Programming

I made a simple haXe profiler

The other day I wanted to see at how many frame-per-second my code was running.

And so I sat down with my keyboard and a glass of water I can only assume was full at the time, and got to work.
Somehow, through a great deal more typing than was strictly necessary, what was to be an FPS display instead became a simple profiler (one that at least also displayed the FPS, I guess).


Posted on Programming

Chromatic Restitution!

Last Game Demo Festival (GDF4, if i’ve decremented correctly) I thought up a neat but simple game idea, and my implementation was truly terrible. The result? A submission known as Worst Game Demo Ever (WGDE) which shames me even today.

The problem was of course laziness.
At least some representation of physics was important to the design, and I had a very specific use of sound in mind. Without those it wasn’t so much a game demo, and very much wasn’t the one I’d intended.

I tried again with GDF5, but decided to try a physics library and settled on Box2d for flash. It wasn’t as difficult as I’d expected! I’m happy with how using it turned out. There were some strange issues that were almost definitely due to my misuse of the library, but avoidance solved those as it does most things.

In order to add a certain potential for complexity, each x position was to play a different note on collision. I totally (sorta) accomplished this using frequencies, sine waves, and the SampleDataEvent. For consistency in representation, the sound generated is stereo – loudest on the side it’s closest to (this is not the case in the example below).

Click the area below and then hit keys to play sounds

Once sounds and physics were basically implemented, I added the import game-elements including and consisting solely of an ability to accrue points. The point system works as follows:

var coeff = 1;
var bonus = 0;
var base = 10;
switch( e.value ) {
	case 2:
		coeff = 1.2;
	case 1:
		coeff = 1.4;
	case 0:
		coeff = 1.6;
		bonus = 5*(++explosionChain);
		if ( ballPool >= maxBalls )
var p:Number = base*coeff+bonus;
points += p;
dispatchEvent( new GameEvent( GameEvent.SCORE_CHANGE, points ) );
// Make it harder
if ( points > 25 ) {
	maxBalls = 2;
if ( points > 100 )
	maxBalls = 3;
if ( points > 200 )
	maxBalls = 4;
if ( points > 350 )
	maxBalls = 5;
if ( points > 600 ) {
	maxBalls = 6;

Pretty simple! The more times you hit a ball, the more points you get. If you eliminate a ball, you get a bonus proportional to the length of your elimination-chain (the number of balls you have eliminated in a row).
At certain score levels, your number of maximum balls in current play increases. If the number of balls in the ball pool is greater than or equal to that value on an elimination, a ball will be added to your ball pool. This is done so that players can’t simply eliminate the last one ball over and over.


So that is Chromatic Restitution! It’s closer to what I’d wanted, and I am happy with the result.

Of course there are some things I wish I’d added but forgot with the distraction of ever decreasing distance to deadline. Additional sound events would have added texture: wooshes when you miss a ball, some sort of triumphant ring when you eliminate one – that sort of thing.
Particles or some other animation on elimination, or even bounce (sparks) would have been nice. In general more colours, lights and sounds and movement. Casinos have taught me people love those things.

Karl added an OpenID thing to the GDF library. I attempted to add it to the GDF Overlay prior to my submission, but failed and was too tired and confused to worry about it. That would have been a nice addition as well.


Posted on Programming

Tic Tac Whatsit

Long days ago I spoke with a dentist of game demos, and of a festival dedicated to those. We talked of Ticktacktoe, a classic game of boxes and shapes — a boring, beatable game, but an easy one to program. It’d be easy to program, right? We could probably make one with flash in less than thirty minutes, couldn’t we? At least one way to find out!

Yup. Sure could!