I need to generate random numbers for a function in my game. If the number generated is even the player gets an item, if its odd it fails. At the moment my character needs to cut down some wood. I tried this:
Code:
A:
if(key [KEY_ENTER])
{
(srand(static_cast<unsigned>(time(0))));
while(true)
{
rand()%1+1;
if(rand()%2==0)
{
textprintf_ex(backbuffer, font, 3, 450, makecol(255, 255, 255), 0, "You obtain a piece of wood!");
wclvlxp+=10;
readkey();
}
else if(rand()%2==1)
{
textprintf_ex(backbuffer, font, 3, 450, makecol(255, 255, 255), 0, "You fail cutting the tree.");
readkey();
goto A;
}
}
}
but after i go to the tree and click enter, the game freezes. Anyone know how to fix this?