Jump to content
Sign in to follow this  
  • entries
    38
  • comments
    87
  • views
    34579

Yay NeHe

Sign in to follow this  
Patbert

353 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 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 )
{
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
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
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!