Ok so i am trying to write a/am if statement to set a random X,Y position for a sprite
here is what i have (I'm very noobish with codeing) am i going about it the right way

here is my function for DRAW

Sprite_Draw_Frame(explosion, posx,posy, frame, 128, 128, 6);

here is the function

void Sprite_Draw_Frame(LPDIRECT3DTEXTURE9 texture, int destx, int desty, int framenum, int framew, int frameh, int columns)
{
	D3DXVECTOR3 position( (float)destx, (float)desty, 0 );
	D3DCOLOR white = D3DCOLOR_XRGB(255,255,255);

	RECT rect;
 	rect.left = (framenum % columns) * framew;
	rect.top = (framenum / columns) * frameh;
	rect.right = rect.left + framew;
	rect.bottom = rect.top + frameh;

	spriteobj->Draw( texture, &rect, NULL, &position, white);
}

and here is what im trying (not so well) to use to change the var's for pos and posy

if (frame==0)
		{
			posx = (int)srand(time);
			posy = (int)srand(time);
		}

Edited 5 Years Ago by Dholcroft79: n/a

ok i tryed to set the seed where i set my variable declarations (with global scope)
and this is what im getting

srand((unsigned int)time(NULL));

Error 1 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

Error 2 error C2365: 'srand' : redefinition; previous definition was 'function'

Edited 5 Years Ago by Dholcroft79: n/a

This article has been dead for over six months. Start a new discussion instead.