Megaman Level Scrolling

Started by
5 comments, last by speedie 17 years, 3 months ago
Hello all. Hopefully this will get some discussion going on this quiet part of the forum :) I am interested in figuring out how the level scrolling works in the Megaman games. I understand that the levels are split into chunks in which the camer freely scrolls left and right. When you get to the edge of a chunk, however, the scrolling stops and Megaman has to run to the edge of the screen to scroll over. When you get to the edge of the screen, the camera pans over to the new chunk and Megaman is positioned in the correct place on screen. This happens every time you travel upwards or down to a new chunk via a ladder or falling. It also happens sometimes when moving horizontally. My question is, how would something like this be implemented?
Advertisement
Simply enforce limits for the "camera". These limits change when the player changes "chunks". Example, suppose the camera can fit 5 tiles/units on the screen horizontally. Then the camera's minimum x is 0, max is 32-5=27. These values change when you change "chunk".

|       Chunk 1    32 units wide     | Chunk 2 27 units wide    |min X = 0, max X = 27                   min X = 33, max X = 54


At least, that's my idea.
Thanks for the input. I'm not so much concerned with stopping the camera at the end of a chunk, but the actual scrolling/positioning a character in the correct place.
you might wanna check out these tutorials

http://jnrdev.72dpiarmy.com/
Just a little update:

To clarify what I was trying to ask in the beginning: I'm not really concerned with centering the level around my character or setting the camera position as he moves about the world. What I haven't yet figure out is when my character reaches the "end" of the current "chunk" of a level, there is a small transition period where the screen automatically scrolls to the next part of the level.

This can be seen in the first Zelda game as well, when you walk to the endge of the screen, the screen scrolls until you are in the next level "chunk".

Megaman did this as well, but the chunks were longer so there were parts where the screen freely scrolls left and right up to a certain point, where the next chunk was loaded.

At that time, the screen scrolls to the next chunk, Megaman is not controlled by you during this time, and he is placed in the correct position on screen.

Has anyone done this before? I'm sure I could figure out a way to do it, but I'm trying to come up with something elegant and not a hack-job.
I haven't done it before, but I would imagine it simply involves using a global pixel offset value for each tile of the next chunk that you increment through till the whole screen fills with the next chunk (ie offset x by -10 pixels each frame). After which, you unload the previous chunk and set the new chunk as your current chunk and reset your character coordinates. As for the character...well you'd figure out how many iterations you need to go through to scroll the entire next chunk onto the screen and use the tile dimension (that you are moving in if it's not a square but rather a isodiamond) divided by the number of offsets required, moving this character perfectly onto the adjacent tile/point on the next chunk. For example, say your screen is 320 pixels wide and your tiles are 32 pixels square, you can figure scrolling an entire chunk from one side to the other takes 32 iterations of 10 pixels. So you need to reduce your offset by 32/32 each iteration for just your character (ie 1 pixel).

I hope this helps. Like I said, I haven't done it but this is just what I would do in your position.
maybe your over complicating things here.

using I would make what you see on the screen completely dependent on where the camera is, not where the character is. The character would never change positions during the scroll. he would always be in the same x, y he was in before the scroll.

You just have to have someway of splitting your world up, but keep it in one stored map. so say you split the world in 10x10 chunks

evertime the player reachs the split and crosses over, you move the cammera over to adjust for the crossing over.

you could reconize this crossing by something like:
old_X_chunk = pos_x / 10;new_X_chunk = pos_x / 10;if (old_X_chunk != new_X_chunk){    // scroll horizontally }old_X_chunk = new_X_chunk;


your scrolling would just cause the camera to scroll in the right direction untill it has reach a desired direction then stop.
-----------------------------------------------The ZoloProject

This topic is closed to new replies.

Advertisement