Right now, I'm trying make an object move. Let say I'm trying to print a box or a circle, what commands should I use in order to make it move? Like should I use while loops, etc? Examples would be nice.
Oh, I should say that I don't want to move the box using keyboard inputs. I'm using Codeblocks and within a 16x16 coordinate screen I want the box to move in a constant motion, bouncing back and forth.
case WM_TIMER:
switch(wParam)
case ID_TIMER1:
{
//if msgbox is showing, dont move it
if(!bMsgBoxShowing)
{
//timer event, handling window movement
MoveWindow(hDlg,cxPos,cyPos,90,90,TRUE);
cxPos += cxSpeed;
cyPos += cySpeed;
if((cxPos+90) >= cxScreen || cxPos <= 0)
cxSpeed *= -1;
if((cyPos+90) >= cyScreen || cyPos <= 0)
cySpeed *= -1;
}
break;
}
see whats happening.on each timer tick i am incrementing x and y coordinates to cxSpeed and cySpeed. these are displacement variables which determine how to move on one tick.
now if the box reaches to the edges then change the sign of the Speed variable and the box will automatically start to move in opposite direction. lets say its moving right and down and lets say it touches right most boundary. so what should happen.. it should now start to move in left and down position. because now cxSpeed will be negative. think and i hope you will get it.