Advertisement

Wrap arounds?

Started by November 22, 2002 01:46 PM
15 comments, last by MattS423 21 years, 11 months ago
Is there a negitive LanderX? does some DDraw thing somewhere prevent me from doing negitive numbers, so it jus truncates them to zero?

you guys have the code...am i doing something wrong?
Programmers of the world, UNTIE!
if((LanderX+LanderDesc.dwWidth) >= ddsd.dwWidth )
{
LanderX = 0;
}
else if(LanderX < 0 )
{
LanderX = ddsd.dwWidth - LanderDesc.dwWidth - 1;
}

try that
Advertisement
The compiler might do some nastyness, as you widths are DWORDs (= unsigned long). I don''t think it should do any difference, but to rule that out, you could try casting them before using, ie:
LanderX = (int)ddsd.dwWidth - (int)LanderDesc.dwWidth - 1;

Is the problem still that it disappears when some part of the lander is outside? If so, you probably still have a clipper issue, with which I cannot help.

ok, that works great to wrap on the leading edge. what about the trailing edge?

could if be...


if((LanderX) >= ddsd.dwWidth )
{
LanderX = 0;
}
else if(LanderX < 0 - LanderDesc.dwWidth)
{
LanderX = ddsd.dwWidth - LanderDesc.dwWidth - 1;
}

no...when i do that...it glues itself to the right edge of the screen.

[edited by - MattS423 on November 22, 2002 8:15:40 PM]
Programmers of the world, UNTIE!
CWizard, once again you prove to be a genius. it works.

thanks for all your help.


here is my final code, jus tin case anybody is wondering.


  if(LanderX > (int)ddsd.dwWidth ) 	{ 		LanderX = 0; 	}		else if((LanderX + (int)LanderDesc.dwWidth  ) < 0 ) 	{ 		LanderX = (int)ddsd.dwWidth - (int)LanderDesc.dwWidth - 1; 	}	if(LanderY > (int) ddsd.dwHeight)	{		LanderY = 0;	}	if((LanderY + (int)LanderDesc.dwHeight) < 0)	{		LanderY = (int)ddsd.dwHeight - (int)LanderDesc.dwHeight - 1;	}  
Programmers of the world, UNTIE!
Good

Just a note, if it was the casting that solved it: you don''t need to cast on all of the variables, only those that you want to be negative. For example, in this:
if(LanderX > (int)ddsd.dwWidth)
the right-hand comparing value will never be negative, so you don''t need it to be signed there.

But if it''s working and you''re happy with it, let it be.

Advertisement
quote: Original post by CWizard


That''s pretty cool....You''ve even set it up so the count isn''t increased repetitively when you scroll down the page.
______________________________________________________________________________________The Phoenix shall arise from the ashes... ThunderHawk -- ¦þ"So. Any n00bs need some pointers? I have a std::vector<n00b*> right here..." - ZahlmanMySite | Forum FAQ | File Formats______________________________________________________________________________________

This topic is closed to new replies.

Advertisement