• entries
38
87
• views
34662

# Yay NeHe

374 views

NeHe

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.

Snippets

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 arguementint 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 )   {      choiceList[count]=i;      count++;      i = va_arg( marker, int);   }   va_end( marker );              /* Reset variable arguments.      */   if (rand()%(1000)>chanceOfFirst)     return ( choiceList[0] );   else     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:
difficulty=level*100;ChooseHouse=makeChoice(difficulty,  makeChoice(1000,htRegular,htPaper,htIgloo,htSnowy,htKrapMart,htIcePalace,-1), // Bonuses  makeChoice(1000,htBouncy,htNuclear,htSniper,htXmasTree,htEye,htBone,-1),-1); // Baddies

## 1 Comment

Congrats-ulations.

## Create an account

Register a new account