Friday, March 28, 2008

Flex Games programming

I have some experience in flex programming, but only in application development. i love the gui part of flex framework, it is much better than java in my opinion.

This time i try to use flex for game programming, not flash codes compile with flex compiler, but really use flex framework to do game.

The very first problem i encounter was there is no example could be found on net! i wonder why, but nevertheless i still found one close enough example from Rico on Flex, it uses AS3 but purely flash api to create a tetris game. as part of learning i decided to redo this tetris game with flex, that is using concept such as canvas, panel, flexSprite, flexShape and mxml!

Although i just started, i already found 2 useful experience:
1) To create double array, do this will create error
_allBricks[m].push(new Array(MASKS[m].length));
should do this instead
_allBricks[m] = new Array(MASKS[m].length);

2) flexShape don't have to added to flexSprite as child, you can add it directly to canvas. to do that:
var _nextBrickDisplay:Shape = new Shape;
var previewUI:UIComponent = new UIComponent;
previewUI.addChild(_nextBrickDisplay);
this.addChild(previewUI);

Monday, March 17, 2008

java gotcha

while working on jdbc, i wanted to filter out invalid character in sql statement such as "'" the single quote. the way i first did is

newSql = orgSql.replaceAll("'", "\'");

it works? doh no! after a little bit searching i found the solution here Avoid the dreaded replaceAll method, the correct way to do it should be

newSql = orgSql.replaceAll("'", \\\\\');

5 slashes, yes, because this statement goin to compile 2 times before it being execute, so java will eat 2 them, regex will eat another 2. the remaining will be "\'". elegant right?

talking about jdbc, in previous java game server, i was using hibernate for the job, but it give me very big headache, the lazyness feature don't work on me at all, give me bunch of exception, at the end i have to manually store the data in heap. after that i seared i'll use jdbc instead.

Thursday, March 13, 2008

Tortured by an Ogre (3D)

This was 4.16am, and iwas still in front of my pc, and all this stay up late is because of my itching hand went to update my ogre3d to latest version, directly from official cvs. the latest ogre3d make 2 of my projects couldn't compile and/or crashed at runtime. and my ego make the things worse, i decided to tamed the new monster instead of going back to the old one. so here i'm, coding at 5am in the moring.

this is not good, today's news said main sleep less then 5 hours can cause overweight problems. i must take note all the problems that i encounter today so that i won't repeat them again

1) my ogre3d framework suddenly complain material for AmbientOneTexture couldn't be found, this is a easy one, just need to add Examples.material to media folder that all, but the reason why new version need these file still unkown

2) my 9th life copy couldn't compiled. this was due to Ogre3d 1.4.7 removed Entity::setNormaliseNormals and Renderable::getWorldOrientation and Renderable::getWorldPosition. they took me awhile to discover setNormaliseNormals and getWorldXXXX are no longer required, can remove them entirely without searching for new subtitute. getWorldOrientation and getWorldPosition for other class (SceneBode) can use _getDerivedPosition instead

3) after my 9th life compiling, it crashed at runtime, at reported all particle file not found! wth? and this b*tch, wasted my 4 hours go and debog the new ogre3d line by line, started from initialiseAllResourceGroups() to OgreParticleSystemManager::parseScript(), after 4 hours then i relised new ogre3d used new script compiler, which compined *.os, *.material, *particle... to one, and this caused serious problem to me. and the solution is simply add OGRE_NONCLIENT_BUILD;FREEIMAGE_LIB;OGRE_USE_NEW_COMPILERS=0 to preprocessor! good lesson, never used cutting edge IT product, never!

my eye was a little bit not cooroperate. i actually there was still one problem bugging me, that was from my the other project. the smartfoxserver don't me to upload file to my server, i still searching for solution for it, sigh... good night

Tuesday, March 11, 2008

A journey begun! is it?

Not too long ago i had watched a japanese movie called Kikujiro, it is about a journey between a gangster (yakuza) and innocent kid. the journey was set out to find the kid's mother, who left the kid at his very young age. as the movie progressed, i discovered that, the journey is actually a journey of life for both of them, a journey that change both of thier life forever.

Not too long ago i 'd resigned from my ex-employer, and thinking of setting up my own software business. i guess more or less i have debarked my own journey of life, and i hoped it will be as fruitful as the one in Kikujiro.

Currently i have a few project at hand, first one is about 3d online dancing game and the second one is web application using flex and smartfoxserver. they are both very new to me, i'll jot down my discovery on this small space of mine :)