Archived

This topic is now archived and is closed to further replies.

drarem

How would I change this to scroll 1 pixel rather than 32..

Recommended Posts

drarem    100
here is my mess of code to scroll my tilemap (32x32) @ 26x18 screen.. it scrolls it 32 pixels at a time and goes way too fast when using the flip() method (which I still don''t understand.. it scrolls smoothly although I can use a different scroll method to make it scroll chunky via dd->WaitForVerticalBlank(DDWAITVB_BLOCKBEGIN, 0); ) If it scrolls smoothly at 32 pixels.. could it be changed easily to scroll smoothly at 1 pixel? I tried using floats to vary the tx and ty by .5 increments so it is a little slower, but the time lag caused it to scroll chunky. Thanx in advance for any help ~ int ScrollMapV2(int *vMap, IMPA dMap, IDirectDrawSurface7* back, IDirectDrawSurface7* backgrnd, IDirectDrawSurface7* lpA, IDirectDrawSurface7* bgScrollStrip, int direction, int step, RECT lpB, int tx, int ty) { int curx=0; int cury=0; int x=0; int y=0; int frame=0; IMPA tMap; RECT lpR; InitRect(&lpR, 0, 0, dMap.xrez, dMap.yrez); tMap.xrez=32; tMap.yrez=32; for (x=tx; x <= tx+dMap.mxrez; x++) { for (y=ty; y <= ty+dMap.myrez; y++) { frame = vMap[(y*dMap.mxrez) + (x)]; curx=(x*32)-tx; cury=(y*32)-ty; Frame2XY(frame, &tMap); InitRect(&lpR, tMap.e, tMap.f, tMap.erez, tMap.frez ); backgrnd->BltFast(curx,cury,lpA,&lpR,DDBLTFAST_SRCCOLORKEY | DDBLTFAST_WAIT); } } return 0; } I fseek, therefore I fam.

Share this post


Link to post
Share on other sites
drarem    100
grrrr wrong code.. here it is.. unless you have something for the other one lol



int DrawMapV2(int *vMap, IMPA dMap, IDirectDrawSurface7* back, IDirectDrawSurface7* lpA, float x, float y) {
int e=0;
int f=0;
int px=0;
int py=0;
int frame=0;
IMPA tMap;
RECT lpR;
InitRect(&lpR, 0, 0, dMap.xrez, dMap.yrez);
tMap.xrez=32;
tMap.yrez=32;
clearScreen();
while (e <= dMap.mxrez) {
while (f <= dMap.myrez) {
frame = vMap[((f+(int)y)*100) + (e+(int)x)];
if (frame) {
px = (int)x % 32;
py = (int)y % 32;
Frame2XY(frame, &tMap);
InitRect(&lpR, tMap.e, tMap.f, tMap.erez, tMap.frez );
back->BltFast(e*32, f*32, lpA, &lpR, DDBLTFAST_SRCCOLORKEY | DDBLTFAST_WAIT);
}
f++;
}
e++;
if (e < dMap.mxrez) f=0;
}
return 0;
}

Share this post


Link to post
Share on other sites
drarem    100
oops didn''t mean to blow chunks..


really tho, do I need to restructure this function or just add something to it? I know it has to do with offsets, and I have tried them but am not having any success...

my head is swimming from all the concepts I am learning, math burnout, and I am in deep confuscious and am in need of help. mentally preferrably.


l8a




I fseek, therefore I fam.

Share this post


Link to post
Share on other sites
I've heard people ask this before, and it blows my mind why anyone in the world would have this problem. I mean, I made a tile engine that scrolls pixel by pixel with no problem. All you have to do is this:

Set up a 2D array of .. .well, they could be a class, like a tile class, which would have information about the tile, like a pointer to the surface to put down and other stuff like that. Well, basicly, you want to do something like this.

int tileWidth; // you'd have to fill this
int tileHeight;

for(int i; i < howManyHigh; i++)
for(int h; h < howManyWide; h++)
{int tileYPosition = i*tileHeight - scrollY;
int tileXPosition = h*tileWidth - scrollX;
tile[ i][h].draw(tileXPosition, tileYPosition);
}

Basically what this does is you get the width and height of the tile. Then you set a loop to go through the 2D array. You get the Y position by multiplying what row you're on by the height of a tile, then you add the scrollY. When you increase the scrollY, it gives the effect of scrolling down, or moving the tiles up. If you need more help, I can clarify on Instant Messenger (ImmigrantMarbles). I hope this helps. I really didn't look at your code so I don't know if this is a solution or not.

--Vic--

Edited by - Roof Top Pew Wee on November 9, 2001 4:57:50 PM

Share this post


Link to post
Share on other sites