Generated side-scroller map

SGDK only sub forum

Moderator: Stef

Post Reply
alko
Very interested
Posts: 172
Joined: Thu Aug 07, 2014 9:31 am
Location: Russian Federation

Generated side-scroller map

Post by alko » Tue Jan 26, 2016 7:31 pm

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.)
Image

Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: Generated side-scroller map

Post by Stef » Tue Jan 26, 2016 8:05 pm

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)) //

alko
Very interested
Posts: 172
Joined: Thu Aug 07, 2014 9:31 am
Location: Russian Federation

Re: Generated side-scroller map

Post by alko » Wed Jan 27, 2016 7:56 am

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.
Image

Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: Generated side-scroller map

Post by Stef » Wed Jan 27, 2016 10:15 am

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;
}

Post Reply