Hello everyone! First time posting on the forums.
I’m working on a game in AS3, using the Flex SDK and Flash Develop. I’m creating a very basic GameEngine base class to handle time-based updating, input, etc., and I was wondering if any Actionscript game gurus could point me in the write direction, design wise.
Most tutorials I’ve seen use frame-based updating. I want to use time-based methods, mostly because in tests I’ve run, swf’s run a bit erratically (fps wise), especially when running in a browser. I want to know the game’s visual components are moving at the same speed regardless of the frame rate. Is my reasoning flawed? Is the benefit of using frame-based updates (less code, computation, etc) actually worth the uncertain fps? And if so, are there techniques to assure the game runs as smoothly as possible?
I’ve been setting stage.frameRate to 1000, so that the time-based algorithms run as fast as possible, and so that if (for some reason) the game is loaded into another swf, it will run at the correct speed (rather than just set the frame rate while compiling). I found browsers will run a 60fps swf at around 23fps, yet the same browser will run a 1000fps swf at well over 60fps. Is there any downside to running that fast?
How should I be thinking of updating objects on the screen? For instance, I’ve though of having a base class for game objects, and each one created gets added to a static array. Then each instance in the array has their “update()” function called per frame, with the fractional number of seconds since the last frame. I’m guessing I just have to be careful and remember to remove them from the display list AND the array when I want them to be GCed. Is this too simplistic? Too complex? Are there other ways which might prove less computationally expensive?
Thanks in advance for any and all feedback!