Scrolling a map(vertical only)
#include "defines.h"
int mapRow, mapIndex, tileIndex;
typedef struct
{
int posx;
int posy;
int obs;
}CELL;
CELL cells[]={
// x, y
{0,0},
{0,0},// blank wall 1
{0,64}, // 2
{0,128}, // 3
{0,192}, // 4
{0,256}, // 5
{0,320}, // 6
};
int MapOne[GAME_PORT_HEIGHT][GAME_PORT_WIDTH] = {
{3,3,3,1,2,1,3,1,1,1},
{3,3,3,1,2,1,3,1,1,1},
{3,3,3,1,2,1,3,1,1,1},
{3,3,3,1,2,1,3,1,1,1},
{3,3,3,1,2,1,3,1,1,1},
{3,3,3,1,2,1,3,1,1,1},
{3,3,3,1,2,1,3,1,1,1},
{3,3,3,1,2,1,3,1,1,1},
{3,3,3,1,2,1,3,1,1,1},
{1,1,1,1,1,1,3,1,1,1},
{1,1,1,1,1,1,1,1,1,1},
{1,1,1,1,1,1,1,1,1,1},
{1,1,1,1,1,1,1,1,1,1},
{1,1,1,1,1,1,1,1,1,1},
{1,1,1,1,1,1,1,1,1,1},
{1,1,1,1,2,1,1,1,1,1},
{1,1,1,2,1,1,1,1,1,1},
{1,1,1,2,1,1,1,1,1,1},
{1,1,1,2,1,1,1,1,1,1},
{1,1,1,2,1,1,1,1,1,1},
};
void DrawBase()
{
int tileSize = 64;
RECT tileRect;
int destx, desty;
for (mapRow = 0; mapRow < GAME_PORT_HEIGHT; mapRow++)
{
for (mapIndex = 0; mapIndex < GAME_PORT_WIDTH; mapIndex++)
{
tileIndex = MapOne[mapRow][mapIndex];
if(tileIndex > 0)
{
tileRect.left = cells[tileIndex].posx;
tileRect.top = cells[tileIndex].posy;
tileRect.right = tileRect.left + tileSize;
tileRect.bottom = tileRect.top + tileSize;
destx = mapIndex * tileSize;
desty = mapRow * tileSize-640;
BlitSurface( lpDDSOffscreen, lpDDSBack, destx,desty,&tileRect, FALSE);
}
}
}
}
for (int y=currentY;...)
for (int x=currentX;...)