Don't point me to tutorials, I need scrolling help!

Started by
2 comments, last by Ferinorius 22 years, 5 months ago
It just doesn''t work. I have racked my brain endlessly, and even E-mailed lpsoftware for his input (it was HIS tutorial i based this on) my code doesnt seem to be working. I am using a modified version of the BOB engine, (one that loads 16/24/32 bpp bitmaps) and I thought that the modifications would make life easier, and it still doesn''t Here is my problem: It draws the first set of tiles perfectly. Then, i hit the right or left key to increase the world camera''s coords. Then, something weird happens. Tiles begin to dissapear. As my character walks off screen, its like the viewport follows him. Any explanation? Here is the code I use:

void Draw_Map(void) {

	RECT tile_src;

	for(y = 0; y < 7; ++y ) {    
		for( x = 0; x < 16 ; ++x ) {  
			
		
			scroll_x = x + (world_camerax / 64);
			scroll_y = y + (world_cameray / 64);

			offset_x = world_camerax & (64 - 1);
			offset_y = world_cameray & (64 - 1);

			tile = map[scroll_x][scroll_y];


			if(tile == 0 ) {
			}	//end if
			else if(tile == 1 ) {
				Set_Pos_BOB(&ground1,(64 * scroll_x - offset_x),(64 * scroll_y - offset_y));
				Draw_BOB(&ground1,lpddsback);
			
			} //end if

		} //end for
	}//end for


}//end function
 
and that is that. If anyone is capable of helping, or at least taking a look at hte program itself, it would be greatly appreciated. Thank you so much for anyone who can help ~ferin Neo-Toshi - The City That Never Sleeps
Advertisement
I would point you to my older article on doing this, but...

Alter it a bit as such to save processing time recalculating coordinates and map tile references:

void Draw_Map(void) {  // Get map coordinates (top-left from camera)  map_x = world_camerax / 64;  map_y = world_cameray / 64;  // Get drawing offsets  offset_x = world_camerax % 64;  offset_y = world_cameray % 64;  // Draw loop  for(y = 0; y < 7; y++ ) {    for( x = 0; x < 16 ; x++ ) {      if((tile = map[x + map_x][y + map_y])) {        Set_Pos_BOB(&ground1, (x * 64 - offset_x),(y * 64 - offset_y));				         Draw_BOB(&ground1,lpddsback);      }    }  }} 


PS - You can do a search on this site to find my old article explaining smooth scrolling a little more.

Jim Adams
lol, hehe thanks, i try implementing this in my code to see if it works. It is almost like im forgetting something, it''s right on the tip of my tongue i guess, but I cant seem to figure this one out, thanks for the help!

Neo-Toshi - The City That Never Sleeps
IT WORKED!!!!!!!!!!

hehehahahaha

and I know what my problem was now too!

i wasn''t following the world_map coords, just changing them!

thanks so very very much!

Neo-Toshi - The City That Never Sleeps

This topic is closed to new replies.

Advertisement