Tuesday, December 22, 2009

i did miss my milestone actually

Now i fully understood why my producer want to play with milestone, always buffer for 1 week. because programmer's milestone != actual milestone :(

my facebook game is only in playable state today, 3 days from the day i expected :(
the thing that i have missed
1) flash security problem, when loading crossdomain resourses. solution is easy just need to add Security.loadPolicyFile("http://profile.ak.fbcdn.net/crossdomain.xml");
2) flash window is always on top, it covered facebook UI. solution is easy too. set swfobject's params wmode: "opaque" or "transparent". i chosen opaque because transparent has performance hit
3) bug in my php code, map is always save in new entry. solution is
a) don't use UPDATEto check for existence of a user because it might return 0 when the update data is same as the existing data. use SELECT instead
b) mysqli doesn't has $mysqli->rows ionly $mysqli->affected_rows different from mysql api
4) not fully understood but it is something todo with IE cache swf in memory, therefore in IE, papervision is only on first time. to trick IE to reload it everytime i have to add a random number behind my swf file. e.g. play.swf?RANDOM. this not a best solution but it works for now

Sunday, December 20, 2009

Milestone 1 hit!!!

finally a barebone tower defense game has form. i have implemented
1) gui + 3d graphics
2) map editing
3) tower defense basic gameplay, (path finding and auto targeting)
4) inventory
5) quest
6) economics
7) facebook and innernet networking
8) art asset production

all major components are in place, all the remaining are fine tuning and enhancement. after 5 months of intensive development (july 2009 to dec 2009) i finally did it :D

Friday, December 18, 2009

screw the thin client and anything look like pc but no self hosted development tools

recently they were many thin clients software and hardware surfacing, using web as front end and cloud computing as back end, and they thought this is all pc users wanted. always online, data and application are fetch from cloud computing. this is not going to help computing industry overall, the moment we accept this system, there is no freedom anymore, anything going to be subscription model. the only thing that i proud of about computing is everyone has equal power, so long you have a simple hardware you are ready to write your own program. i see this is the fundamental concept of freedom in computing, removing that will make us as slave of the mighty evil empire, and see we are heading to that direction. stop it now, before this industry heading toward telecommunication direction, which is suck.

Saturday, November 21, 2009

facebook + actionscript + php

it was harder than i believe. it was because of poor doc (or i'm impatient?). most of them recommended simple but unsafe way to do it or given the code but didn't explain the what facebook application setting are required. for example to use is only applicable if you used fbml in your settings, if you use iframe, swfobject is the way to go. there is a nice website explain it pretty well http://www.insideria.com/2009/04/overview-of-embedding-swfs-int.html. thanks mirza

Wednesday, November 11, 2009

single player mode is finally done!

Although it doesn't has all the feature i planned for it, but it playable now :) congrats the next sprint will server connect and facebook connection. stay tune

Monday, November 2, 2009

Blender frame animation guide

Today i redo my md2 animation by using blender again. although the last attempt was 1+month ago, i have totally forgotten how to do it! it took me something to regain my memory. to prevent the history happen again, i write down the step by step guide here

1) create key frame or shape key. first 'tab' into edit mode, create a new shape key (named it properly) move the vertex, then 'tab' again to exit edit mode.
2) is good idea to save basic mode (or unanimated mode)
3) after all the key frame are saved, display IPO screen. change IPO screen to shape mode.
4) move the current frame indicator (the green line) to the keyframe location
5) move the shape keys to the intensity u want

this will do for the animation portion. exporting it to md2 is easy but remember, default papervision md2 fps is 6fps. so it good idea to make keyframe multiple of 6. and also in the md2 frame configuration, state the number of frame of each animation not the end frame number.

Sunday, November 1, 2009

Flash 9 optimization revelation + project progress

read some flash optimization tips, and revealed that flash is different from c++, i'd been wrong so far by using c++ rules to optimise my actionscript code

1) unsigned int is always slower than signed int
2) number is faster than int in multiplication and division operations (!!!!!)
3) function call is expensive in actionscript
4) for(;;) is much slower than for each but .foreach is much slower than both of them
5) closure is very damn slow in actionscript, should never use it
6) uses of static const is more costly (unless it is current in current module)


my project is good, i have multiple wisps display on screen and tower removal is working :)

Sunday, October 25, 2009

tower, light, orbs, portal, wisps and camera!!!

finally all things were hacked together, hopefully next week will have something interesting to play with :)

Tuesday, October 20, 2009

prerouting

prerouting is a cool command to make your internal server access externally

Wednesday, October 14, 2009

Production starto!!!

From July to now, technical preparations are finally done, full steam ahead to accomplish my simplest RTS game :D

Sunday, September 20, 2009

What is game?

What is game? this puzzle me a long time, I'd the feeling i'm not productive when i'm doing games, i feel like i my wasting my time and our customer time. i feel that to continue my path i must understand this definition game.

after some thinking i come out some rough idea
1) game is simplify version of real human or imaginary activities (and therefore, it doesn't inherit the similar risk as the real activities)
2) game is under a structure environment, goal, difficulties and user progress is well defined and measurable
3) game is a system that required human/s interaction to complete. the system has certain challenges to work toward a specified goal. because of it is challenging activities, user rewarding with sense of achievement when the goal is achievement.

and because of this definition, everything could be a game. and everything should be a game :) suddenly i feel like my job is meaningful.

Wednesday, September 16, 2009

Blender stop the nonsense

I can't remember the number of time i revisited blender3d, but i always left it with disappointment in the export and import department. i love the interface, the shortcut and the concept of it. but without a usable set of export and import scripts it is totally useless, this time round i tested md2 and collada format, md2 format always reported index key out of bound error and collada doesn't export my animation correctly, so what is the nonsense about the peach, orange, banana open source projects? when not spend the money on these fundamental problem? i'm sick of it, no wonder people still using max even it is expensive, slow and bloated. wake up blender

Sunday, September 6, 2009

break through!

my collaborative path finding algorithm is finally worked on my test program. the algorithm i used is making use of pre-calculated data and used flood fill method to 'bake' them on the scene. thanks for sean cooper giving me the hints. the basic of the algorithm is a follow

1) using A* pathfinding to find the shortest path
2) fill the path with number destination with zero and each point away from destination increment by 100.
2) draw lines on map based on the path, meaning for each path's point we draw a perpendicular line
3) fill the line with number, each point away from path point increment by 10
4) do a post filtering on the map, it is a basic blur filtering, summing 8 neighbor boxes and devide by 8, notes that only cell without any value from previous step need to gone through this.
5) calculate the 'direction of each cell, by comparing the weight of the neighbor cell, from small t big, neighbor with weight higher than 90 don;t put into dir list to prevent flow back problem

the execution:
1) spawn and creep on the staring point
2) during the game loop, read from cell's dir list, move to the first encountered empty neighbor in the dir list
3) remove the creep that have reached the end point

the result is pretty good, although still has speed factor to be taken care of, but i think i'll leave it first and start working on 2d animated trasparent sprite and 3d animated collada model first :)

Monday, August 24, 2009

rails' equivalent printf

debugging rails (or any server side scripting?) is pain in the ass. and for a while i thought printf style of debugging is impossible, until recently i realised this most primitive form of debugging is possible. here it is:

RAILS_DEFAULT_LOGGER.warn("########### printf close :p ")

Monday, August 17, 2009

svn commands

doing work on ubuntu server (no gui), that's mean svn without front end. here are the svn commands that save my day
* svn update -- get latest copy from svn
* svn propset svn:ignore filelist -- add file to ignore list
* svn commit -- commit new changes to svn
* svn add --force ./ -- recursively add new content
*svn revert filelist -- cancel added files

graphical unit test

Always thought that unit test is not suitable for graphical programming, because most of the unit test package only provide ascii text output but graphical programming can simply tell a module is right or wrong but text output only. therefore i been ignoring unit test most of the time.

recently i came accross a game engine called facepunch, by the famous gary mod auther. i downloaded the incomplete engine i try it myself and i discover a test program in the bin folder, guess what it does? it is a unit test tool, it tests most of the aspect of the engine, and it provide visual feedback to veryfy the result! from that moment i know i'm completely wrong all this time :(

and recently i been working on force fill algorithm to simplify swarm/group/collective path finding, after wasted 2 weeks on it, i decided to create a visual unit test tool from scratch. so this tool doesn't serve as a test platform, it will be my prototyping/play group for me :) in fact this is common in certain nature development such as web development, they call it build by spec.

Friday, July 31, 2009

Nightmarezzz!!

I had nightmare today, woke up at 3.30am because of it, i was a secondary student in the dream, but it wasn't take place at my secondary school, it was like the school i learn from tv program :). abd my dream girl was my school mate and she was sitting next to me! ok so far so good, the night started after i came back from washroom, then i realized the man i hate the most (my ex-colleague swen) and he took my seat and the worse part my dream girl was very nice to him, arrrrg, they were a couple in my dream, wtf.

I went to protest but swen is equally disgusting in dream, he used his "charm" to swap the seat, as usual i do as his say took his seat with a broken hearth (sad sad sad). i his place is a mess a lot of personal stuff on and in the desk. i threw the things on floor and the teacher came in and annouce there was a test, i didn't prepare for it!!! wtfomgbbq??? and i woke up.

I was thinking the moral behind this dream. I think i haven't found my identity (yes i have identity crisis). like in my dream, the girl i like doesn't like me, get bully by so call friends and no significant achievement in my fields.

I have completed none of my personal project. given them up half way during the project, that's why i have not much progress in my fields. i should really put more effort in my current project and make it a successful one. let's pray to my god

Wednesday, July 29, 2009

Tower defense games review

I Played a quite a few TD games during lunch time recently, some of the games added brilliant twists to this sub-genre, i listed the them here

1) Desktop tower defense - path finding, custom path
2) Xeno Tactic 2 - each tower can only upgrade certain amount of times and each time can only update a type of attributes (range, speed, damage), this created unique attributes for each tower
3) Shock to the system - Flash 3d with tron style graphics
4) GemCraft - the gem crafting system
5) Vector TD - non-tower, general purpose buildings for more damage, range and firing rate. and also low level tower has unique attribute make them valueble even at latter part of game

Tuesday, July 21, 2009

similarity in javascript and actionscript in time functions

dealing with actionscripting and javascipting recently, need to port a time related javascript to actionscript. the Date class and setTimeOut are almost the same but have some differences, i listed them here
1) javascript Date.parse format is "date mon year hr:min:sec GMT" example: 21 Aug 2009 10:10:10 GMT. but actionscript Date.parse format is "mon date hr:min:sec year" example Aug 21
2) javascript setTimeout syntax is setTimeout("func(param1, param2)", timeout), actionscript is setTimeout(Functor, timeout, param1, param2)

in this project i also learnt how to exchange data between javascript and actionscript.
javascript->actionscript could use tag or swfobject flashvars
acriptscript->javascript could use ExternalInterface.call("func", param1, param2,paramn)

I have also learn how to use swfobject to insert swf into a div, it is by using the div id in the swfobject.embed second parameter

Wednesday, July 8, 2009

great progress on web 2.0 development

recently i have great exposure to web 2.0 and flash technologies. they are eye wide opening experience, very different from my pass c++ and java experience. i guess this is the current hot stuff, the web platform.

Thursday, June 11, 2009

Internet is polluted with obsolete data

Internet is reaching her 50 year olds, to human this is an old age, i believe it is still true in cyber space. people are keep adding contents to internet but no one is evaluating the relevance of the contents. recently i was learning xml builder from internet, but most of the information are obsoleted, this is worse than no information are provided. end up it took me 1 whole just to figure out how it build a xml. some organisation really should look into this, who know, this could be profitable business in one day :)

Wednesday, June 3, 2009

Life is like driving

Life is like driving, once you get into wrong lane, you will get further and further away from your goal. but driving is better, you still have chance to make a U-turn and back to the right path, of cause time is wasted but in real life you may not able to find the U-turn. yes it's that scary.

Speaking is the same, once you say somthing and spoilt the atmosphere, it is very hard to make it right again, sometime to more you try to make it right, the more creepy you become. still don't understand what is the best thing to do in this situation, i found the the least harmful way t end it is to let the other party you alright and you hope everyone is alright then end the conversation. sigh...

Tuesday, May 12, 2009

Another lesson learned

8 hours brain frying debugging finally solved a crashed bug. yes it's a single bug reported in Bugzilla, but it's actually contributed by many sources.
  1. Singleton object, one of the third party library use singleton and my application is multithreaded, so they were on fire. lesson learned: singleton is bad
  2. Smart pointer, another third party uses smart pointer to manage memory, therefore depends on state it might help me clean up my memory :). lesson learned: raw pointer isn;t that difficult then the behavior is better understood so use more raw pointer
  3. Unreset windows event, if a event was created with manual reset attribute, the state will stay set until it is manually resetted, this make your program only work correctly at the first time
  4. thread id, GetThreadId() is only available on window vista and 64bit xp. on xp stored the id yourself. and the question is where to get the id? if you used _beginthread or _beginthreadex, it is the thrdadd parameter
  5. WM_USER event doesn't dispatch by DispatchMessage(), the reason still a big mistery, hopefully i could find out soon
  6. if you got interlocking problem while you delete child window with DestroyWindow(), try set exstyle to WS_EX_NOPARENTNOTIFY when you create child window, this could prevent the interlocking. (more testing needed)
  7. the infamous, interface class no virtual destructor problem, see my previous post
  8. and many more careless mistakes that do not worth to mention here
But the problem still not fully solved yet, such as keyboard input become not responsive if multiple instances exist. and closes multiple instances at once may still cause the crash. I guess QA still need to curse and swear me for some time :)

Wednesday, May 6, 2009

destructor of interface derived class will never get called

interface struct in C++ is a structure contained only pure virtual functions. no data member shall be declared in interface struct. and because of this no constructor and destructor needed. 

here come the pitfall, consider this

struct IBase
{
virtual void doSomething() = 0;
}

class Derived : public IBase
{
Derived() { text = new char[64]; }
virtual ~Derived() { delete [] text; }

virtual void doSomething() { printf("%s", text);
}

IBase *obj = new Derived();
delete obj;

It was looking perfectly fine to me, until i placed a break point in the derived class destructor. one of the solution is to add a virtual destructor to IBase, but this is ugly and unbalance. the solution I adopted was use self made init() and uninit() insteads.

Monday, May 4, 2009

OpenGL Stack overflow

This strange problem bugging me for some time. the scenario is create opengl rendering context on an existing window, opengl render successfully until the window resize or window bring to top, the window crash immediately after that.

The problem was caused by the opengl context was created on a window that wasn't build for opengl, there are some requirement for a opengl ( i got the hint from this MSDN help)

The solution is create a child window for the exisitng window, the settings work for me was:

[quote]
exStyle = WS_EX_TOPMOST;
style = WS_CHILD | WS_VISIBLE;
[/quote]

Thursday, April 30, 2009

firefox plugin failed to load

If your created a firefox plugin and it able to load up but NP_GetEntryPoints() never get called, and you are using visual studio, check your module definition file and make sure it is specified in your project file :)

Sunday, April 26, 2009

Multithread plugin architecture

Spending few weeks on a (overly?) complicated c++ plugin architecture, and today i have it working :) and this new plugin architecture is to replaced my old method, which was heavy in dll and light in exe.

My old method let the plugin handle threading and windowing, and this lead to a heavy dll, and it was hard to control under certain situation, such as web application. web browser doesn't provide enough facility for cleaning up resources when destroy command is given, this lead to a nightmare, my web application always crash at exit. with this new architecture, the resources could be free up immediately without synchrounous with external thread. my following work will be implementing a web application utilising this new architecture :)

Monday, April 6, 2009

elegant way to erase a node from an iterating list

It is always puzzle me why erasing a stl node inside a loop is so troublesome, example:

for (i = List.begin(); i != List.end(); )
{
temp_i = i; // to prevent the "chain" breaks by the erased node
++i;
List.erase(temp_i);
delete *temp_i;
}

There is a more elegant way to do the similar thing

for (i = List.begin(); i != List.end(); )
{
delete *i;
i = List.erase(i); // return element that followed the last element erased by the function call
}

elegant right?

Sunday, April 5, 2009

ICE is hot

yes i was talking about ICE network framework from zeroc. i use it to develop a multiplayer prototype, it was very complete, although i didn't use it to it fullness but i could see it is a well written libraries a lot of potential, it remind me python twisted framework. going to spend some time to go through the manual

Tuesday, March 31, 2009

Threading and windowing

Recently i have tried windowing in mutithreaded mode, meaning the parent in one thread and child window in another thread. and that's is possible unless the CreateWindow() and PeekMessages() are called within the same thread, if they are not within the same thread, the application will be hanging or couldn't get windows messages.

Friday, March 27, 2009

Set backs

Yesterday night was the lousiest night i ever had, i was driving to meet my dream girl Delia and that was my longer ride too, during the trip i almost had a car accident, at the moment i don't feel sorry to the motorcyclist because i was in the rush to the meeting point, and i believe it was the driver fault, he didn't take note of my car signal. but the worse thing didn't end here, after meeting my girl and have some chats her then i realised she already had a boyfriend, and they already committed to each other. wth? how could i miss all these? it was like paisley case, i'm so dumb. sigh...
i'm hope the driver is doing alright and the girls happy always :)

ok here are the thing to take note while driving
1) when cutting to other lane, must use side mirror, not by turning head
2) no rushing
3) don't look elsewhere more then 5 sec while driving, always pay attention to your front
4) slow down during traffic light even it is green
5) train your slope parking.

Saturday, February 14, 2009

Gained some insight

Just some quick notes of some thing i learnt:
  • Should use unit test whereever is possible. recently done some tests with QA team, discovered the process is extremely inefficient, we programmers have make their live misserable. i felt sorry for them. if we could discouple of graphics code and logic code and place the logic code into individual lib, i'm sure we could run unit test on the logic code. must do this in future.
  • Doxygen is good. i was using doxygen for my had over material. i find it very useful, should've used it earlier :)
  • new use of interfaces. interface should be the first thing to design when creating a new module. by doing this we won't be distracted from the details. for example if a framework project required memory allocator, a memory allocator could be designed first and use some simple technique to implement it first. more focus could be given to the frameowork. and interface wor well unit test.
  • Asynchronous design is really really very important. can't stress enough how important it is. recently having some disagreement with my co-worker, it was due his implemention of resource handling is extremely rigid, everything need to be managed on my side. I couldn't send commands in this order Add(), Remove(), Add(), Remove(). my side must make sure resource are remove then add new resource to it. therefore if my code are async, it should be able work with these crap library. moral of the story, if your co-worker is a newbie, your interface with his module better be async :)

Thursday, February 5, 2009

Career

Today I decided to said bye bye to my current employer, and join a new startup, mainly due to the new resposibility, and instability in my current company. my new responsibilty is team leader, i able to build my own team and decide on the technology is really very attractive to me.

i wish with this new responsiblity i could build up my leadership, build up my contacts to path away for total independants. god bless me

Saturday, January 24, 2009

Blender madness

Learning blender for my last LightFeather engine test (previous test was, scene import export, shader tests). this last test is animated model export and import. I decided to follow BSoD tutorial to create a animated character then use LightFeather exporter to export it lfm format. while following the tutorial I have picked up some useful technique, worry that I'll forget them soon, since I don't do modeling often, I decided to note down the useful technique here :)

1) Use Numpad with laptop
Blender uses numpad for camera control, but laptop has no numpad, to use number row insteads, drag down menu bar then goto "system & opengl" then enable "enumerate Numpad"

2) Linked vertex selection
to select linked vertex, hold down alt key then rmb a vertex, all linked vertex will be selected as well, to select other linked vertex, rmb the same vertex again.

3) Undo list
alt+u for history list, handy

4) duplicate vertexes
press key 'e' then rmb to cancel it, new vertexes are duplicate at the same location as original.

5) simulate "offset" CAD function in blender
select vertexes and press key 's' then hold down ctrl key, move mouse to offset the vertexes.

6) remove overlapped vertexes
press key 'w' then select "Remove Doubles"

7) Useful shorcut keys
ctrl+r == loop cut
ctrl+n == recalculate normal in edit mode
ctrl+tab == vertex, edge and face mode swither if mesh selected, pose mode if armature selected
shift+s == snap menu, able to snap selected object and 3d cursor
alt+b == clip the selected area, good for hiding unwanted area
alt+r == reset rotation
alt+g == reset transition
c == move camera to 3d cursor or center view (3d cursor could be adjust by view->view properties...
m == move object to diff layer
f = create a face


8) save version number
f2 to call up save dialogbox, use number to postfix the filename, press key + to change increment the postfix number, '-' to decrement the postfix number.
alt + '+' or alt + '-' for minor version
shift + '+' or shift + '-' for medium version
ctrl + '+' or ctrl + '-' for major version

9) influence move
select a vertex and press key '0' all nearby vertexes will be move together with the vertex, to increase it influence, use mouse wheel (mw)

Thursday, January 8, 2009

Lua, Blender, flex, memory allocators == today topic

Is about time to go to bed, let's spend a few minutes to note down what i have learnt these few days

Lua
===
- Environment table is per module (or class), registry table is for all module. to assign an environment table to a module u should do this (i don;t understand it actually, since luaL_register did create new table internally)
lua_newtable(L);
lua_replace(L, LUA_ENVIRONINDEX);
luaL_register(L, libname, funclist);
- longer the table it is, more stall time for gc it is
- lua debugger use introspect (query) and hook (callback) for debugging (neat)

Blender
=======
- ctrl-e: special edge functions (loop cut)
- ctrl-v: speical vertex function (merge vertexes)
- ctrl-tap: selection method in edit mode
- ctrl-lmb /w vertex selected: duplicate the vertex
- ctrl-lmb /wo vertex selected: create new vertex
- w: subsurface
- k: loop cut
- u: texture unwrap method
- shift-alt-b: baked Shadow to texture (must make sure the background color is white

Flex
====
- forget about pure actionscript but still mxml is still a need

Memory Allocator
===============
- an allocator has two types, object and data types, object need to use special new operator
- don't need to implement it now, only need to resign yourself.

ok my eye lib refuse to keep opening any longer, night!

Tuesday, January 6, 2009

Feasibility studies for the big Three

Have spend time to study the feasibility of the three projects, the result is they are all feasible (of course). I have set some short term goals for them

  1. Async platform, added more thought to it, the event system shouldn't be specific to any of the module, for example event for renderer, event for window are bad idea, bad for making the system rigid and not generic. the new event system should be generic any module and talk to any module, the only constraint is from the logic module. the short term goal of this project is to let window and renderer module communicate to each other through the event system
  2. SmartFlex framework, I have research on java's nio libraies (mina, grizzly, nio framework and xsocket) and also study the feasibility of flex program without mxml. the outcome is xsocket is the one, because it is less web centric (oppose to grizzly), the design is closer to standard network library (mina let you design protocol), and the small foot print. but flex without mxml was an failure, because flex without mxml has compile prolem, theme problem and view stack problem. the short term goal for this project was to setup a flex project with mxml and yet object oriented.
  3. LightFeather project, I have successfully import 3d models with textures into lightfeather, the next approach will be importing animated avatar into it.
yap so far so good, may the time with me :)