Scrolling Map

I am making a mock-up of an RPG Crawler and I need a way to make the map follow the character around on the screen so the character doesn't run off of the map.

Any ideas on an algorithm?
You probably want to store the whole map in memory, and then only display the parts in view.
Your question doesn't explain what type of UI you are going to use.

PS: Did you mean Pokemon style, or Zelda style camera? (I assume 2D graphics.)
Explain what you mean when you say store it in the "memory". As of now I have a text file with numbers in it. Each number represents a different type of terrain and it is read into the program and stored in a multidimensional vector.

The UI is going to be kind of like the average RPG UI. With the skillbar in the bottom of the screen and with the minimap in the bottom. The Health/mana bar is in the top left. Is this what you were asking?

Your assumption is correct. I am using SFML. Aren't Zelda and Pokemon cameras pretty much identical?
I envision something similiar to this in my head, but I don't expect it to come out quite as detailed and smooth.
http://bit.ly/hUgkg8
Last edited on
In Pokemon you are always at the center of the screen.
In Zelda you move around, but when you reach the end of the screen it scrolls to the next.

Tresky
I am using SFML
This is what I meant by UI actually, but maybe the question was a bit ambiguous.

I think SFML can store the whole screen in a variable and then has a view method for things like this.
Last edited on
In Pokemon you are always at the center of the screen.
In Zelda you move around, but when you reach the end of the screen it scrolls to the next.

I forsee problems in doing it the Zelda way. Accounting for different sizes of screens and what-not. I just doesn't sound too programmer friendly. What do you think?


I am using SFML
This is what I meant by UI actually, but maybe the question was a bit ambiguous.

I think SFML can store the whole screen in a variable and then has a view method for things like this.

Do you mean like the API can potentially save a screenshot of the map?
Algorithm.......

It's pretty simple mate, are you looking for something like this?
http://www.youtube.com/watch?v=hf1H8vDvp98

You can also look through the old archives of my last unfinished game. I believe one is room based:
http://sourceforge.net/projects/ultiscroll/files/

Do you mean like the API can potentially save a screenshot of the map?

The map can be stored in memory as either a tilemap or a single image. You load said image and move around a "camera" in order to see more.

I forsee problems in doing it the Zelda way. Accounting for different sizes of screens and what-not. I just doesn't sound too programmer friendly. What do you think?

Both methods are trivial.

Tresky
Accounting for different sizes of screens and what-not.

This should not be a problem. You want to define the widow size in your program, as long as it's small enough to fit on a low resolution screen (1024 x 768).
ultifinitus: Nah. I'm trying to make an RPG Crawler http://www.youtube.com/watch?v=pJe4FrTcRlA

I appreciate it. I will definitely take a look.

Would you end up moving the camera around the map or vice-versa?


Mathhead200: Is there a way to scale to a screensize without distorting the images? Like say scale to one axis but leave the other unscaled?
@tresky: cool cool.

I would leave the map be.

Why scale? Why not just have blank space surrounding rooms? More consistent theme.
@ultifinitus: So you would just put the whole map on the screen at once?
You don't have to fill the whole screen. Just make a window.
Hmmm... Haha that is probably what I should do XD

Let's recap:
Looks to me like I'm going to do the Pokemon style of the map. Have it move around with the character in the center of the map, but I will have the maps large enough to do that yet small enough to be able to transfer room to room.

Thanks you two. :) Really appreciate it.
Topic archived. No new replies allowed.