Help for lesson 11 :(

The Partridge Family were neither partridges nor a family. Discuss.
Post Reply
Zergling
Posts: 10
Joined: July 4th, 2012, 3:14 am

Help for lesson 11 :(

Post by Zergling » July 4th, 2012, 3:28 am

hi chili im a newly programmer i've been watching your videos a few days now getting meh 3 hours on and off. I followed the instructions and the video for some reason i cant figure this out i was wondering if u can find the damn annoying problem :( class D3DGraphics
{
public:
D3DGraphics( HWND hWnd );
~D3DGraphics();
void PutPixel( int x,int y,int r,int g,int b );
void DrawLine( int x1,int y1,int x2, int y2,int r,int g,int bl );
void DrawCircle( int cx,int cy,int rad, int r,int g,int b );
void BeginFrame();
void EndFrame(); k i did tht part in D3DGraphics.h for the declaration of DrawCircle now this is the part is messing me up........... void D3DGraphics::DrawCircle( int cx,int cy,int rad, int r,int g,int b );
{
float radSqr = rad * rad;
for( int x = -rad; x <= rad, x++ )
{
int y = sqrt( radSqr + x*x );
PutPixel( x,y,r,g,b );
} } k it might look fine but in my screen it says for the 1st { under D3DGraphics::DrawCircle.etc its saying 1>..\Assets\D3DGraphics.cpp(125): error C2447: '{' : missing function header (old-style formal list?)
im pretty sure the void was it but ..... then DrawCircle in 3D3Graphics.cpp its saying 1>..\Assets\D3DGraphics.cpp(124): error C2761: 'void D3DGraphics::DrawCircle(int,int,int,int,int,int)' : member function redeclaration not allowed Please help :( k and idk why in the post my }} is together but its not its under each other just to make tht clear

Zergling
Posts: 10
Joined: July 4th, 2012, 3:14 am

Re: Help for lesson 11 :(

Post by Zergling » July 4th, 2012, 3:34 am

WOW nvm after looking over and over i just noticed one little small mistake *facepalms* i feel like a idiot i noticed i put the ; after void D3DGraphics::DrawCircle( int cx,int cy,int rad, int r,int g,int b ) well i will enjoy viewing your videos and become a programmer and i was wondering if you get to teach us about game engines too because that seems like i need help with that when i reach there.

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

Re: Help for lesson 11 :(

Post by LuX » July 4th, 2012, 3:20 pm

Good thing you solved it yourself. But just to clarify, c++ language doesn't care even if you put all the code on just one line, that why we use the squiggly brackets, to tell the compiler which parts of the code belongs where.

There might be a few exceptions, but just speaking generally.
At learning stage I would still recommend to brake the lines down like chili does, but later to save scrolling space, you can start putting short code blocks neatly on one line.
ʕ •ᴥ•ʔ

Zergling
Posts: 10
Joined: July 4th, 2012, 3:14 am

Re: Help for lesson 11 :(

Post by Zergling » July 4th, 2012, 10:39 pm

k im having a problem agn the cursor i drew is...... off idk if its the line of cursor pixels or the math in compose frame part heres what i got void Game::ComposeFrame()
{
const int baseX = 250;
const int baseY = 150;
const int squareSize = 100;

if( kbd.RightIsPressed() )
{
cursorX++;
if(cursorX > 2 )
{
cursorX = 2;
}
}
if( kbd.LeftIsPressed() )
{
cursorX--;
if( cursorX < 0 )
{
cursorX = 0;
}
}
if( kbd.DownIsPressed() )
{
cursorY++;
if( cursorY > 2 )
{
cursorY = 2;
}
}
if( kbd.UpIsPressed() )
{
cursorY--;
if( cursorY < 0 )
{
cursorY = 0;
}
}


DrawGrid( baseX,baseY );
DrawCursor( baseX + cursorX * squareSize,baseY + cursorY * squareSize );
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 ) == O )
{
DrawO( baseX + ix * squareSize,baseY + iy * squareSize );
}
}
}
} k then i have this in drawcursor one void Game::DrawCursor( int x,int y )
{
gfx.DrawLine( x + 8,y + 8,x + 48,y + 8,0,255,0 );
gfx.DrawLine( x + 8,y + 9,x + 8,y + 48,0,255,0 );
gfx.DrawLine( x + 91,y + 91,x +51,y + 91,0,255,0 );
gfx.DrawLine( x + 91,y + 90,x + 91,y + 51,0,255,0 );
} idk which is wrong but this one is the same as chili so im watching over parts too what i did wrong somewhere.

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

Re: Help for lesson 11 :(

Post by LuX » July 4th, 2012, 11:21 pm

I don't really understand what problem you mean, but I bet it's your cursor being stuck at the top left of the screen ; -D (possibly giving you an error?)

Explain in more detail or upload the project.
ʕ •ᴥ•ʔ

Zergling
Posts: 10
Joined: July 4th, 2012, 3:14 am

Re: Help for lesson 11 :(

Post by Zergling » July 5th, 2012, 3:06 am

hm idk how to add the the program to here when i try it says no sln extension allwoed how u make my code and all come to here and allow u to see what it shows on the frame when i start the solution up

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

Re: Help for lesson 11 :(

Post by chili » July 5th, 2012, 3:12 am

Bro, read the forum rules. You know, the sticky at the top of the forum that says: "READ THIS FIRST". ;)
Chili

Zergling
Posts: 10
Joined: July 4th, 2012, 3:14 am

Re: Help for lesson 11 :(

Post by Zergling » July 5th, 2012, 3:30 am

lol thanks haha shudve read tht one. k so i uploaded and i have some future stuff within lesson 12 just ht when i got there was error with the part else if( !( kbd.RightIsPressed() l l
kbd.LeftIsPressed() l l
kbd.UpIsPressed() l l
kbd.DownIsPressed() ) )
yea tht part when i tried it said error im missing a ")" before the l l. in ur video idk what the l l were but i put it there and error so i decided i start over from the grid part of the lesson delete the else if part and leave the s0-s8 state coding there and the cases there so tht i dunt need to write all tht agn when i get back to that part. Right now im in lesson 10 looking at the part where u create your Drawline coding but it cant be tht my line coding is wrong otherwise the grid would be off too am i right? but still the cursor part where it shows like l```


___l kinda thing but in my it shows tht in the middle of the grid but if i go anywhere else either the top left of the cursor changes to be in left mid if the square and when i go to section s0-s2 the bottom right cursor has a long tail of pixels which goes into the other squares.... u got to see what i see my cursor goes bad once it goes away from the mid lol
Attachments
Chili DirectX Framework - Copy.zip
(8.42 MiB) Downloaded 140 times

Post Reply