stoopid tiles, why wont they scroll?

Started by
3 comments, last by Ferinorius 22 years, 5 months ago
ok, i am racking my brain. it isnt working for me. i have used the tiles tutorials here, and it just isnt working. here is the funciton i use....

for(y=0; y < SCREEN_SIZEY; ++y ) 
	{
		for( x = 0; x < SCREEN_SIZEX; ++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_y][scroll_x];

			tile_src.left	=	(tile - 1) * 64;
			tile_src.top	=	0;
			tile_src.right	=	tile * 64;
			tile_src.bottom	=	64;

			if(map[scroll_x][scroll_y] == 0 ) {
			}	//end if
			if(map[scroll_x][scroll_y] == 1 ) {
				Set_Tile(&ground1,(scroll_x * 64),(scroll_y * 64));
				Draw_Tile(&ground1,lpddsback);
			} //end if
		} //end for
} //end for  
and it is perfect for displaying what is on the current screen, but when i try to get it to scroll, the tiles themselves move but the next row of tiles doesnt appear. apparently the tiles dont move, and it doesnt load in the next section of the map. when the player hits the left or right buttons, the worldcamera_x moves backward or forwards respectively. Where is my error, and why the hell does the next part of the map not show up? Edited by - Ferinorius on October 30, 2001 10:15:59 AM
Advertisement
You're only looping until the end of the screen, but because of the world camera offset, the screen isn't where you think it is: when world_camerax is 10, the screen *starts* 10 pixels to the left of the start of the physical screen, so the end of the screen is now 10 pixels to the left of the end of the physical screen.

You need to loop this way:

        for(y = world_cameray; y < world_cameray + SCREEN_SIZEY; ++y ) {    for( x = world_camerax; x < world_camerax + SCREEN_SIZEX; ++x ) {      



'Nuff said. I'll enjoy watching you live, demon.

Edit: Error in code.

PS. Even though your engine isn't isometric, the Isometric Land forum is the right place for tile-engine questions.

Edited by - Mayrel on October 30, 2001 10:48:38 AM
CoV
AHA!!!!!

well wait a second. now when i do this, it works up to a point. the tiles scroll by very quickly when my character reaches the end of the screen and end up to this:

BEFORE moving to right of screen:


after moving to the right:




its like it doesnt draw what is after the first section, when there is 48 more rows of map left to draw

argh

Edited by - Ferinorius on October 30, 2001 11:15:35 AM
The original code looks good for me, I would use an else on the secound if (or get rid of the first one), but thats all, the bug is not there, I would say it is rather in the Draw_Tile(&ground1,lpddsback); function, you might have a constraint there not to draw tiles after the first screen, and you set the offset but never use it, I see a source rect but I dont see a destination one (has to be inside Draw_Tile I am sure) look it there, or post Draw_Tile instead.
ok, what i did since my last post was discarded that rect crap. i just copied it from the sample code, and i dont need it. I utilize the offset now for the "smooth" scrolling, but i think the problem does lie in that section. I am not capable of drawing tiles past the first screen. its like the clipper moves, but the viewport seems the same.... im gonna break apart everything looking for this bug or whatever it is.



Neo-Toshi - The City That Never Sleeps

This topic is closed to new replies.

Advertisement