• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 384
  • Last Modified:

OnTimer() - clockspeed

I have written a a game in VC++5.0, similar to "nibbles", where the user controls a worm that runs across the screen. To display the bitmaps I used the OnTimer() command.
 
Although the game runs fine on my computer, I have tried it on other computers and the worm moves at different speeds.  My computer is running win95 and a slower computer running winNT makes the worm move incredibly too fast to play it.

Can anyone please show me how to set the clockspeed temporarily durring the program, or write a function that will make the game run at the same speed on all systems?
0
SileNcer
Asked:
SileNcer
  • 3
  • 2
1 Solution
 
SileNcerAuthor Commented:
Edited text of question
0
 
SileNcerAuthor Commented:
Edited text of question
0
 
Answers2000Commented:
When you do SetTimer you specify the interval between timer messages (smaller interval makes the game run faster).

Paradoxically I think you have set the timer value too _high_.

WM_TIMER messages may not always get thru (they are not guaranteed).  On the slow computer some are probably being dropped as the screen is still updating or whatever, on the faster computer, more (or all), get thru, hence the faster game.

Change the 2nd (MFC SetTimer) or 3rd parameter (Win API SetTimer) function.  Increase the value.  It's in milliseconds (1000 = 1 second).  Also don't go below 1000/18.
0
 
SileNcerAuthor Commented:
Thanks, I had the timer set to 0, I can change it all the way to 40 and it runs the same, which was the difference between the two computers.
I guess if I want the game to go faster, different skill levels, I can set up another timer.
0
 
Answers2000Commented:
The _slowest_ computers have 18.2 ticks per second hence the 1000/18,
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now