Jump to content

  • Log In with Google      Sign In   
  • Create Account

Scrolling a map(vertical only)


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

Likes

Posted 23 October 1999 - 04:22 PM

I'm trying to scroll my map vertically. I having some trouble though. BAsically I want my map to automatically scroll vertically, but I'm not too sure how to do this. coudl someone help...here's the code:


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

}

}
}




Sponsor:

#2 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

Likes

Posted 23 October 1999 - 09:09 AM

I really need help on this...so please help

#3 thmleo   Members   -  Reputation: 122

Like
Likes
Like

Posted 23 October 1999 - 04:22 PM

Store the current map positions and use them in your loop.

for (int y=currentY;...)
for (int x=currentX;...)





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS