Thread: why is this not working?

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

    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?

    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.


  2. #2
    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.


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, 08: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, 08: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