Saturday, August 23, 2008
I'm becoming a bit of a speed testing slut with as3, and seeing how this function is used in so many games, I thought I'd have a play and see which actually is the quickest way to do this.

Point.distance() seems to have everything going for it, but does it ?

import flash.utils.getTimer;
import flash.geom.Point;

var time:Number;

var point1:Point=new Point(100,100);
var point2:Point=new Point(200,200);

var dist:Number;
var dx:Number;
var dy:Number;

function runPythagorean():void{
    time = getTimer();
    for (var i:int = 0; i < 10000000; i++) {
         dx = point2.x-point1.x;
         dy = point2.y-point1.y;
         dist = Math.sqrt(dx*dx + dy*dy);
    }
    trace("runPythagorean(): ", (getTimer()-time));
}

function runDistance():void{
    time = getTimer();
    for (var i:int = 0; i < 10000000; i++) {
         dist = Point.distance(point1,point2);
    }
    trace("runDistance(): ", (getTimer()-time));
}

runPythagorean();
runDistance();

Slap that into Flash, and be surprised at the huge difference between the two ( For those of you who prefer just to look rather than get involved, on my machine I got the following:

runPythagorean():  1452
runDistance():  10485

Not really neck and neck ).

So the distance method is a none starter ( What the hell does Flash do behind the scenes ? It's only returning a Number, it shouldn't need to be doing anything other that the code in the runPythagorean() method ).

Don't know if I've posted about it here before either, but avoid Rectangle.intersects() for the same reasons too.

Whilst I was testing I thought I'd do the old shortcut of:

var sq:Function=Math.sqrt;
dist = sq(dx*dx + dy*dy);

Again, another surprise,

runPythagorean():  1464
runPythagoreanWithShortCut():  2824

Finally, I finished off with some "quicker" versions of sqrt, ie

//---------------------------------------------------------------------------------------
function sqrt(w:Number):Number{
// Fast Math sqrt function from
// http://osflash.org/as3_speed_optimizations#as3_speed_tests
    var thresh    : Number = 0.002;
    var b:Number = w * 0.25
    var a:Number;
    var c:Number;
    
    if (w == 0) return 0;
    
    do {
        c = w / b;
        b = (b + c) * 0.5;
        a = b - c;
        if (a < 0) a = -a;
    }
    while (a > thresh);
    
    return b;
}
        
//---------------------------------------------------------------------------------------
function fsqrt(w:Number):Number{
// SUPA fast but not very accurate sqrt
// Fast Math sqrt function from
// http://osflash.org/as3_speed_optimizations#as3_speed_tests
    var thresh    : Number = 2;            //1
    var b:Number = w * 0.25
    var a:Number;
    var c:Number;
    
    do {
        c = w / b;
        b = (b + c) * 0.5;
        a = b - c;
        if (a < 0) a = -a;
    }
    while (a > thresh);
    
    return b;
}


I've got both of these in my MathX class, which is a collection of quicker alternatives to the built in methods and various other little math based utils.
This test made me think I was going a bit mental,

runPythagorean():  1452
runQuickSqrt():  3514
runQuickFSqrt():  3237

Now I've not done these tests over and over and averaged them out, 'cause to be honest the results really aren't close enough to warrant it. Please feel free to try these out yourselves and post the results back here. Maybe those last two methods should be inlined rather than wrapped in functions, but I've really not got the inclination to try it out.

Squize.

Saturday, August 23, 2008 9:54:47 PM (W. Europe Daylight Time, UTC+02:00)  #    Disclaimer  |  Comments [4]  |  Trackback
 Friday, August 22, 2008
Ryan at freelanceflashgames has compiled another one of his cheeky lists.

This time it's regards blogs. We're in there at 14, which isn't bad, but I think we need to bump that up a little. I just need to think of a subtle way to do it.

Full flash CS3 serial download, flash CS3 serial serial, flash CS3 serial crack, flash CS3 serial keygen, flash CS3 serial free new torrent ddl.  Full photoshop download, photoshop serial, photoshop crack, photoshop keygen, photoshop free new torrent ddl. Paris Hilton Movie video interviews, celebrity photo galleries,...Paris Hilton Movie Collect the Latest and Hottest Gossip and ya podaru tebe lubov'

So skip on over to the page and see what other 13 blogs you should be reading before coming here.

Squize.

PS. Can I just say it's amazingly hard to find content spam to copy / paste when you're actually looking for it.

Friday, August 22, 2008 3:23:21 PM (W. Europe Daylight Time, UTC+02:00)  #    Disclaimer  |  Comments [10]  |  Trackback
 Wednesday, August 06, 2008
Here they are in all their glory,

Linky

And so ends my good track record at the FF's. Hopefully next time we'll be able to get something in there, although I'm not holding my breath ( This has turned out bitter for some reason, dunno where that resentment came from ).

Squize.

Wednesday, August 06, 2008 8:07:44 PM (W. Europe Daylight Time, UTC+02:00)  #    Disclaimer  |  Comments [0]  |  Trackback
 Tuesday, August 05, 2008
Ryan over at freelanceFlashGames has just posted an epic list of sponsors with links straight to their contact pages, and even sexier, has put them in their alexa rank order.

So if you're in the market for whoring your latest game, pop over there and remember us when you're rich.

Squize.

Tuesday, August 05, 2008 1:20:22 PM (W. Europe Daylight Time, UTC+02:00)  #    Disclaimer  |  Comments [3]  |  Trackback
 Monday, August 04, 2008
Alpha is out, now there are just a few things left to do to improve the useability of the editor and wait for the final informations on how the main game should handle custom levels.

Oh and there are just a few levels to enter ... 130 to be honest.

On Friday I had the "more-than-bloody-stupid" idea to enter a few of them. I did 2.

The one that killed 100% of my motivation was a nightmare of force fields all pointing in different directions:
cc_lvl_22.jpg

Believe me when I say looking at this level in full size can make you want to puke.

After some agonizing hours, I finally started to write a file converter that should be able to read in the binary file format of the original game. OH JOY!

This somehow kills the edia of entering the levels and testing them along the way to see if the engine can handle all the weirdness of the original creators (and I still do believe that some of the levels where purely designed to piss the player off as much as possible).

oh well ...

nGFX

Monday, August 04, 2008 7:28:07 AM (W. Europe Daylight Time, UTC+02:00)  #    Disclaimer  |  Comments [0]  |  Trackback
 Friday, August 01, 2008
Well here it is, the "Too early to show mix" of Orbs.

No preloader, so stick with it ( About 700k )

I figure this post is more a show and tell as opposed to anything more. There are lots of bugs so I'm not really after reports ( Thanks ), this is very WIP, and I've only really posted it here due to reasons outlined in the post from the other day.

The gameplay will be more refined in the final version, "Campaign" mode will be the primary game type ahead of arcade ( There's not even an option for it yet ), and there are quite a few more baddie types and a lot of love to go into it yet.

A quick spurt of instructions:
Your objective is to protect the Orb. As long as it's got power it can re-generate your ship. WASD or Arrow keys move you around, aim and shoot with the mouse, P to pause.
Some of the options work ( Stats for example, although there are some unfinished ones in there, and a lot more to go in, along with a lot more medals ), but most don't.

It's mainly a case of looking around and watching the particles right now, but they are quite pretty so far.

As I do more work on it I'll flesh the posts out about the tech. side of it as I've gone to quite a bit of effort to get this bad boy running as fast as possible ( Which is sheer bliss. In real life you never have the time to even write the word optimise never mind doing it ) and hopefully development will go onlong in fits and starts like it has since the project started 'til one day it can go free into the world able to stand on it's own two feet.

Enjoy.

Squize.

Friday, August 01, 2008 8:19:41 PM (W. Europe Daylight Time, UTC+02:00)  #    Disclaimer  |  Comments [8]  |  Trackback
 Thursday, July 31, 2008
Great day, Geometry Wars2 is out today ( And I've nearly nailed the collision routines in the arkanoid "style" game I'm doing at g5games, but I digress ). Regular readers will know I've been working on Orbs forever now, which is inspired by the GWars look and feel, so I've been keen to check the sequel out ( For the whole week or so since I heard it was coming )

800 points later, and wow. It's sex.

When you shoot a baddie, it drops a geom ( Correct me in the comments if I've given that the wrong name ). When you get close to them, they get sucked towards your ship.

Hmmm, just like the credits I coded the other day in Orbs.

Also there are new things, called "gates" ( Corrections always welcome :) ), where you can shoot them and your bullets rebound to kill baddies. It even keeps track of how many rebound kills you've got.

Hmmm, just like when you shoot the orb and it rebounds and kills a baddie.

Arse. For fear of Orbs coming out and everyone just pointing the finger of copy catness, it's forced my hand ( Yeah the title makes sense now, these posts aren't just thrown together you know ) to release a demo sooner than I'd rather.
Hopefully by Saturday we can have some particle porn up here. I'm just thankful that Bizarre haven't got Pong in the pause mode.

Squize.

Wednesday, July 30, 2008 10:21:16 PM (W. Europe Daylight Time, UTC+02:00)  #    Disclaimer  |  Comments [2]  |  Trackback
 Tuesday, July 29, 2008
Here's a funny thing.

Law of the West Pinball was posted to newgrounds. All good so far. Got a score of around 3.15, nothing great. Some helpful feedback, some pointless ( Well, one pointless ).

Being kind of anal I check back on it now and again, and this is the weird thing, it's score is going down every day. Every day, someone is voting it down.

Now it was never really on the radar, I've never linked to the NG page anywhere ( I don't really like to, it feels very "Here's my game. Oh look, you can vote for it, I never noticed that before. Well, whilst you're there, give it a 5. Please. I'm needy." ) so it seems really odd that either one person is going there everyday fuelled with petty hate and knocking it down slowly but surely until it goes the way of Chimbo and gets blammed or someone new is stumbling across it every day, and hating it that much that they're voting it down.

I'm not sure which is worse actually.

I just thought I'd mention it, as it's bugging me slightly, and what other reason is there to have a blog than to be self indulgent and post about petty things ( Tomorrow, "Why do people wear shades on the underground ?" ).

Squize.

Tuesday, July 29, 2008 9:51:00 PM (W. Europe Daylight Time, UTC+02:00)  #    Disclaimer  |  Comments [3]  |  Trackback