Problem with lesson 8

The Partridge Family were neither partridges nor a family. Discuss.
Post Reply
kratrs
Posts: 8
Joined: May 22nd, 2012, 2:46 am
Location: California

Problem with lesson 8

Post by kratrs » May 22nd, 2012, 2:55 am

Hi! I was following through the tutorial just fine, but when I got to the end where the face was collecting all the poo the game over screen would pop up when i collected the poo at the bottom and sometimes the entire screen would just go black.. Please help?!
Attachments
Solution File.rar
(38.2 KiB) Downloaded 167 times
Image

User avatar
zentojamorn
Posts: 10
Joined: May 22nd, 2012, 4:22 am

Re: Problem with lesson 8

Post by zentojamorn » May 22nd, 2012, 4:36 am

In this part of your program
if( !( poo1IsEaten && poo2IsEaten && poo3IsEaten) )
{
if( !poo1IsEaten )
{
if( faceX + 20 > poo1X &&
faceX < poo1X + 24 &&
faceY + 20 > poo1Y &&
faceY < poo1Y + 24 )
{
poo1IsEaten = true;
}

DrawPoo( poo1X, poo1Y );
}
if( !poo2IsEaten )
{
if( faceX + 20 > poo2X &&
faceX < poo2X + 24 &&
faceY + 20 > poo2Y &&
faceY < poo2Y + 24 )
{
poo2IsEaten = true;
}

DrawPoo( poo2X, poo2Y );
}

if( !poo3IsEaten )
{
if( faceX + 20 > poo3X &&
faceX < poo3X + 24 &&
faceY + 20 > poo3Y &&
faceY < poo3Y + 24 )
{
poo3IsEaten = true;
}

DrawPoo( poo3X, poo3Y );
}
else
{
DrawGameOver( 375, 275 );
}

DrawFace( faceX, faceY );
}
From your nested if-else,your program will gameover in case of poo3IsEaten only.
Your problem is you messed up brackets.

PS.Sorry for poor english. :(
Sorry for my poor english..

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

Re: Problem with lesson 8

Post by LuX » May 22nd, 2012, 6:49 am

You should study, and learn to use "for" statement and arrays for poos. There is no need to write all that separately for each poo. :x

Or maybe this comes after tutorial 8...
ʕ •ᴥ•ʔ

User avatar
zentojamorn
Posts: 10
Joined: May 22nd, 2012, 4:22 am

Re: Problem with lesson 8

Post by zentojamorn » May 22nd, 2012, 7:39 am

I didn't watch the whole tutorial in programming pooEater game but I recognize that "for" statement and arrays for poos comes after tutorial 8.
Sorry for my poor english..

User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: Problem with lesson 8

Post by chili » May 22nd, 2012, 3:09 pm

Yeah arrays come later.

Thanks for answering this guys question Zento. ;)
Chili

kratrs
Posts: 8
Joined: May 22nd, 2012, 2:46 am
Location: California

Re: Problem with lesson 8

Post by kratrs » May 22nd, 2012, 10:59 pm

Thanks Zento! I managed to fix the problem :D
Image

Post Reply