Hi, I've been trying to follow up on the tutorials on youtube, everything was going on well for me until you didn't finish up on the solution to Lesson 9's assignment (that is, the solution you started on episode 10). please would you do something extra-ordinary and post an entire solution for me? (I've been trying to avoid asking for this on the forum since it been 2 years... but this particular solution is why I believe I've lost out - please I need this)
I must add that I got the rectangle moving around but cannot seem to resize the area. Thank you.
Beginner Lesson 9 assignment problems!!!
-
- Posts: 2
- Joined: August 13th, 2014, 12:59 pm
-
- Posts: 432
- Joined: September 26th, 2013, 4:57 pm
- Location: Kentucky
- Contact:
Re: Beginner Lesson 9 assignment problems!!!
Please clear up what your actual question is. It is wasting people's time to have them go through and watch the two lessons to try to figure out what you're talking about.
What are you trying to do? Resize a rectangle?
What are you trying to do? Resize a rectangle?
PM me if you need to contact me. Thanks to all the helpful people on this forum especially to Chili.
-
- Posts: 2
- Joined: August 13th, 2014, 12:59 pm
Re: Beginner Lesson 9 assignment problems!!!
yes I want to see the code for resizing the rectangle
-
- Posts: 432
- Joined: September 26th, 2013, 4:57 pm
- Location: Kentucky
- Contact:
Re: Beginner Lesson 9 assignment problems!!!
Two questions.
1. Have you been successful in creating a draw line function?
If you were having trouble with the DrawLine function, then it should look something like this
2. Have you been successful in creating a Draw Rectangle function?
If you have had issues creating a Draw Rectangle function, it should look something like this considering you have a working DrawLine function
If you have done both of these and still are having issues resizing a rectangle, your issue is you need to pass a variable to hold one or more of the coordinates depending on which you're changing.
The only last thing I can think of is maybe you're storing your variables that hold the coordinates in the wrong scope. Try declaring them in your Game object if you are passing variables and having issues resizing the rectangle just to test.
1. Have you been successful in creating a draw line function?
If you were having trouble with the DrawLine function, then it should look something like this
Code: Select all
void D3DGraphics::DrawLine( int x1,int y1,int x2,int y2,int r,int g,int blu )
{
int dx = x2 - x1;
int dy = y2 - y1;
if( dy == 0 && dx == 0 )
{
PutPixel( x1,y1,r,g,blu );
}
else if( abs( dy ) > abs( dx ) )
{
if( dy < 0 )
{
int temp = x1;
x1 = x2;
x2 = temp;
temp = y1;
y1 = y2;
y2 = temp;
}
float m = (float)dx / (float)dy;
float b = x1 - m*y1;
for( int y = y1; y <= y2; y = y + 1 )
{
int x = (int)(m*y + b + 0.5f);
PutPixel( x,y,r,g,blu );
}
}
else
{
if( dx < 0 )
{
int temp = x1;
x1 = x2;
x2 = temp;
temp = y1;
y1 = y2;
y2 = temp;
}
float m = (float)dy / (float)dx;
float b = y1 - m*x1;
for( int x = x1; x <= x2; x = x + 1 )
{
int y = (int)(m*x + b + 0.5f);
PutPixel( x,y,r,g,blu );
}
}
}
If you have had issues creating a Draw Rectangle function, it should look something like this considering you have a working DrawLine function
Code: Select all
void D3DGraphics::Draw_Rectangle(int topleftx, int toplefty, int bottomrightx, int bottomrighty, int r, int g, int b)
{
for (int i = toplefty; i <= bottomrighty; i++)
{
DrawLine(topleftx, i, bottomrightx, i, r, g, b);
}
}
If you have done both of these and still are having issues resizing a rectangle, your issue is you need to pass a variable to hold one or more of the coordinates depending on which you're changing.
The only last thing I can think of is maybe you're storing your variables that hold the coordinates in the wrong scope. Try declaring them in your Game object if you are passing variables and having issues resizing the rectangle just to test.
PM me if you need to contact me. Thanks to all the helpful people on this forum especially to Chili.