View Full Version : Building a Game - An RTS Barracks

Mar 21st, 2007, 04:36 PM
I am trying to build an online web browser based RTS game. I am making the barracks script where the user clicks the "build" button and new units are built for the player.

The problem I am having is that if the user leaves the page or refreshes the page the JS countdown timer (which is the timer that counts the time left until the unit is built) is not persistent (of course not -- JS is client side!). So I am trying to make it persistent by doing server-side checks.

I can't seem to reliably do it.

Here is the sample script:

1. click to build a few soliders, snipers and rangers
2. refresh the page
3. watch what happens to the timers.. only 1 timer countsdown, the rest stay stagnant. This is the problem.
4. take a look at the source code: I need to make all of the count down timers run through the function countDown() -- how to do it?

Mar 22nd, 2007, 09:42 AM
php I believe

Mar 22nd, 2007, 11:32 AM
I know this is a totally different direction, but have you considered using Adobe Flex?

Mar 22nd, 2007, 11:52 AM
Yes I have considered Adobe Flex. But why learn a whole new language when I know this problem can be solved using JS and PHP