Scroll map region corruption
Posted: Wed Oct 07, 2015 12:33 am
So, i was trying to make it scroll less then 8 pixels by changing the xscroll to a float, but now i have a new problem. (still doesn't scroll less than 8 pixels, don't know what to do)
The graphics corrupt while i have scrollx going, and the player is passing above or bellow the npc to trigger the zorder change.
I don't think it's because i switch to a float, but that i switch sprite array order while its scrolling. What you think it could be?
Here is the code.
Code that switches zorder.
if (player1.posy > cxypos[1][0])
{
if (triggerIndex == 1)
{
player1.pzorder = 0;
czorder = 1;
SPR_initSprite(&sprites[player1.pzorder], &jason_sprite, player1.posx, player1.posy, TILE_ATTR(PAL1, TRUE, FALSE, FALSE));
SPR_initSprite(&sprites[czorder], &fcitizen_sprite, cxypos[0][0], cxypos[1][0], TILE_ATTR(PAL2, TRUE, FALSE, FALSE));
triggerIndex = 0;
}
}
else
{
if (triggerIndex == 0)
{
player1.pzorder = 1;
czorder = 0;
SPR_initSprite(&sprites[player1.pzorder], &jason_sprite, player1.posx, player1.posy, TILE_ATTR(PAL1, TRUE, FALSE, FALSE));
SPR_initSprite(&sprites[czorder], &fcitizen_sprite, cxypos[0][0], cxypos[1][0], TILE_ATTR(PAL2, TRUE, FALSE, FALSE));
triggerIndex = 1;
}
}
Map scrolling code.
if (tileproperty == TILEPROP_NOTSOLID) { scrollH = 1; } else { scrollH = 0; }
if ((value & BUTTON_RIGHT) && MapXPosInTile < 152 && scrollH == 1 )
{
SYS_disableInts();
MapXPosInTile += 0.1;
pInMAX = (player1.posx/16)+MapXPosInTile;
cxypos[0][0] -= 0.1;
SPR_setPosition(&sprites[czorder], cxypos[0][0], cxypos[1][0]);
indb = TILE_USERINDEX;
VDP_setMapEx(BPLAN, map, TILE_ATTR_FULL(PAL0, FALSE, FALSE, FALSE, indb), PlanXPosInTile, PlanYPosInTile, MapXPosInTile, MapYPosInTile, MapWidthInTile, MapHeightInTile);
indb += bgb_image.tileset->numTile;
SYS_enableInts();
}
if ((value & BUTTON_LEFT) && MapXPosInTile > 0 && mright != 1 && scrollH == 1 && tileproperty == TILEPROP_NOTSOLID)
{
SYS_disableInts();
MapXPosInTile -= 0.1;
pInMAX = (player1.posx/16)+MapXPosInTile;
cxypos[0][0] += 0.1;
SPR_setPosition(&sprites[czorder], cxypos[0][0], cxypos[1][0]);
indb = TILE_USERINDEX;
VDP_setMapEx(BPLAN, map, TILE_ATTR_FULL(PAL0, FALSE, FALSE, FALSE, indb), PlanXPosInTile, PlanYPosInTile, MapXPosInTile, MapYPosInTile, MapWidthInTile, MapHeightInTile);
indb += bgb_image.tileset->numTile;
SYS_enableInts();
}
The graphics corrupt while i have scrollx going, and the player is passing above or bellow the npc to trigger the zorder change.
I don't think it's because i switch to a float, but that i switch sprite array order while its scrolling. What you think it could be?
Here is the code.
Code that switches zorder.
if (player1.posy > cxypos[1][0])
{
if (triggerIndex == 1)
{
player1.pzorder = 0;
czorder = 1;
SPR_initSprite(&sprites[player1.pzorder], &jason_sprite, player1.posx, player1.posy, TILE_ATTR(PAL1, TRUE, FALSE, FALSE));
SPR_initSprite(&sprites[czorder], &fcitizen_sprite, cxypos[0][0], cxypos[1][0], TILE_ATTR(PAL2, TRUE, FALSE, FALSE));
triggerIndex = 0;
}
}
else
{
if (triggerIndex == 0)
{
player1.pzorder = 1;
czorder = 0;
SPR_initSprite(&sprites[player1.pzorder], &jason_sprite, player1.posx, player1.posy, TILE_ATTR(PAL1, TRUE, FALSE, FALSE));
SPR_initSprite(&sprites[czorder], &fcitizen_sprite, cxypos[0][0], cxypos[1][0], TILE_ATTR(PAL2, TRUE, FALSE, FALSE));
triggerIndex = 1;
}
}
Map scrolling code.
if (tileproperty == TILEPROP_NOTSOLID) { scrollH = 1; } else { scrollH = 0; }
if ((value & BUTTON_RIGHT) && MapXPosInTile < 152 && scrollH == 1 )
{
SYS_disableInts();
MapXPosInTile += 0.1;
pInMAX = (player1.posx/16)+MapXPosInTile;
cxypos[0][0] -= 0.1;
SPR_setPosition(&sprites[czorder], cxypos[0][0], cxypos[1][0]);
indb = TILE_USERINDEX;
VDP_setMapEx(BPLAN, map, TILE_ATTR_FULL(PAL0, FALSE, FALSE, FALSE, indb), PlanXPosInTile, PlanYPosInTile, MapXPosInTile, MapYPosInTile, MapWidthInTile, MapHeightInTile);
indb += bgb_image.tileset->numTile;
SYS_enableInts();
}
if ((value & BUTTON_LEFT) && MapXPosInTile > 0 && mright != 1 && scrollH == 1 && tileproperty == TILEPROP_NOTSOLID)
{
SYS_disableInts();
MapXPosInTile -= 0.1;
pInMAX = (player1.posx/16)+MapXPosInTile;
cxypos[0][0] += 0.1;
SPR_setPosition(&sprites[czorder], cxypos[0][0], cxypos[1][0]);
indb = TILE_USERINDEX;
VDP_setMapEx(BPLAN, map, TILE_ATTR_FULL(PAL0, FALSE, FALSE, FALSE, indb), PlanXPosInTile, PlanYPosInTile, MapXPosInTile, MapYPosInTile, MapWidthInTile, MapHeightInTile);
indb += bgb_image.tileset->numTile;
SYS_enableInts();
}