-
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
-
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