Solved

OnTimer() - clockspeed

Posted on 1998-09-22
5
328 Views
Last Modified: 2008-02-26
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
Comment
Question by:SileNcer
  • 3
  • 2
5 Comments
 

Author Comment

by:SileNcer
Comment Utility
Edited text of question
0
 

Author Comment

by:SileNcer
Comment Utility
Edited text of question
0
 
LVL 8

Accepted Solution

by:
Answers2000 earned 20 total points
Comment Utility
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
 

Author Comment

by:SileNcer
Comment Utility
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
 
LVL 8

Expert Comment

by:Answers2000
Comment Utility
The _slowest_ computers have 18.2 ticks per second hence the 1000/18,
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now