Solved

OnTimer() - clockspeed

Posted on 1998-09-22
5
351 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
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 20 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

ScreenConnect 6.0 Free Trial

Check out the updates in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI that improves session organization and overall user experience. See the enhancements for yourself!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
TCP/IP Socket - connection close results in data lost 14 133
Dynamically allocate memory 9 58
C++ :Change value from  DisableCMD registry 4 59
gdb doesn't stop on breakpoint 2 67
Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
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++.

770 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