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 );
}
}
}
}
Lesson 12 problem
-
- Posts: 115
- Joined: April 27th, 2012, 11:49 pm
Re: Lesson 12 problem
Only thing I see differentiating from the Tic Tac Toe game I have on my system is SquareSize variable should be set to 100.
Re: Lesson 12 problem
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 --
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 --
-
- Posts: 2
- Joined: June 8th, 2013, 2:54 am
Re: Lesson 12 problem
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.
Re: Lesson 12 problem
oh, well, ok
well gonna point out something in your code above tho :p
that would be a problem
well gonna point out something in your code above tho :p
Code: Select all
else if( GetSquareState( ix, iy ) == 0 )
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 --
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 --