Lesson 14 Poo Game, implementing a reset button

The Partridge Family were neither partridges nor a family. Discuss.
Post Reply
TheRoflReaper
Posts: 4
Joined: June 3rd, 2012, 9:57 pm

Lesson 14 Poo Game, implementing a reset button

Post by TheRoflReaper » June 5th, 2012, 3:30 am

Soooo, since i don't like exiting and re-debugging every time i want to play this game... i decided to try to implement a reset button, and i have.. sooo here it is if you wanna do this too


this one is a new function so add it to the Game.h user functions

Code: Select all

void Game::ResetFace()
{
	faceX = 400;
	faceY = 300;
}

this one is also a new function so add it!

Code: Select all

void Game::NewPoo()
{
	for( int index = 0; index < NPOO; index++ )
	{
		pooX[ index ] = rand() % (800 - 24);
		pooY[ index ] = rand() % (600 - 24);
		pooXVelocity[ index ] = (rand() % 8001) / 1000.0f - 4.0f;
		pooYVelocity[ index ] = (rand() % 8001) / 1000.0f - 4.0f;
	}
}

add this code after 'DrawGameOver' so your Game::ComposeFrame() looks like this

Code: Select all

void Game::ComposeFrame()
{
	gfx.DrawDisc( goalX,goalY,GOALRAD,255,255,0 );

	for( int index = 0; index < nPoo; index++ )
	{
			DrawPoo( pooX[ index ],pooY[ index ] );
	}

	DrawFace( faceX, faceY );

	if( gameIsOver )
	{
		DrawGameOver( 375,275 );

		if( kbd.EnterIsPressed())
		{ 
			gameIsOver = false;
			nPoo = 0;
			ResetGoal();
			ResetFace();
			NewPoo();
		}
	}
}
a game isn't complete without a means of restarting that isn't annoying... sooooo... i hope this helped :D

User avatar
LuX
Posts: 1492
Joined: April 22nd, 2012, 12:33 pm
Location: Finland

Re: Lesson 14 Poo Game, implementing a reset button

Post by LuX » June 5th, 2012, 9:35 am

I'm not sure if you should post all this basic stuff here. Don't get me wrong its cool you get things working and want to share some code, but I'm sure other people want to find out how to make something themselves too, it's the best way to learn : -)
ʕ •ᴥ•ʔ

TheRoflReaper
Posts: 4
Joined: June 3rd, 2012, 9:57 pm

Re: Lesson 14 Poo Game, implementing a reset button

Post by TheRoflReaper » June 5th, 2012, 3:59 pm

I know what you mean.. i kind of had that feeling when i was posting this one :D

Post Reply