Skip to main content
gamedev.net
🔒 Locked

Bounds checking tile engine

Started by darkchrono4 May 25, 2006 at 1:45 AM 3 replies 900+ views
Original Post
darkchrono4
darkchrono4
Playing around with a smooth scrolling tile engine and having a bit of a round with the bounds checking. I got something that works but it doesn't seem like it would be right. I checked it with a couple different sized maps and it stopped correctly just thinking there has to be a better way.

	if (keys[VK_DOWN]) {
		keys[VK_DOWN]=FALSE;
				
		if (map_yoffset < (map_height - (display_y-2)) * TILE_HEIGHT 
			               - (TILE_HEIGHT/2) + MOVE_SIZE)	
			map_yoffset += MOVE_SIZE;
	}

	if (keys[VK_RIGHT]) {
		keys[VK_RIGHT]=FALSE;
		
                  if (map_xoffset < (map_width - (display_x-2)) * TILE_WIDTH - (TILE_WIDTH/2))
			map_xoffset += MOVE_SIZE;
	}


I've got the minus two because I need the one extra for the partial tiles then the other is because OpenGL likes pop in a line of tiles so I just render the extra off screen and let it scroll in.
darkchrono4
darkchrono4
Thanks for the usual amount of help I get from this place. Guess I have no reason to waste my time coming here anymore.
scourgez
scourgez
it usually takes a little while before someone replies, if you give up that easily i hate to see what you can accomplish when things get really tough.

as far as the code, it looks ok, and if it works why mess with a godo thing?
My tech blogEasy Tech Talk
jbadams
jbadams
The way you're doing it is fine. Nice to see you apparently don't appreciate the free help you get here. Ingrate.
- Jason Astle-Adams
scourgez
scourgez
Quote:
Original post by Kazgoroth
Nice to see you apparently don't appreciate the free help you get here. Ingrate.



bahaha, i almost spit out my iced tea. dont know why but that ingrate comment just hit the right spot
My tech blogEasy Tech Talk

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.