I need help with some coordinates things

This is a discussion on I need help with some coordinates things within the Game Programming forums, part of the General Programming Boards category; Code: //set up rectangle for filling RECT rcFill; SetRect(&rcFill,ptLastPosition[0].x,ptLastPosition[0].y,ptLastPosition[0].x+gdicBall.GetWidth(),ptLastPosition[0].y+gdicBall.GetHeight()); //set up a ddbltfx DDBLTFX ddbltfx; memset(&ddbltfx,0,sizeof(DDBLTFX)); ddbltfx.dwSize=sizeof(DDBLTFX); //set up a ...

  1. #1
    left crog... back when? incognito's Avatar
    Join Date
    Oct 2001
    Posts
    1,427

    I need help with some coordinates things

    Code:
    	//set up rectangle for filling
    	RECT rcFill;
    	SetRect(&rcFill,ptLastPosition[0].x,ptLastPosition[0].y,ptLastPosition[0].x+gdicBall.GetWidth(),ptLastPosition[0].y+gdicBall.GetHeight());
    
    	//set up a ddbltfx
    	DDBLTFX ddbltfx;
    	memset(&ddbltfx,0,sizeof(DDBLTFX));
    	ddbltfx.dwSize=sizeof(DDBLTFX);
    
    	//set up a color fill of black
    	ddbltfx.dwFillColor=0;
    
    	//blt the color fill to the back buffer
    	lpddsBack->Blt(&rcFill,NULL,NULL,DDBLT_WAIT | DDBLT_COLORFILL, &ddbltfx);
    
    	//set up source and destination rects for blitting the ball
    	RECT rcSrc;
    	RECT rcDst;
    
    	SetRect(&rcSrc,0,0,gdicBall.GetWidth(),gdicBall.GetHeight());
    	CopyRect(&rcDst,&rcSrc);
    	OffsetRect(&rcDst,ptBallPosition.x,ptBallPosition.y);
    
    
    	/*	ptBallPosition.x=0;//remember that this initialized the 
    	ptBallPosition.y=0;    //position of the ball and all that.
    	ptLastPosition[0].x=0;
    	ptLastPosition[0].y=0;
    	ptLastPosition[1].x=0;
    	ptLastPosition[1].y=0;
    
    	ptBallVelocity.x=16;
    	ptBallVelocity.y=8;*/
    	//blit the ball
    	lpddsBack->Blt(&rcDst,lpddsBall,&rcSrc,DDBLT_WAIT, NULL);//don't really need a source 
    
    	//copy current position of ball to old position
    	ptLastPosition[0]=ptLastPosition[1];
    	ptLastPosition[1]=ptBallPosition;
    
    	//move the ball
    	ptBallPosition.x+=ptBallVelocity.x;
    	ptBallPosition.y+=ptBallVelocity.y;
    
    	//bounds checking
    	//left side
    	if(ptBallPosition.x<=0) ptBallVelocity.x=abs(ptBallVelocity.x);
    	//top side
    	if(ptBallPosition.y<=0) ptBallVelocity.y=abs(ptBallVelocity.y);
    	//right side
    	if(ptBallPosition.x>=(int)dwDisplayWidth-gdicBall.GetWidth()) ptBallVelocity.x=-abs(ptBallVelocity.x);
    	//bottom side
    	if(ptBallPosition.y>=(int)dwDisplayHeight-gdicBall.GetHeight()) ptBallVelocity.y=-abs(ptBallVelocity.y);
    
    	//flip surfaces
    	lpddsPrime->Flip(NULL,DDFLIP_WAIT);

    I don't really understand that part that is in bold.
    There are some real morons in this world please do not become one of them, do not become a victim of moronitis. PROGRAMMING IS THE FUTURE...THE FUTURE IS NOW!!!!!!!!!

    "...The only real game I thank in the world is baseball..." --Babe Ruth

    "Life is beautiful"-Don Corleone right before he died.

    "The expert on anything was once a beginner" -Baseball poster I own.


    Left cprog on 1-3-2005. Don't know when I am coming back. Thanks to those who helped me over the years.

  2. #2
    left crog... back when? incognito's Avatar
    Join Date
    Oct 2001
    Posts
    1,427
    When you do this

    ptLastPosition[1]=ptBallPosition;


    and you don't specify what happens wheter it's ptBallPosition.x or ptBallposition.y what happens?
    There are some real morons in this world please do not become one of them, do not become a victim of moronitis. PROGRAMMING IS THE FUTURE...THE FUTURE IS NOW!!!!!!!!!

    "...The only real game I thank in the world is baseball..." --Babe Ruth

    "Life is beautiful"-Don Corleone right before he died.

    "The expert on anything was once a beginner" -Baseball poster I own.


    Left cprog on 1-3-2005. Don't know when I am coming back. Thanks to those who helped me over the years.

  3. #3
    Has a Masters in B.S.
    Join Date
    Aug 2001
    Posts
    2,267
    what is ptLastPosition declared as?

    my guess that the entire (struct/class) is copied hence, after

    ptLastPosition[1]=ptBallPosition;

    ptLastPosition[1]'s 'x' and 'y' 's values should equal that of ptBallPosition's.
    ADVISORY: This users posts are rated CP-MA, for Mature Audiences only.

  4. #4
    left crog... back when? incognito's Avatar
    Join Date
    Oct 2001
    Posts
    1,427
    //position of the ball
    POINT ptBallPosition;
    POINT ptLastPosition[2];
    //velocity of the ball
    POINT ptBallVelocity;
    There are some real morons in this world please do not become one of them, do not become a victim of moronitis. PROGRAMMING IS THE FUTURE...THE FUTURE IS NOW!!!!!!!!!

    "...The only real game I thank in the world is baseball..." --Babe Ruth

    "Life is beautiful"-Don Corleone right before he died.

    "The expert on anything was once a beginner" -Baseball poster I own.


    Left cprog on 1-3-2005. Don't know when I am coming back. Thanks to those who helped me over the years.

  5. #5
    Used Registerer jdinger's Avatar
    Join Date
    Feb 2002
    Posts
    1,065
    elchulo,
    This example is where you have to blit over the last 2 positions of the ball. You are copying the entire struct over. It's the same as if you would have done:
    Code:
    ptTwo.x=ptOne.x;
    ptTwo.y=ptOne.y;
    just with less typing..

  6. #6
    left crog... back when? incognito's Avatar
    Join Date
    Oct 2001
    Posts
    1,427
    Sorry but is this ptLastPosition[1] like a temperary array? That we use just to transfer the data?

    Ok my last ramble for the night, but if
    ptLastPosition[0]=ptLastPosition[1];
    ptLastPosition[1]=ptBallPosition;

    and ptLastPosition[1] is equal to zero, then when we call offrect on the second "round" offrect is not going to move the ball anywhere and this would cause the ball to be blitted twice before it actually moves, by means of offrect or am I wrong? Please help!!!!!!!1
    Last edited by incognito; 05-08-2002 at 09:41 PM.
    There are some real morons in this world please do not become one of them, do not become a victim of moronitis. PROGRAMMING IS THE FUTURE...THE FUTURE IS NOW!!!!!!!!!

    "...The only real game I thank in the world is baseball..." --Babe Ruth

    "Life is beautiful"-Don Corleone right before he died.

    "The expert on anything was once a beginner" -Baseball poster I own.


    Left cprog on 1-3-2005. Don't know when I am coming back. Thanks to those who helped me over the years.

  7. #7
    Has a Masters in B.S.
    Join Date
    Aug 2001
    Posts
    2,267
    im not exactly sure what yer asking

    but if you mean blitting over the balls last two positions before its even originally drawn or moved then yes you would be wasting two blits.
    ADVISORY: This users posts are rated CP-MA, for Mature Audiences only.

  8. #8
    Unregistered
    Guest
    Originally posted by no-one
    im not exactly sure what yer asking

    but if you mean blitting over the balls last two positions before its even originally drawn or moved then yes you would be wasting two blits.

    Yeah that's about it, Thanks

  9. #9
    left crog... back when? incognito's Avatar
    Join Date
    Oct 2001
    Posts
    1,427
    oh BTW that was me from school, didn't feel like signing in, because sometimes I forget and stay signed on!!!!!! Imagine someone posting crap under my name!!!!!?????
    There are some real morons in this world please do not become one of them, do not become a victim of moronitis. PROGRAMMING IS THE FUTURE...THE FUTURE IS NOW!!!!!!!!!

    "...The only real game I thank in the world is baseball..." --Babe Ruth

    "Life is beautiful"-Don Corleone right before he died.

    "The expert on anything was once a beginner" -Baseball poster I own.


    Left cprog on 1-3-2005. Don't know when I am coming back. Thanks to those who helped me over the years.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Suggestions for things to study
    By Mastadex in forum Windows Programming
    Replies: 5
    Last Post: 08-18-2008, 09:23 AM
  2. 2 things at once?
    By bradszy in forum C++ Programming
    Replies: 7
    Last Post: 02-20-2008, 12:19 PM
  3. Converting from Screen to World Coordinates
    By DavidP in forum Game Programming
    Replies: 9
    Last Post: 05-11-2004, 12:51 PM
  4. How to save previous coordinates
    By GaPe in forum C Programming
    Replies: 7
    Last Post: 06-04-2002, 01:26 PM
  5. Help with these three things...
    By face_master in forum C++ Programming
    Replies: 2
    Last Post: 08-26-2001, 07:05 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21