Skip to main content
gamedev.net
🔒 Locked

Need Help!!!!!!

Started by Feblex Apr 16, 2002 at 6:43 PM 0 replies 200+ views
Original Post
Feblex
Feblex
I really need some help for a school project I''m doing that is due Thursday. How do you randomly select a texture? I''ve tried the obvious use of a variable (let''s call it a) that is made from a rand statement. I tried placing the variable in place of the number used to specify what texture that you want, but Dev-C++ tells me "invalid types `unsigned int[6][GLfloat]'' for array subscript". How do I select a random texture?
Lukerd
Lukerd
I think you''re on the right track. Create a variable like you said but make it an integer. Then do this:


  
#define NUM_TEXTURES 3 (Or however many you have)

int variable = 0;

variable = rand()%NUM_TEXTURES



Now if memory serves me correctly that should pick a random integer between 0 and NUM_TEXTURES. It''s been a while since I used rand() so I may be wrong.

Oh and dont forget to randomise the numbers by using srand().

Just one question though. Why do you have a 2 dimensional array?

Hope that helps.

"To err is human, to really mess up requires a computer"
"To err is human, to really mess up requires a computer"

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.