Random help

hi,
im new to C++ and would like some help :)
im trying to code a text based adventure as part of my coursework and it consists of a 10*10 grid, anyway a monster is supposed to appear (this i have done but after every move the monster is supposed to move a space. so i have monx and mony (x and y values of the monster are random) and i have tried rand() % monx-- || monx++ || mony++ || mony--; but it only changes the first value so everytime it will just do monx--. i hope all this makes some sort of sense :P thankyou in advance :)
look up what % and || does.
well % is the modulus and is the first reason that it only alters monx-- also after further research of || when it looks at the code if the first option is possible (monx--) it goes for that and goes to the next line ignoring the other options. is that correct?
also how would i fix this?
thanks :)
1
2
r=rand()%4;
*(r/2?&monx:&mony)+=r%2*2-1;//I know you won't understnd this. Use a bunch of if statements instead. 
Last edited on
Thankyou :)
Topic archived. No new replies allowed.