Lesson 11 Source Files?

The Partridge Family were neither partridges nor a family. Discuss.
Post Reply
adabo
Posts: 154
Joined: October 27th, 2012, 3:28 am
Location: Houston, Texas

Lesson 11 Source Files?

Post by adabo » October 27th, 2012, 3:42 am

I'm super new to c++ and all this math business... failed miserably throughout highschool.

I'm having an odd problem with the circle plotting. I mimicked all your instructions and kept up with all your build outputs(including the incomplete circle parts that you systematically debugged). The part that everything broke for me is right after you added the second putpixel line. I swear I have everything in the same order, but apparently something is missing. Instead of a circle, I get 2 horizontal lines xD

Are there any source files I can look at to find out what I'm doing wrong? I've gone over and over and I just don't know what's wrong. Thanks :)

adabo
Posts: 154
Joined: October 27th, 2012, 3:28 am
Location: Houston, Texas

Re: Lesson 11 Source Files?

Post by adabo » October 27th, 2012, 3:48 am

For reference, here's what I wrote:

Code: Select all

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(cx + x,cy + cy,r,g,b);
        PutPixel(cx + x,cy - cy,r,g,b);
    }
}

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

Re: Lesson 11 Source Files?

Post by chili » October 27th, 2012, 3:50 am

I have a better idea. First, read the forum rules on posting code, and then post your solution.
Either myself or somebody else will give you a hint that should lead you to the solution.
Chili

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

Re: Lesson 11 Source Files?

Post by chili » October 27th, 2012, 3:52 am

Just saw your code. You're really going to facepalm when you figure it out. Take a very close look at your putpixel calls and you should see the problem.
Chili

adabo
Posts: 154
Joined: October 27th, 2012, 3:28 am
Location: Houston, Texas

Re: Lesson 11 Source Files?

Post by adabo » October 27th, 2012, 3:55 am

Facepalm.jpg :roll:

I put "cy + cy" and "cy - cy"....
should be "cy + y" and "cy -y"

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

Re: Lesson 11 Source Files?

Post by chili » October 27th, 2012, 3:57 am

That was fast. :p
Chili

adabo
Posts: 154
Joined: October 27th, 2012, 3:28 am
Location: Houston, Texas

Re: Lesson 11 Source Files?

Post by adabo » October 27th, 2012, 3:57 am

Something else I wanted rave about (and what I think is most important and essential to the learning process) is the thinking you have the students do. Hand holding doesn't do good in the long run. Thanks for not spoiling it for me and thanks for encouraging us to figure stuff out. Cya!

Post Reply