Lesson 12 problem

The Partridge Family were neither partridges nor a family. Discuss.
Post Reply
Razzzleberry
Posts: 2
Joined: June 8th, 2013, 2:54 am

Lesson 12 problem

Post by Razzzleberry » June 10th, 2013, 4:20 pm

Hey guys, I have been working on lesson 12 for a while, re-watching parts I kinda don't get and making sure I understand. In the process I guess I messed up one of Chili's instructions and after being about an hour into the video I try to run it as he does, but instead of seeing the grid and the X and O I get build successful with no errors, but it breaks as I try to run it. Upon closer inspection I notice my rad, r, g, and b are some outrageously large numbers. I can't seem to figure out why. I'm sure it's a simple answer and I'm just looking over it but if someone could help me out I would be much appreciated. Here's the code for drawing the circle:

void D3DGraphics::DrawCircle( int cx, int cy, int rad, int r, int g, int b )
{
float radSqr = rad * rad;
int x0 = 0.7071068f * rad + 0.5f;

for( int x = 0; x <= x0; x++ )
{
int y = sqrt( radSqr - x*x ) + 0.5f;
PutPixel( cx + x,cy + y,r,g,b );
PutPixel( cx + y,cy + x,r,g,b );
PutPixel( cx - x,cy + y,r,g,b );
PutPixel( cx - y,cy + x,r,g,b );
PutPixel( cx + x,cy - y,r,g,b );
PutPixel( cx + y,cy - x,r,g,b );
PutPixel( cx - x,cy - y,r,g,b );
PutPixel( cx - y,cy - x,r,g,b );
}
}




And here's the code for manifesting it on the screen:



void Game::ComposeFrame()
{
const int baseX = 250;
const int baseY = 150;
const int SquareSize = 200;

DrawGrid( baseX, baseY );
for( int iy = 0; iy < 3; iy++ )
{
for( int ix = 0; ix < 3; ix++ )
{
if( GetSquareState( ix, iy ) == X )
{
DrawX( baseX + ix * SquareSize, baseY + iy * SquareSize );
}

else if( GetSquareState( ix, iy ) == 0 )
{
DrawO(baseX + ix * SquareSize, baseY + iy * SquareSize );
}
}
}
}

nG Inverse
Posts: 115
Joined: April 27th, 2012, 11:49 pm

Re: Lesson 12 problem

Post by nG Inverse » June 10th, 2013, 4:50 pm

Only thing I see differentiating from the Tic Tac Toe game I have on my system is SquareSize variable should be set to 100.

User avatar
LuisR14
Posts: 1248
Joined: May 23rd, 2013, 3:52 pm
Location: USA
Contact:

Re: Lesson 12 problem

Post by LuisR14 » June 10th, 2013, 9:43 pm

well you posted what your composeframe and drawcircle functions do but you didn't post what your DrawO function does (but posting your whole solution would be more helpful, follow this first before posting it tho)
always available, always on, about ~10 years c/c++, java[script], win32/directx api, [x]html/css/php/some asp/sql experience. (all self taught)
Knows English, Spanish and Japanese.
[url=irc://irc.freenode.net/#pchili]irc://irc.freenode.net/#pchili[/url] [url=irc://luisr14.no-ip.org/#pchili]alt[/url] -- join up if ever want real-time help or to just chat :mrgreen: --

Razzzleberry
Posts: 2
Joined: June 8th, 2013, 2:54 am

Re: Lesson 12 problem

Post by Razzzleberry » June 10th, 2013, 10:25 pm

Thanks for the help! What nG Inverse said fixed the issue, although upon running it, now EVERY square is filled with a circle, but that seems simple to fix, haha. I'll zip and attach code in the future.

User avatar
LuisR14
Posts: 1248
Joined: May 23rd, 2013, 3:52 pm
Location: USA
Contact:

Re: Lesson 12 problem

Post by LuisR14 » June 11th, 2013, 2:06 am

oh, well, ok :P
well gonna point out something in your code above tho :p

Code: Select all

else if( GetSquareState( ix, iy ) == 0 )
that would be a problem :)
always available, always on, about ~10 years c/c++, java[script], win32/directx api, [x]html/css/php/some asp/sql experience. (all self taught)
Knows English, Spanish and Japanese.
[url=irc://irc.freenode.net/#pchili]irc://irc.freenode.net/#pchili[/url] [url=irc://luisr14.no-ip.org/#pchili]alt[/url] -- join up if ever want real-time help or to just chat :mrgreen: --

Post Reply