Path: chuka.playstation.co.uk!news From: Andrew Partington Newsgroups: scee.yaroze.freetalk.english Subject: negative scrolling on homebrew map routine - need help!! Date: Wed, 14 Mar 2001 14:09:54 +0000 Organization: PlayStation Net Yaroze (SCEE) Lines: 52 Message-ID: <3AAF7BB2.B427AED3@harbinger.com> NNTP-Posting-Host: gate.harbinger.co.uk Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 4.7 [en] (WinNT; I) X-Accept-Language: en Hi everyone I have a 98% working routine for drawing my own maps (I don't want to use the GsBG stuff supplied because I want zoomrotation in my project!). It zoomrotates fine, and seems to work 100% when scrolling in a positive direction (i.e. down and to the right). However, my maths fails on the following range of negative numbers... The problem lies in the following formula, which calculates the block in the map to start drawing from: offsetX = (X scroll position (in pixels) / block size X (also in pixels) ) % background size X (number of blocks going across the map, in this case 80); I'm using the mod operator in order to wrap the values around to the other side of a 2D array containing map data if the scrollX/scrollY values go out of range. For any positive numbers I am asking to scroll the map by, this approach works fine... However, If the scroll value is in the range of -blocksize to (-blocksize * 16) (i.e. in the range of -16 to -256), the offset of the map comes out in the range of positive 15 - 0! (I need it to be in the range of 79 to 64). Any negative scroll numbers NOT in this range work fine!!! This is mathematically correct (well according to Windows calculator anyway ;) , but its a very annoying bug - when you scroll in a negative direction and you hit that particular range of scroll values, it looks like some of the old cartoon backgrounds where you notice the wraparound :) Is there any way I can make this approach work for all negative numbers without having to reset my scroll positions for the map, and without having to resort to a large number of complex, error-prone IF statements? I kinda like the simplicity of the maths as it seems to work for most cases... (if I reset my scroll positions, that would work for that particular map, but will knacker any parallax effects I have - and I don't think you have to resort to any similar kludges when using the GsBG16 stuff!) Sorry if this message isn't clear, i'm on my dinner break at work and I don't have my routine/CW project in front of me to post it, i'll do that when I get home... I hope someone can help out with this problem, it's been holding me back for about 3 months, and I wanna get back into the swing of things!!! Cheers Andy