Game Panels and bounds
Hey all,
I created four different backgrounds for a project I am creating. (The background are a top down view of a road with sidewalks). I have them named as road1, road2, road3, and road4.
I have two questions. My first and most important is if I have a little box I want to move around the screen (a character), how do I set bounds so it can't go past a certain point (i.e. the road is the only place it is allowed to go)?
And secondly, I know how to remove panels but if I wanted this to be a long road and once the character reaches the right side of the screen it would remove road1 and replace it with road 2. How would I accomplish this? And once that is figured out, road 3 would replace road 2, but road 3 goes vertical so the character would go right through road 1 and right through road 2, but vertical through road 3 to get to road 4.
I have a bunch of code if anyone would like to see to help make sense of this, just let me know exactly what you would like to see.
Thanks in advance for all the help and I hope I didn't confuse anyone too much.
P.S. If this has already been discussed, I apologize. I looked, but couldn't find anything.
[1198 byte] By [
csc165a] at [2007-10-2 17:35:32]

[quote]how do I set bounds so it can't go past a certain point (i.e. the road is the only place it is allowed to go)?[/quote]
If the character is only allowed on the road have a monocrome (black and white) map image/map of the road areas. When the character moves up, check that the top of the character (after the move) does not go beyond the top part of that section of the road. When you move down, check that the bottom won't go past the lower road boundary where your character is, and so on for the other directions.
Secondly, when you are displaying the road, if it is as long as you say, ( ;) ) then only display the portion that is plus or minus 200 pixels let's say in any direction around your character. When you sense that you are around a border you have to display part of the new road (on whichever sides) and part of the old road. For instance if your field of vision is 200 pixels, when you move to 199 pixels from an edge you need to display one pixel from the new road. To keep track of what road you are on or going to you could use a 2D array that contains an int in every cell to tell you what map you are on or need to display.
Good luck in your assignment (assuming csc stands for Comupter SCience) like it does at my university with the 165 being the course number.