Advertisement

Scrolling tiles question

Started by May 27, 2002 01:32 PM
12 comments, last by Zorbfish 22 years, 7 months ago
Go for that Jim Adams tut, its 1996 and fl**ping fantastic. (I used it with allegro-DOS)

If you wish a more in depth thingamy - post.

,Jay
I finally found the problem... every tutorial I had read blitted tiles from top to bottom, then left to right. I always find the most difficult way of doing things and I was doing the blitting in the opposite way; from left to right then top to bottom. That''s why it wasn''t working Now it works perfectly... Thanks to all who posted... I''ll be back in a few days with more Qs most likely

Zorb
Advertisement

    UpdateFrame(){	start_x=camerax/32;	end_x=start_x+20;	start_y=cameray/32;	end_y=start_y+15;        x=camerax%32; //offset        y=camera%32;        if (x!=0) x=-32; else end_x--; //if offset not zero blit extra tile        if (y!=0) y=-32; else end_y--; // and start from offscreen (clipped)        SetRect(&dest,x,y,32+x,32+y); //first tile portion	for(int i=start_y;i<end_y;i++){		    for(int j=start_x;j<end_x;j++){			int tile=map[i][j];			                   lpBackBuffer->Blt(&dest,lpSecondary,&Tiles[tile],DDBLT_WAIT,NULL);			                  dest.left+=32;dest.right+=32;		        }		dest.top+=32;		dest.bottom+=32;		        dest.left=x;        dest.right=32+x;	        }	return TRUE;    


This is the alteration to add offset calc (x,y), My previous posts demostrated using a large surface and just blitting a portion of it (a very quick method in some cases with out clipping), but a bit different to this method.

I lost some code off my previous posts (??).

,Jay

Edit: Missed a bit.

[edited by - Jason Zelos on May 29, 2002 4:09:00 PM]
And after I''d written all that code

Incidently you are blitting top to bottom, left to right.
The screen is always 0,0 at the top left corner.

,Jay

This topic is closed to new replies.

Advertisement