Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


A few questions

This topic is 5869 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

1. timeGetTime(), How do I use it??? I want to use it to make a game timer but I recieve undeclared identifier errors when I compile 2. How would probability work in C++? For example if I wanted there to be a 30% chance of something happening or not.

Share this post

Link to post
Share on other sites
timeGetTime() i think you get if you #include <windows.h>. I think many will argue that there are better timers than this one, though.

For probability you could use something like this:

if((rand() % 100) <= 30) ThenDoThis();

[edited by - CWizard on September 1, 2002 6:38:39 PM]

Share this post

Link to post
Share on other sites
timeGetTime is actually not a bad method if you don''t mind EXE size. You''ll need to include mmsystem.h and then link winmm.lib

There are dozens of threads on random numbers. A cheap way to do a 30% chance requires you to include stdlib.h and time.h and then use this code:

//call this once at the outset of your program:
srand(time(0)); // I think this''ll work. Lemme know if it doesn''t.

//execute this each time you need a chance:
bool WillHappen = (rand()/(double)RAND_MAX) <= 0.3;


//email me.//zealouselixir software.//msdn.//n00biez.//
miscellaneous links

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!