why is this not working?

This is a discussion on why is this not working? within the Game Programming forums, part of the General Programming Boards category; ok, im making a game in c++ and its a text based pac man game. Every once and a while, ...

  1. #1
    Registered User heat511's Avatar
    Join Date
    Dec 2001
    Posts
    169

    why is this not working?

    ok, im making a game in c++ and its a text based pac man game. Every once and a while, walls fall and impede your path. These walls fall randomly. I have this weird problem where walls land in places outside of my 2d array. Anyone know why this is happening?

    Code:
    srand( (unsigned)time( NULL ) );
    intrndnum = (rand() % 39) + 1;
    and does this code make from 1 to 39? I think it should but I'm not sure.

    thanks

  2. #2
    Unregistered
    Guest
    That part of your code appears to be correct (though if this is within a loop, I would not srand each time, but have that up above.

    That rand will generate a number from 1 to 39 possibly including 1 or 39.

    -Justin

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Function not working
    By sloopy in forum C Programming
    Replies: 31
    Last Post: 11-12-2005, 07:08 PM
  2. Program Not working Right
    By raven420smoke in forum C++ Programming
    Replies: 2
    Last Post: 09-16-2005, 03:21 AM
  3. Trying to eject D drive using code, but not working... :(
    By snowfrog in forum C++ Programming
    Replies: 3
    Last Post: 05-07-2005, 07:47 PM
  4. x on upper right corner not working
    By caduardo21 in forum Windows Programming
    Replies: 1
    Last Post: 02-20-2005, 07:35 PM
  5. cygwin -> unix , my code not working properly ;(
    By CyC|OpS in forum C Programming
    Replies: 4
    Last Post: 05-18-2002, 04:08 AM

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