Path: chuka.playstation.co.uk!news From: "Martin Keates" Newsgroups: scee.yaroze.freetalk.english Subject: Re: negative scrolling on homebrew map routine - need help!! Date: Tue, 20 Mar 2001 02:01:08 -0000 Organization: PlayStation Net Yaroze (SCEE) Lines: 37 Message-ID: <996din$7jl7@www.netyaroze-europe.com> References: <3AAF7BB2.B427AED3@harbinger.com> <98o38v$ij81@www.netyaroze-europe.com> <98p3qp$rms2@www.netyaroze-europe.com> <98t840$6f5@www.netyaroze-europe.com> <99057g$3ok7@www.netyaroze-europe.com> <3AB6404F.65C9AF1C@harbinger.com> NNTP-Posting-Host: modem-102.sodium.dialup.pol.co.uk X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.00.2314.1300 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300 > offsetX = background->scrollX / background->blockSizeX; > while(offsetX < 0) file://Had to change > the if to a while to cope with when things went massively negative! > { > offsetX += background->backgroundSizeX; > } > offset %= background->backgroundSizeX; I don't think this is quite right. Looking at it again you need to check for negativity before doing the integer division. Dividing by 16: -16 = -1, -15= 0, -1= 0, 0= 0, 15=0, 16=1, 31= 1, 32= 2 ==> the first negative block is only 15, and repeats the first positive block. Here's my second spasm at it (splitting positive and negative into 2 cases): if (background->scrollX<0) { offsetX= ((background->scrollX-1)/background->blockSizeX)%background->backgroundSizeX+ background->backgroundSizeX-1; } else { offsetX= (background->scrollX/background->blockSizeX)%background->backgroundSizeX; } The first -1 copes with the size 15 block. The second -1 copes with the negative blocks all being 1 too large. The map drawing certainly looks ok at the moment, so this probably doesn't matter, but you may end getting bugs later (e.g. when trying to compute which block the ship is over). Sorry I've no help for optimising - I'm trying to learn all that stuff myself... Martin.