Friday, November 28, 2008
Irony irony irony, you don't have to be so heavy handed. Subtle irony is better. It's funnier. Hell it's the English way.

Big nasty smiling in your face as it twists the knife in your stomach irony isn't good. Unless it happens to someone really bad who deserves it, but then you're treading on Karmas toes a little.

Two days after writing the post "Xbox, we love you", just after the 3 year extended warranty has expired, just as I'm building up to some quality down time with a clutch of new games for my baby, just as the NXE has come out, we've had a death in the family.

deathInTheFamily.jpg
"Jede dritte stirbt den Hitzetod"

My beautiful, fault free lump of gaming heaven has passed away. Bastard.

For those of you who don't know, that's known as the "Red Ring of Death". It's the Xbox's way of saying "You're going to need to buy a replacement for me, that's money you could do without spending just before Christmas isn't it. That'll teach you to finally do a blog post about me. Irony, that's what that is."

If this has taught me one thing, it's to never write a blog about how great my prostrate is feeling or that I'm glad I've never caught my testicles on razor wire.

Squize.
Friday, November 28, 2008 9:40:14 PM (W. Europe Standard Time, UTC+01:00)  #    Disclaimer  |  Comments [13]  |  Trackback
 Wednesday, November 26, 2008
I know there wasn't a lot of love for the Mii360's when it was announced, if you own a 360 by default you're a hard core gamer. Leave the avatars to Nintendo.

But... they're kinda more-ish. Here's what Olli and I look like when made of polygons.

avatar-body_nGFX.pngavatar-body.png

Obviously Olli isn't a child who's only been fed salt sandwiches for 6 months, nor am I a giant whose only eaten cake for 6 months ( I didn't realise the difference in size until 2 seconds ago when I uploaded them both. It looks like I could, and possibly will, eat Olli ).

Because we like looking at strangers who we don't really care about, here's how to link to your avatar,

http://avatar.xboxlive.com/avatar/YourGamerTag/avatar-body.png

So feel free to post a link in the comments, just so we can be surprised at whose's actually bald, or wears a dress, or is nothing like how we pictured them.
Or even better, if you've made your avatar look like some one famous, and not just the usual staples ( Mr. T, that's the avatar equivalent of going to a fancy dress party as the fucking Blues Brothers ) but the likes of Jesus, Charlie Mansion, the midget from Fantasy Island, John Wayne Gacy in his clown outfit. The more twisted the better actually.

Also if you just want the smaller gamer pic version, link to

http://avatar.xboxlive.com/avatar/YourGamerTag/avatarpic-l.png

Although that only works if you've taken / saved a snap shot of your new avatar as your gamer pic ( It won't link to the pre-NXE gamer pics ).

( Here's me again, trying to get my gamer pic to look like the last person in the world you'd ever want to be stuck in a lift with

avatarpic-l.png

Mental Mii ).

Squize.
Wednesday, November 26, 2008 11:09:00 AM (W. Europe Standard Time, UTC+01:00)  #    Disclaimer  |  Comments [3]  |  Trackback
 Tuesday, November 25, 2008
So I'm a little behind the times with this post, but to be fair I've had other things on.

Adobe have released Alchemy, which is a c/c++ compiler that outputs to Flash byte-code. Sweet.

I guess most people reading this remember when news of F10 broke and there was a video clip of Flash playing a native version of Quake that blew everyone anyway ( Better font rendering in FP10 ? Who gives a shit, that's Quake dude! ). At the time there were very few details about it, and it seemed to just disappear from view.

Well it's back and has a new poster boy, Doom. Runs a little dog rough for me when there are a couple of baddies on screen but hell, it's Doom ( I think it's the sign of a platforms maturity when someone ports Doom to it ).

How does this all work then ? Basically it relies on LLVM ( Low Level Virtual Machine ). This takes your source code, or "Front-end", currently  c/c++ but there's support coming for other languages, and compiles it down to a very simple byte-code.
With the byte-code in place you can then add your own "Back-end" which converts that code to run on your cpu of choice. Basically it's converting a high/mid-level language to an ultra low-level language ( RISC like ) which is then easier to port.

Because Flash uses a virtual machine model a back-end has been written to support that, so it goes c++ > RISC code > AVM2 byte-code and we're left with either a swc to include or a standalone swf ( Not sure how much use that'll be in real life though ).

My first thoughts ( Even after seeing the Quake demo ) was that anything written using this is going to run like poo. I mean as3 isn't the fastest language in the world. But there's a couple of reasons why it works and works well.

Firstly the LLVM compiler is really good. It optimises the pants out of the code, which reduces some of the percieved overhead.

Next up, the system works by allocating a byte-array in memory which the alchemy code uses for pointers / stacks etc. as well as storing it's own byte-code in there. In FP10 additional byte-codes have been added to the avm2 to deal with byte-arrays much quicker ( Allowing this to work at a good speed ), the haXe guys have done some amazingly quick work to figure these out.

Finally 'cause the alchemy converted code ( Is there a proper name for that yet ? Something catchy and slightly rude sounding ? ACC will do for now ) runs in it's own little byte-array "enclosure" it can access memory ( ie a location in it's own enclosure ) and call functions really quickly ( It's like coding in assembler on the old 8-bit machines ).

You lose performance when your action-script has to call / recieve data from the ACC ( Known as "
Marshaling" ), but such is life. If you plan so you pass as much code as possible outside of the mainloop then hopefully it shouldn't be too harsh.

Byte-Arrays are F9/F10's bitmap methods in terms of a new feature offering a huge leap forward in how we work with Flash. They offer up so much scope for some really cool stuff, from mod-players to things like
Alchemy.

It's looking like it's possible to finally in-line byte-code thanks to the avm2 back-end for LLVM, which has a lot of possibilities for speed enhancements. Also take things like box2D, natively written in c++ ( That is currently being converted, although there have been some teething problems ), or a* pathfinders taking advantage of the much quicker memory access, or engines like Coco3D which could be ported over and solve issues in existing 3D engines, or self-modifying code, or things I can't even hope to think of yet.

Squize.

Tuesday, November 25, 2008 7:02:04 PM (W. Europe Standard Time, UTC+01:00)  #    Disclaimer  |  Comments [0]  |  Trackback
 Monday, November 24, 2008
What a great title. It sounds nice and gamey. Like a sweet bullet time effect, or maybe a real time rewind function. Picture that, being able to pause and then rewind the action in any game, just by dropping the cessation time distortion component into your game. Nice.

It's actually got nothing to do with gaming or Flash, it's yet another smoking reference. Promise it'll be the last mention of my own personal trial on here ( In 15 mins I'll have been a non-smoker for exactly 1 week, hence my final farewell to banging on about how hard it is etc. etc. ).

"A cigarette is the perfect type of a perfect pleasure.
It is exquisite, and it leaves one unsatisfied.
What more can one want ?
"
Oscar Wilde.
I've been doing a bit of reading about smoking and the effects it has on you, it does help when trying to stop, as it makes you realise it's not just a case of you being weak. It's a bit more than just caving in and eating that last bit of cake.
Ok we all know smokings bad. No one is so stupid as to think otherwise. Non-smokers just don't get how smokers can smoke, I mean it stinks, it's bad for you and it costs the earth. Smokers just hide behind a million different reasons just to keep smoking.
( Personally I used the combination of "I do actually enjoy it", "It helps me think" < Strong reason for me there, "I stopped before, and I remember how hard it was, and now I'm self employed I just don't have the time to effectively write off two weeks suffering withdrawal pangs". If you're a smoker I'm sure you can add your own to this list ).

So we all know all the bad things about smoking, the smell, the social costs ( It's no longer cool kids, try standing outside in the rain smoking, far from cool. Speaking of which, I'm sure I can't be the only smoker ever to stand in the rain, thinking "What the fuck am I doing this for ? I'm not even enjoying it that much anymore" only to do it again the next day. Same as going to a shop at 3am to buy some smokes 'cause there's nothing worse than waking up without a cigarette is there. ).

But here's something I only found out over the past couple of days. I was kinda aware of it, but never really knew the details. It's something that's never really thrown up as a reason to not smoke in the first place, I assume that cancer and heart disease are treated as good ( Bad ? ) enough reasons, in addition to the usual staples ( Smell, cost, ages your skin etc. etc. ).
To me it's caused more of a knee jerk than either of the big boy reasons not to smoke.

( Again, there's this pre-conception that smokers are dumb 'cause smoking greatly increases your chance of getting a million different cancers, with lung cancer being the big one, the mother of cancers. God's way of really smiting the smoker. You want to smoke ? Here's a cancer just for you. That'll fucking teach you.
As a smoker you know that, but it's an addiction non-smokers, so you can twist anything to suit your argument [ To keep smoking ].
Here's some stock replies, that I'm sure I've used before "I could get run over by a bus tomorrow", "You only live once, life's too short to worry about things like that. Anyway they say you can get cancer from <insert whatever has just been in the news recently that can give you cancer> so what can you believe anymore?" or the classic "I know it's bad for me, I'll stop smoking as soon as I notice my health getting worse, so I'll be fine".
I'm sure my Dad used that last one, he also used the other classic "Uncle Tom smoked 80 a day from the age of 14 and died in his 80s and was fit and healthy right to the end". Every smoker has that uncle Tom. My Dad died of lung cancer when I was 20, so 16 years ago. I started smoking when I was 17, and by the time Dad was dying infront of us I was quite happily smoking 20 a day. At his funeral ( Which btw was the first one I'd ever been too. Not the best way to lose your burial virginity ) I was desperate for a smoke, and when I got the chance, I did.
Here's a good definition of an addiction, "The uncontrollable, compulsive drug craving, seeking, and use, even in the face of negative health and social consequences." [source]. That's what smoking is, that's what makes you want to smoke at your Dad's funeral. It really is more than just not being able to turn down that last bit of cake ).

Nicotine is a poison, we all know that. It's the tobacco plants natural protection from insects. Drop for drop it's 3 times more deadly than arsenic. I guess there aren't too many insects eating tobacco leaves. It's also a member of the same family as cocaine, morphine, quinine and strychnine. Nice family.
But here's the detail that I only discovered the other day, the "If only I'd known that before I started smoking" bit of info ( That really wouldn't have made much difference in all honesty, but more than the big guns of reasons not to smoke ).

Eight seconds after your first ever drag your brain releases a ton of dopamine ( You can read the very dry definition here, or if you want to skip that, it increases heart rate and blood pressure. Basically it's an instant rush. It's also connected with your bodies reward system, which is handy in terms of forming an addiction ).
K, you've taken your first ever smoke. Nasty as hell. You're going to have to work quite hard to get addicted to this, but don't worry, smoking messes up your sense of smell and taste, so in effect it masks the fact that it tastes like what it is, poison. Also you know that stat about cigarette smoke containing 4000+ chemicals, included in those are things like Cocoa and Corn Syrup, added to make it smell less like death, and more like a white stick of nice.

Your brain knows poison when it gets a lung full of it. In return it reduces the number of [ Acetylcholine ] receptors available to receive nicotine to try and protect itself. It also reduces the number of transporters capable of moving the nicotine around in your brain, and as a final wave of protection, in other areas not affected by that first ever rush of nicotine it creates millions of extra receptors, so if you do have any more nicotine intake it's spread out more.
That's why you'll never ever get the same hit from a smoke as you did on that first ever time, every cig since that very first draw has been an attempt to re-create that first buzz. Your brain has re-wired itself to protect itself from having too much posion concentrated in one spot.

That's the thing that's freaked me out. That the crap I breathed in is dangerous enough that my brain is physically different, that it adapted itself straight away to avoid the harmful effects of nicotine ( The same thing happens with other drugs, it's the bodies way of coping with having something in it that really shouldn't be there ).

And connected to your brain being different to cope with nicotine ? Cessation Time Distortion.
In that first 72 hours when you stop smoking you have some nicotine left in your system ( It has a half life of 2 hours that's why when you're a smoker going over a couple of hours without smoking is hard as hell, for me it was an hour before I'd start getting really needy for one ), but it's not enough and that's why your brain throws a hissy fit.
This includes mood swings, lack of concentration ( It's exactly a week today that I stopped, and it's only just starting to sort itself out, although this post has taken ages to write ) and all the other things that make you a pain in the arse when you stop. At it's most simple level, you have a panic attack due to not being able to get what you crave, mixed in with your body regaining control of it's fight or flight mechanism, which has been run by nicotine since you started smoking ( Hence the attacks of instant pure rage for no real reason. Your body isn't used to handling anger itself properly any more, it's like when people have their sight restored after years of being blind, it's just over whelming and your brain doesn't really know how to cope ).

After those first 72 hours your brain kinda gets it, and starts resetting the changes it had put in place. Basically you're learning how to be the real you again, as opposed to the smoking-in-the-rain-even-though-you-don't-enjoy-it you. This isn't too smooth either, but should only take a couple of weeks.
Part of this re-wiring process is this really weird side effect, time distortion. Your whole concept of time is screwed. As a rule we all have pretty good internal clocks ( We've all had that "Got to get up in the morning it's really important" and then woken up a couple of minutes before the alarm was due to go off ) but during this process of re-wiring it's a million miles out.

At first that's a nasty thing. You know how when you're waiting at the doctors or the dentist time just drags. It's 'cause you're a bit bored, perhaps a bit worried about what's coming up, and it just seems to go in slowmo.
When you stop smoking, the whole day is like that. It's like the week before Christmas when you're a kid, it just goes on and on forever. Apparently actual physical nicotine cravings only last for 3 minutes at a time, but during the first couple of days you get hit by a lot of these cravings, and mixed in with this newly found no concept of time at all, they really really don't feel like 3 minutes.

Now I'm at the worst is behind me stage, this whole time distortion is nearly as cool as a component you could just drop into your Flash game to control time. I'm getting more done because I have more time on my hands. Not just 'cause I'm not having to shoot outside every 45mins / hour for a smoke, but because my brain really doesn't have a clue how long things take.
Which is such a result, as I have a deadline this Friday, and I've done relatively little the past week because I've had no concentration at all. I'm hoping I'm going to stay ever so slightly mental long enough to get the new game done.

And on that note, we're back onto games and leaving smoking behind. Normal service should resume tomorrow, thanks for indulging me.

Squize.

Monday, November 24, 2008 11:22:27 AM (W. Europe Standard Time, UTC+01:00)  #    Disclaimer  |  Comments [4]  |  Trackback
 Wednesday, November 19, 2008
I have an inherent dislike of self indulgent blog posts, the whole "I'm not feeling well today" thing.

I've found twitter takes this part of a blogging to it's natural extreme. "I've just been out to buy some tea bags" kind of pointless, mindless, please have an interest in me and my life crap.

Well check my hypocrisy out, here's what my twitter post would be today:

"Gave up smoking Monday. Hate everything right now. Haven't got a civil tongue in my head, so not posting until I'm less of a cock".

Sorry to everyone who I owe emails to, but I really can't write more than 4 words without them turning into some sort of nasty rant for no real reason so it's best I go to ground until I stop wanting to burn down the whole world.
Normal service will resume as soon as my brain fully understands that I don't want to smoke any more and so stops thinking about it every waking second.

Squize.

Wednesday, November 19, 2008 11:33:25 AM (W. Europe Standard Time, UTC+01:00)  #    Disclaimer  |  Comments [2]  |  Trackback
 Sunday, November 16, 2008
Gears of War2, the most stunning game I've ever seen, and despite some of the on-rails sections being a bit tricky to the point of swearing at the TV, it's a fantastic game.

One of the new features in it is your "War Journal", where your progress is kept.

gearsJournal.jpg

Which is a really sweet feature. Although it reminds me ever so slightly of...

disJournal.jpg

Nice to know that my thoughts aren't a million miles away from Epic's at times ( I didn't come up with the idea of the journal in Death in Sakkara, but I'm pretty sure that having extra hidden collectables was down to me. That was obviously before I started the 3 month crunch to actually code the game ).

Squize.
Sunday, November 16, 2008 6:52:32 PM (W. Europe Standard Time, UTC+01:00)  #    Disclaimer  |  Comments [0]  |  Trackback
 Saturday, November 15, 2008
The indie Flash game community seems to love stats. I guess it's 'cause it's always nice to see someone whose written something good getting the recognition ( Even if it is more in terms of traffic than cash ), and because it's slightly inspirational, that everyone is just one good game away from achieving the same results.

When our game Chimbo got blammed on newgrounds it really shook me quite hard. It's the first time that I've really had a project fail on me ( I've had games I've not been able to sell before, but never something out there which has performed badly on a critical level ).
We thought that was it for the game. We were under no illusions of what the game was, a reskin of an even older game. It's far from great, but both Olli and I chatted about it before hand ( Like we always do ) and considered it good enough to go out under the gyw banner. It's an average game that looks pretty with varying degrees of presentation.
That was it then, a footnote in our history.

And then the traffic started to creep up. It got on some front pages of high traffic sites, only for a day or two ( Such is the turnaround on such sites ) and got spread around a little.

chimboStats.png

At present Chimbo is hosted on 392 sites, and in the 281 days it's been hosted on gamejacket it's served up 1,248,011 impressions. Not a hit by any stretch of the imagination, but average traffic for an average game which started it's life quite badly ( And apparently in gamejacket's all time top 20 hits, although I think that's more through default 'cause it's been there pretty much since the beginining ).
Today it's had 4359 impressions, which is a nice trickle of people ( Hopefully ) having some fun with it. It's proved to be a slow burner ( Hopefully pinball will be the same, as that's done relatively poorly ).

So is there anything you can take away from this ? I mean it's all well and good seeing a nice graph and knowing one of our games hasn't done too badly, but it doesn't help you much.
Hopefully it shows that sites with a typical teenage boy market ( Ninja zombie pirate shoot'em up anyone ?) aren't the be all and end all. There are a lot of sites which are targetted at young girls too which have insane amounts of traffic. Chimbo had 50k+ hits in one day purely by being front paged on a girl site ( That sounds terrible, "A site aimed specifically at girls" is what I should have said ). If you got that sort of traffic on ng or Kong in one day you'd be pretty pleased.

To show this isn't a one off, the game I did for gimme5, Loved Up, died on it's arse on all the "usual" sites, then went on to be g5's top referring game for months.

Is there a large mostly untapped audience for "games for girls" ? Hell yes. I spoke to Barry at gamejacket just the other day and he told me that they're now generating two lists [ Of portals ], the usual one and one for the female audience.
You may think it's selling your soul to do a game targetted specifically at girls. You want to do Metal Slug X, not Me and My Pony, but a game which appeals to a young female audience doesn't have to be overly twee or technically "cheap". Just see it as another genre which should be on your list of ones to try, same as doing a puzzle game or a mode7 racer etc.

Anyway to wrap up this posts about stats, here's a great couple of links where you get to see dirty hard amounts of cash, compiled by Drastika ( Cheers Paul, saved me hunting these down ).

Elite games' earnings ( For Oct )

Emanuele Feronato's one year money making experiment results

Squize.

Saturday, November 15, 2008 6:12:15 PM (W. Europe Standard Time, UTC+01:00)  #    Disclaimer  |  Comments [7]  |  Trackback
 Monday, November 10, 2008
I've posted here before on our google indexing. Also the blog software records what search terms drive people here, the most popular being "as3 frame counter" and "as3 flex preloader". We get a lot of disappointed Cure fans with "I don't care if Mondays blue" as well as some other really obscure searches landing here ( "Boylinks" comes up a lot, don't ask ).

Checking the logs Friday I came across this gem from google.com.au,

"WHY THE FUCK WON'T STUPID FUCKING as3 LET ME FUCKING CREATE AN EVENTLISTENER"

( We've got the number one rank for that phrase, I really don't know why, we can't be the only people using the word "fuck" and "as3" in the same posts surely ).

Anyway to be so pissed off at coding to swear at google is something we totally sympathise with ( As well as admire in a slightly mental way ), and whoever you were, you're a kindred spirit mate.

[Update: I've also noticed other people are entering the phrase into google, is that just to see if we're ranked number one for it ? I think we own it now :)
Also today, "wee sex" gets us a front page hit. I think I may need to calm down the bad language and obscure sex terms on here, as we're going to be getting hits for the most obscure stupid things. golden showers ].

Squize.

Monday, November 10, 2008 7:13:12 PM (W. Europe Standard Time, UTC+01:00)  #    Disclaimer  |  Comments [0]  |  Trackback
 Friday, November 07, 2008
A really nice abstract demo, called Sugar Cubes, which feels like it uses a lot of Box2D.

sugarcube_grab.png

Visually it reminds me of Thrust, due to the simple colours and heavy scanlines, and it's got an abstract soundtrack which fits perfectly.

Yet more great work by Yoshio Ishii / Nekogames, just making something visually arresting out of very simple movement and images.

Squize.
Friday, November 07, 2008 3:18:31 PM (W. Europe Standard Time, UTC+01:00)  #    Disclaimer  |  Comments [0]  |  Trackback
 Thursday, November 06, 2008
Quite a descriptive title for this post for a change.
651_jellyVectors.jpg

In this section of 651 we're running two effects, a bog standard RGB plasma effect and then a "Jelly vector" effect.

To create a plasma you're going to have to suck up to Math.sin, he's your daddy for this.

Firstly we pre-calc a colour table, eg.

        public function ColourTable(){
            colourTable=new Array();
            var cnt:Number=-1;
            var col:Number;
            var r:int;
            var g:int;
            var b:int;
            var offset:Number=3.1415;

//To avoid /4 for each pixel every frame, we just make the colour table 4 times as big
            while(++cnt!=256*4){
                r = 128 + 128 * Math.sin(offset * cnt / 32);
                g = 128 + 128 * Math.sin(offset * cnt / 64);
                b = 128 + 128 * Math.sin(offset * cnt / 128);
                col=(r << 16)+(g << 8)+b;
                colourTable.push(col);
                colourTable.push(col);
                colourTable.push(col);
                colourTable.push(col);
            }
        }

Here we're just creating what is in effect a gradient, so we have an array which smoothly goes from one colour to the last one. When it comes to the look-up when we're plotting we'd need to divide the value by 4, so to avoid this we make the colour table 4 times larger than is really needed ( Often it's a balance between memory usage vs speed. An easy way to think of it is with loops. If your game didn't have any loops and you just copy / pasted the same thing over and over it would run quicker, but take a lot more memory, and be pretty insane ).

Right the colour table is done, next up we create instances of our Pixel class,

            activePixelsStorage=new Array();
            var pixelObj:Pixels;
            var j:int=-1;
            var k:int;
            while(++j!=120){
                k=-1;
                while(++k!=120){
                    pixelObj=new Pixels(new Point(j,k),colourTable);
                    activePixelsStorage.push(pixelObj);
                }
            }    

It's just like doing a tile based engine, each instance of our Pixel class is passed an x/y position so our plasma is 120 pixels wide by 120 high. That's pretty tiny so we double the scale of the sprite in which we're plotting and add a blur filter just to smooth it out. It's a lot less expensive than plotting a 240x240 plasma.

On to the actual Pixel class:

    public class Pixels{
//---------------------------------------------------------------------------------------
// Properties
//---------------------------------------------------------------------------------------
        private var xPos:int;
        private var yPos:int;

        private var cX:Number;
        private var cY:Number;
        
        private var jointDist:Number;
        
        private var offset:int;

        private var cT:Array;
        
//---------------------------------------------------------------------------------------
//Constructor
//---------------------------------------------------------------------------------------
        public function Pixels(pos:Point,colourTableArg:Array):void{
            cX=xPos=pos.x;
            cY=yPos=pos.y;
            var xDist:int=120-cX;            //Distance from the bottom
            var yDist:int=120-cY;

            cT=colourTableArg;
            
            var distance:Number=Math.round((Math.sqrt((xDist*xDist)+(yDist*yDist))/2));
            var distX:Number=256 * Math.sin(distance/8);
            var distY:Number=256 * Math.cos(distance/8);

            jointDist=distX+distY;
       }
        
//---------------------------------------------------------------------------------------
//Public
//---------------------------------------------------------------------------------------
        public function toString():String {
            return "Pixels";
        }        

//---------------------------------------------------------------------------------------
        public function pixelmainloop(x:Number,y:Number,plotbm:BitmapData):void{
            offset = (Math.cos((xPos+x)*0.0525) + Math.sin((yPos+y)*0.0255))*256 + jointDist;

            if(offset<0){
                offset=(offset ^ -1) + 1;
            }
            
            plotbm.setPixel(xPos,yPos,cT[offset]);
        }
    }

I'm not going to go into too much detail with this, as it'll take ages to be honest. The most interesting part is the pixelmainloop, where we pass in the x/y ( As well as the bitmapData we're plotting too, more on that soon ), and from those coords we create an offset into the colour table. To create the smooth curves that makes a plasma look so sexy we use some lovely sin and cos ( That's the bit I'm skipping explaining in any real detail. It takes quite a bit of tweaking to get something looking how you like and different values really give different results, for example:

            offset = (Math.cos((xPos+x)*0.0525) + Math.sin((yPos+y)*0.0255))*64 + jointDist;
            offset=offset>>3;

That's what's used in the credits plasma / kaleidoscope effect, which uses exactly the same colour table values but looks totally different ).

All that's left for the plasma part is the mainloop that we run on the enterFrame.

            sinOffset++;
            var radian:Number = sinOffset/60;
            paletteShiftX = 128-Math.sin(radian)*255;
            paletteShiftY = 128-Math.cos(radian)*255;

            plotbm.lock();

            var pixelObj:Pixels;
            for each(pixelObj in activePixelsStorage){
                pixelObj.pixelmainloop(paletteShiftX,paletteShiftY,plotbm);
            }

            plotbm.unlock();

            if(plotbm==bm1){
                plotbm=bm2;
            } else {
                plotbm=bm1;
            }

            bmData1.bitmapData=plotbm;

Nothing too tricky here. We just increase the position ( Offset ) into the colour table every frame, and then use for...each ( Much quicker ) to loop through all our Pixel instances calling the pixelmainloop and passing the args.
The part that may be of interest is the plotbm var. To increase speed slightly we double buffer the plasma bitmap, so when one bitmapData is being displayed we're plotting to the other one which is no longer being shown.
To try and explain that a little better, we have two bitmapData objects, bm1 and bm2. bmData1 is our bitmap ( I find the difference between the two confusing as hell in as3. It makes total sense, it just doesn't seem to stay in my brain very well ) which is attached to the our holder sprite for the plasma ( The one we doubled in size and added a blur to as mentioned earlier ).
So lets say we have something like this:
holderSprite.bmData1.bm1;
And that's what you see on screen. If you can see bm1 that means we're plotting to bm2, and visa versa.

This is why we pass the currently hidden bitmapData to each instance of the Pixel class every frame rather than just passing one value in during it's construction.

That's plasmas for you. I've only really given the core concept as hopefully a spring board for your own experiments.

The Jelly cube is going to be much more straight forward, because someone else wrote the clever bit. After x amount of time we run a really quick white up over the whole stage, and that's where we remove the plasma all together and replace it with a papervision cube.

Ultra simple, we just rotate him and scale him. The twister code came from the excellent zupko who kindly open sourced it. Now we've got a twisty cube, what about the texture ?

This is another big fat cheat. At best you can get a plasma running the size we have at around 40fps, so there's no way we could do it realtime and run the cube. One idea I had early on was to use draw() on every frame of the plasma and store those away, then update the texture every frame on the cube using those stored away bitmaps.
I didn't go this route as I was concerned about the amount of memory it would use and I was concerned that using draw() may have had a negative performance hit when actually running the plasma ( I'm possibly paranoid about that and it would more than likely be fine, but it felt like quite a bit of data to be copying every frame when you want everything running as quickly as possible ).

The solution ? flv baby. Unless it's youTube the flv format seems to be badly over looked when it can be used for all types of tricks ( I did quite a bit of video work in games at preloaded long before flv came out so I've learnt what the advantages of using video are early on ).
I just ran the plasma for a little while grabbing the frames, cropped them up, created a copy running backwards and then joined the two together, so runs as A > B > A.
All that was left then was to created a flv texture for each side of the cube, and papervision along with Flash did everything for me.

The only thing left to cover off is the black outline on the cube. Again ultra simple, it's just a glow filter. Set it to black, turn up the strength, turn down the blurring and you've got a sexy outline.

Phew. I think this is going to be last in-depth-ish tut on the 651 effects. Not only does it takes ages, but I think the rest of the effects not touched on so far can be summarised in one post.

Squize.


Thursday, November 06, 2008 5:24:29 PM (W. Europe Standard Time, UTC+01:00)  #    Disclaimer  |  Comments [0]  |  Trackback
 Wednesday, November 05, 2008
And that's as political as we're ever going to get here.

Squize.

Wednesday, November 05, 2008 4:09:03 AM (W. Europe Standard Time, UTC+01:00)  #    Disclaimer  |  Comments [3]  |  Trackback
 Tuesday, November 04, 2008
So what's wrong with this code:

if (this._iDrawLayer & ChipsGame.VIEW_LAYER_A == ChipsGame.VIEW_LAYER_A) {
// draw contents of layer A ...
}

nothing, really. Nonetheless it's not working in CS3 (yet again, prove me wrong).

Basically it's just the unoptimized check if a certain bit is set or not. Let's do some traces:

trace ("with ():", ((this._iDrawLayer & ChipsGame.VIEW_LAYER_A) == ChipsGame.VIEW_LAYER_A))
trace ("without ():", (this._iDrawLayer & ChipsGame.VIEW_LAYER_A == ChipsGame.VIEW_LAYER_A))
trace ("values :", this._iDrawLayer & ChipsGame.VIEW_LAYER_A , ChipsGame.VIEW_LAYER_A)

The result is this:

with (): true
without (): 1
values: 1 1

Interesting, isn't it?
It seems like the compiler chains the & and the == for some reason that escapes me...

So if you get something undesiered with bitwise operators ... use ( and ) around it.

nGFX

Tuesday, November 04, 2008 3:33:54 PM (W. Europe Standard Time, UTC+01:00)  #    Disclaimer  |  Comments [3]  |  Trackback