lundi 16 mars 2015

Object initialized with random numbers

I'm pretty new to c++ and oo, so this is probably something pretty silly. This is all in the code right after my include statements.



enum ObjType { CUBE, CONE, };
typedef struct {
ObjType type;
float x;
float y;
float z;
int selected;
} object;

static object objects[] =
{
{ CUBE, rand()%11-4, rand()%-10-5, rand()%-65-55, 0},
{ CONE, rand()%11-4, rand()%-10-5, rand()%-65-55, 0},
}


I make a call to srand, passing in the current time, in my main method. However, this is generating the same random numbers every time the program is wrong. What am I not understanding?


Aucun commentaire:

Enregistrer un commentaire