Article View: rec.games.programmer
Article #1750Re: Game timing
From: Chris Green
Date: Fri, 18 Dec 1992 13:11
Date: Fri, 18 Dec 1992 13:11
60 lines
2784 bytes
2784 bytes
In article <1992Dec17.144044.18199@westminster.ac.uk> fkpec@westminster.ac.uk (Liaket Ali) writes: >A question (hypothetical) related to Game timing... > >I have an AMIGA 500 and will soon be getting a 1200 which is a faster computer. >The game that I'm currently writing runs at 10 frames per second on the A500. >However, I would like the game to run at 20fps on the A1200 but be smoother. >This means that it will not zoom past at twice the speed but instead will increment the display view by half increments. > >For example, consider a flight simulator which, say, updates 10 pixels in 1 frame in order to achieve a frame rate of 10fps. >I would like to be able to then update 5 pixels in 1 frame to achive 20fps. > >Is this possible? And how would I go about programming it. > >Thanks for any info. > What you do is determine the elapsed time from frame to frame each time. On the amiga, the easiest and highest resolution way to do this is to call ReadEClock, which returns a 64 bit count, and how many counts there are per second. Subtract the previous value, and divide by (counts_per_sec>>15). This will return an elapsed time in 32768th's of a second. Multiply all incremental poistion increments by this fraction when determining how much to move per frame. For instance, my simple movement code for moving at an arbitrary angle along the ground is: move.w PlayerHeading(a6),d0 bsr sincos ; d0=sin d1=cos move.w frfract(a6),d2 ; frfract=elapsed time 32768=1 sec muls d2,d0 muls d2,d1 add.l d0,d0 add.l d1,d1 swap d0 swap d1 move.w PlayerSpeed(a6),d2 muls d2,d0 muls d2,d1 add.l d0,d0 add.l d1,d1 swap d0 swap d1 ext.l d0 ext.l d1 add.l d0,PlayerX(a6) add.l d1,PlayerZ(a6) rts This will give the same movement rate on everything from an A500 to an A4000. -- *-------------------------------------------*---------------------------* |Chris Green - Graphics Software Engineer - chrisg@commodore.COM f | Commodore-Amiga - uunet!cbmvax!chrisg n |My opinions are my own, and do not - icantforgettheimpression o |necessarily represent those of my employer.- youmadeyouleftaholeinthe r |"A screaming comes across the sky..." - backofmyhead d *-------------------------------------------*---------------------------*
Technical Details
Message-ID:
<38038@cbmvax.commodore.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!cbmvax!chrisgReferences:
<1992Dec17.144044.18199@westminster.ac.uk>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!cbmvax!chrisg From: chrisg@cbmvax.commodore.com (Chris Green) Newsgroups: rec.games.programmer,comp.sys.amiga.programmer Subject: Re: Game timing Message-ID: <38038@cbmvax.commodore.com> Date: 18 Dec 92 13:11:08 GMT References: <1992Dec17.144044.18199@westminster.ac.uk> Reply-To: chrisg@cbmvax.commodore.com (Chris Green) Organization: Commodore, West Chester, PA Lines: 60