Path: chuka.playstation.co.uk!news From: Tones Newsgroups: scee.yaroze.programming.2d_graphics Subject: Re: Boundaries still don't work Date: Fri, 06 Nov 1998 17:21:22 +0000 Organization: PlayStation Net Yaroze (SCEE) Lines: 43 Message-ID: <36433012.8439F839@cwcom.net> References: <363BB11F.2BD02604@aol.com> NNTP-Posting-Host: 193.82.133.201 Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 4.05 [en] (Win95; I) Omar Metwally wrote: > I tried to put boundaries to the screen, and it failed. Craig told me to > put: > > if (TestSprite.x > (320-17) > TestSprite.x=320-17; > if(TestSprite.y > (240-17)) > TestSprite.y = 240-17; > > Well, this worked, but only for the bottom and the right side of the > screen. What about the top and left side of the screen??? Hello Omar, Right, if you haven't worked it out yet, here is a suggestion : Firstly, at the beginning of the check store the sprites position into two variables (Ie Player1x, Player1y). Now do the check (something like this ) : int Player1x = TestSprite.x, Player1y = TestSprite.y; if ((TestSprite.x > (320-17)) | (TestSprite.x < (0+17))) TestSprite.x = Player1x; //This will restore the players position if ((TestSprite.y > (240-17)) | (TestSprite.x < (0+17))) TestSprite.y = Player1y; Basically all it is doing is testing 2 conditions on each pass - and if they are true, it'll leave the player where he is. This will sort out the problem of testing all sides of the screen. Hope this helps Tones 8)