From: "Al Amzeen (Alexandr Amzin)" Newsgroups: comp.os.msdos.djgpp Subject: Re: games speed ? Date: Thu, 6 Apr 2000 21:48:11 +0400 Organization: Fidolook Express page http://fidolook.da.ru Lines: 47 Message-ID: <8ciirf$10rf$1@gavrilo.mtu.ru> References: <5C3H4.8071$pR DOT 68532 AT carnaval DOT risq DOT qc DOT ca> NNTP-Posting-Host: ppp108-126.dialup.mtu-net.ru X-Trace: gavrilo.mtu.ru 955043504 33647 212.188.108.126 (6 Apr 2000 17:51:44 GMT) X-Complaints-To: usenet-abuse AT mtu DOT ru NNTP-Posting-Date: 6 Apr 2000 17:51:44 GMT X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Fidolook Express V1.51rus for MS OE 5.0 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Greetings, Yannick Benoit ! You wrote: > hi, > i made some part of a game and after testing it on few diferent pcs, i found > out that the speed is never the same, sometimes it lags and sometimes its > too fast... > > is there a way to make it the same on every pcs? I think it is better to begin code optimizations. btw, vsync() is slightly unregular procedure when we are talking about run time. Allegro FAQ about subj: How can I make my game run at the same speed on any computer? You need to make sure the game logic gets updated at a regular rate, but skip the screen refresh every now and then if the computer is too slow to keep up. This can be done by installing a timer handler that will increment a global variable at your game logic speed, eg: volatile int speed_counter = 0; void increment_speed_counter() { speed_counter++; } END_OF_FUNCTION(increment_speed_counter); void play_the_game() { LOCK_VARIABLE(speed_counter); LOCK_FUNCTION(increment_speed_counter); install_int_ex(increment_speed_counter, BPS_TO_TIMER(60)); while (!game_over) { while (speed_counter > 0) { update_game_logic(); speed_counter--; } update_display(); } }