Page 1 of 1

Generated side-scroller map

Posted: Tue Jan 26, 2016 7:31 pm
by alko
Aloha :o
if map scrolled by single speed, then known at which interval update tiles behind the screen.

Code: Select all

levix++;
VDP_setHorizontalScroll(PLAN_A, levix);
if(levix==256) VDP_setMap(VDP_PLAN_A, levi2, TILE_ATTR_FULL(PAL0, FALSE, FALSE, FALSE, ind2), 16,0);
if(levix==128) VDP_setMap(VDP_PLAN_A, levi3, TILE_ATTR_FULL(PAL0, FALSE, FALSE, FALSE, ind3), 32,0);
if(levix==0) VDP_setMap(VDP_PLAN_A, levi4, TILE_ATTR_FULL(PAL0, FALSE, FALSE, FALSE, ind4), 48,0);
but what to do if levix iteration will vary ? :roll: (levix+=10 or levix+=50, etc.)

Re: Generated side-scroller map

Posted: Tue Jan 26, 2016 8:05 pm
by Stef
Just use range test like that ?

Code: Select all

if ((levix >= 256) && (levix < (256 + 128)) //
if ((levix >= 128) && (levix < (128 + 128)) //
if ((levix >= 0) && (levix < (0 + 128)) //

Re: Generated side-scroller map

Posted: Wed Jan 27, 2016 7:56 am
by alko
Just use range test like that ?
nope...
because it will unoptimized. In a certain period tiles will be drawn several times.
Reasonably just once place picture on plane.

Re: Generated side-scroller map

Posted: Wed Jan 27, 2016 10:15 am
by Stef
Ok, so you can just detect "screen change" then... something as:

Code: Select all

newScreen = levix / 32;   // divsion by 32 is fast as internally it bitshifts by 5

if (newScreen != lastScreen)
{
   VDP_setMap(VDP_PLAN_A, levi2, TILE_ATTR_FULL(PAL0, FALSE, FALSE, FALSE, ind2), newScreen * 32,0);
   lastScreen = newScreen;
}