Original Post
Hi!
I've been developing a little java-game for a while now, and it's slowly starting to get ready, but there are some problems that i haven't been able to solve by myself. So maybe someone here could help me out..
The game is implemented as an applet (java 1.1) and theres somekind of half-ready version of the game at http://www.ratol.fi/~tanderss/test/index.html. You're supposed to find the landing platform as fast as possible and land on it.
There are bonus items (+time, -time, shields, nitros, etc) lying around the map which could help/make things worse. There are 2 crappy test maps, the 3rd wone won't work yet.
Turn the ship with the left/right arrow keys, press up-key to accelerate and if you get nitros, press SPACE to use them.
I've mostly tested it on MSIE and appletviewer on Win2K, so dunno how it works on other platforms. Tell me if it bugs like hell
Now, i've been trying to make it as frame-rate independant as i could. Which is i alter the ship speed and other factors based on the current FPS. What i've been wondering, is that on my IE, when i for example pick up some items in the game (a new thread for effect timing is created each time), the FPS goes down so that you can easily see it until the effects wear off and the thread gets terminated.. I've set the threads to MIN_PRIORITY but it still does the thing. Guess there's nothing i can do about it? This problem is only on IE, not appletviewer.
Another thing that i was wondering, what that if the Garbage Collection gets done while the game is running, it can slow things down for a few seconds too. Anything i can do about this? Prevent it from running or something? Again, on appletviewer no 1-2 sec slowdowns seem to come up?
Then: I've got random items around the map. I'm just using Math.random() each time a random item is picked up, and for each item in the map, it seems to return the same value every round (when you select 'play again' from the menu after crashing/landing). If you load the map again, it seems to give new random values which again are the same until you reload the same map. This is pretty weird, as it makes me thing the random generates the seed based on the ship x,y coords which i don't think should be the case?
And the last problem at the moment:
The gravity and inertia values are not effected by the FPS. So as the ship calculations are performed every frame, the gravity and inertia seem to be smaller on slow computers, and higher on fast ones. Currently i just add the gravity to the ship's power-vector y component, and i was wondering that how could i calculate the gravity per frame? With the speed it's easy, just doing SpeedPerFrame = SpeedPerSecond/FPS, but for the gravity and inertia this results in weird results. Probably because those forces are kinda acceleration forces (rising ^2?).
It's a little weird as on Appletviewer the game runs quite smooth (getting a constant ~90 fps), but on IE i get about 70FPS and it seems to jump up and down pretty much. Could the MS JVM do something so different? AFAIK it SHOULD run faster on IE than appletviewer.
Sorry if I've forgot to mention something or haven't been precise enough.. Please note if i forgot to mention something essential.
Thanks
[edited by - fovster on December 5, 2002 3:06:46 PM]