• Advertisement
Sign in to follow this  
  • entries
  • comments
  • views

Yay NeHe

Sign in to follow this  



Yay! NeHe has posted my message about Psycho Boy 3D on his front page. NeHe's tutorials have been a great help in making the game, infact the game started from his tutorial on making a textured cube, I for-looped the cube rendering to make a row of cubes, added a house texture on them and it grew from there.


Making the randomly generated levels has been tricky but this function I made has helped:
// Pre: arguments terminate with -1, maximum 100 arguments
// Post: If random(1000)>chanceOfFirst return first arg
// else return a randomly selected integer arguement
int makeChoice( int chanceOfFirst,int first, ... )
int count = 0, choiceList[100], i = first;
va_list marker;

va_start( marker, first ); /* Initialize variable arguments. */
while( i != -1 )
i = va_arg( marker, int);
va_end( marker ); /* Reset variable arguments. */
if (rand()%(1000)>chanceOfFirst)
return ( choiceList[0] );
return( choiceList[rand()%(count)] );

Basically, it takes a variable number of integer arguments (up to 100 and terminated with -1) and returns a randomly selected one. You can also give higher odds for getting the first one with chanceOfFirst with 0 being always pick the first argument and 1000 giving each argument an even chance.

So my code for working out which houses to pick goes something like this:

makeChoice(1000,htRegular,htPaper,htIgloo,htSnowy,htKrapMart,htIcePalace,-1), // Bonuses
makeChoice(1000,htBouncy,htNuclear,htSniper,htXmasTree,htEye,htBone,-1),-1); // Baddies
Sign in to follow this  

1 Comment

Recommended Comments

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement