First Windows game, FINALLY DONE!

This is a discussion on First Windows game, FINALLY DONE! within the Game Programming forums, part of the General Programming Boards category; Thats good randomising is fairly easy to put in. In case you're interested, this is what I know about generating ...

  1. #31
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    Thats good randomising is fairly easy to put in. In case you're interested, this is what I know about generating random numbers:

    use this to seed the random number generator at the beginning of the program
    #include <time.h>
    srand(time(NULL));

    Or if you are making a Windows app, you can use
    srand((int)GetTickCount());

    use this to get just any random number
    rand();

    To get a random number from "start" to "end", do this:
    int start = 5;
    int end = 10;
    int randomNumber = (rand() % (end - start + 1)) + start;

    To make it easier, make a macro:
    Code:
    #define RANDOM(start,end) ((rand() % ((end) - (start) + 1)) + (start))
    Hope it helps
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  2. #32
    Registered User Kirdra's Avatar
    Join Date
    Aug 2002
    Posts
    105
    Yea thanks, I am using a lot of random numbers for rare items and Enemy/Player attack damage. I've got the random thing worked out now. That clears it up at bit.

Page 3 of 3 FirstFirst 123
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need book to program game into multiplayer...
    By edomingox in forum Game Programming
    Replies: 3
    Last Post: 10-02-2008, 10:26 AM
  2. Game Engine Link Prob
    By swgh in forum Game Programming
    Replies: 2
    Last Post: 01-26-2006, 12:14 AM
  3. Game Designer vs Game Programmer
    By the dead tree in forum Game Programming
    Replies: 8
    Last Post: 04-28-2005, 10:17 PM
  4. Tricks of the windows game programming gurus
    By Nutshell in forum Game Programming
    Replies: 0
    Last Post: 04-25-2003, 12:37 AM
  5. finished my game, finally
    By agerealm in forum Game Programming
    Replies: 15
    Last Post: 10-12-2001, 09:01 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21