Lesson 9 Assignment (HELP FOR YOU WITH SQUARE)

The Partridge Family were neither partridges nor a family. Discuss.
Post Reply
ElmerCoder
Posts: 10
Joined: March 5th, 2013, 8:00 pm

Lesson 9 Assignment (HELP FOR YOU WITH SQUARE)

Post by ElmerCoder » March 5th, 2013, 8:08 pm

Hi :) , I've made the square being able to be moved and Minimized. (Have not fixed going back to normal yet )

This is how it looks:


int y = boxY;
while( y < boxY + boxWidth )
{
int x = boxX;
while( x < boxX + boxWidth )
{
gfx.PutPixel(x,y,255,255,255);
x = x + 1;
}

y = y + 1;
}
That is the whole Square

if (kbd.RightIsPressed() )
{ boxX = boxX + 1;

}
if (kbd.LeftIsPressed() )
{ boxX = boxX - 1;

}
if (kbd.DownIsPressed() )
{ boxY = boxY + 1;

}
if ( kbd.UpIsPressed() )
{ boxY = boxY - 1;

}

That is the movement up here :)

if ( kbd.SpaceIsPressed() )
{
if ( boxX > boxWidth )
{
if ( boxY > boxWidth )
{

boxWidth = boxWidth - 1;


}


}


}

This was the Minimize.
Hope i helped a bit. I'm going to try make it go back to its originarly form without holding spacebar.

Game.cpp : Game::Game( HWND , etc etc etc... )
boxY( 250 ),
boxX( 350 ),
boxWidth( 100 )


Game.h : Private :
int boxX;
int boxY;
int boxWidth;
int boxHeight;



Now to fix that it should go back to its originarly state as it was in the beginning is not too hard to figure out... :D after the ''Minimize''
(The 3 } you had in the end you add :

else
{ boxWidth = boxWidth + 1;
}
if( boxWidth > 100 )
{ boxWidth = 100;
}
which means : If not holding down spacebar to make it decrease it takes the boxWidth in the boxWidth and add with 1 pixel every time.
If BoxWidth is LARGER than 100, boxWidth equals (=) 100.

Btw I'm a new Coder , i've followed all the 9 lessons and i'm on my 10th
Chili Your an awesome helper!! :)
Never coded in my whole life before.
Too exhausted right now ;) Learned this in 2 days :P.

Post Reply