Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

OnTimer() - clockspeed

Posted on 1998-09-22
5
Medium Priority
?
383 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 

Author Comment

by:SileNcer
ID: 1173435
Edited text of question
0
 

Author Comment

by:SileNcer
ID: 1173436
Edited text of question
0
 
LVL 8

Accepted Solution

by:
Answers2000 earned 80 total points
ID: 1173437
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
ID: 1173438
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
ID: 1173439
The _slowest_ computers have 18.2 ticks per second hence the 1000/18,
0

Featured Post

Technology Partners: 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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
Suggested Courses

618 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