delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/10/18/18:00:29

From: Jared Stevens <stevja AT lineo DOT com>
Organization: Lineo
To: djgpp AT delorie DOT com
Subject: Re: Game Speed
Date: Mon, 18 Oct 1999 15:30:57 -0600
X-Mailer: KMail [version 1.0.21]
References: <H3jO3.7505$Tk DOT 157563 AT news DOT tpnet DOT pl>
MIME-Version: 1.0
Message-Id: <99101815345000.05137@sparky.lineo.com>
Reply-To: djgpp AT delorie DOT com

On Sun, 17 Oct 1999, you wrote:
> Hello everybody
> 
> I programmed a simple game in C.
> (I used DJGPP and ALLEGRO)
> But the game runs on different Computers with
> a different speed.
> Is it possible, that the game runs on all
> Computers with a similar speed ?
> Please Help me immidiately .

In Allegro you can use a timer routine... what that is, is a function that is
called every, say 30 ms, (you can specify the rate). That function increments a
global variable every time it is called. In your program, all you have to do is
check that variable and see if it is '1' yet. If it is still '0', then loop
until it is '1'. When it equals or is above '1', run a loop of your game, and
set the variable back to 0. 

There is an example of this in some of the examples that came with allegro, I
can't remember which one, but it is in there. 

--
Jared Stevens

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019