Sign in to follow this  
essbee

Questions about Isometric world

Recommended Posts

essbee    103
Hey there,

I have a question regarding my random generated 2d Isometric world. First of all, I'm looking to do a sort of diablo-style movement system where your character doesn't move but the world does.
I searched on the forum but I haven't found anything directly on this. So I want to know how you are supposed to handle this. If you move each tile individually at each frame, it will be too laggy. Instead, I was looking for something that let the world be considered as one entity, is it possible? Or how else it would be done?

Can someone give me a hint of how it would work? I just can't imagine it.

Thank you!

Share this post


Link to post
Share on other sites
SuperVGA    1132
No, it won't be too laggy. All games "move" the world; it's not like you need to shove your monitor around to see more. :-) so your character being static while the world is moving is a trick. Relatively, he still moves. Depending on your applied technology, you blit or isometrically render either 2d tiles or 3d geometry to your back buffer. You could optimize by having batches of these tiles shown at once, but for a 2d game like diablo you won't need to do it for the game to run smooth. A laggy experience can be caused by many things, depending on how you do everything. -What do you have in mind?

Share this post


Link to post
Share on other sites
essbee    103
Ok I know about the games that moves the world but I heard it would be laggy to move, let's say, a 200 per 200 tiles world, each frame. I don't have anything in mind except maybe for the rendering which can be made by rendering only certain chunks depending on where you are. But for the movement, even if you don't render all the tiles, will still be laggy because it will be 40k tiles each frame. I thought about having one big entity to move instead of 40k.

I hope you know what I mean :) .

Thanks by the way.

Share this post


Link to post
Share on other sites
Anthony Serrano    3285
[quote name='essbee' timestamp='1306543524' post='4816634']
Ok I know about the games that moves the world but I heard it would be laggy to move, let's say, a 200 per 200 tiles world, each frame. I don't have anything in mind except maybe for the rendering which can be made by rendering only certain chunks depending on where you are. But for the movement, even if you don't render all the tiles, will still be laggy because it will be 40k tiles each frame. I thought about having one big entity to move instead of 40k.

I hope you know what I mean :) .

Thanks by the way.
[/quote]

Classic premature optimization.

It may sound slow and inefficient to move 40,000 tiles each frame (or, at 60 fps, 2,400,000 tiles per second), but on modern hardware, it likely isn't. The only way to know for sure is to try it out.

That said, you're also thinking about the problem the wrong way. Don't think about it as moving the world around the character. Think of it like this:

You have a stationary world. You have a character in the world who is moving. And finally, you have a camera looking at that character, that is fixed relative to the character. So when the character moves, the camera moves with him. If you know where the camera is, you can find out what part of the world is actually onscreen (i.e. in the camera's view) - and from there, you can simply take those tiles and figure out where on the screen to draw them.

Share this post


Link to post
Share on other sites
essbee    103
Okay thank you Anthony. I'll try what you said and I'll also think about the situation you gave me, like rendering the tiles from where the camera is.

So this gives me 2 options:

1: The original idea of moving each tiles.
2: Rendering the according tiles depending from where the camera (and character) is.

I'll take a look into that, if you have something to add, don't hesitate.

Cheers!

Share this post


Link to post
Share on other sites
JTippetts    12950
In a way, that is what the view matrix for the camera in a 3D game is. I know, you are talking about traditional isometric, but the concept still applies. A view matrix is simply the inverse transform of the camera position. Every single object that is drawn is transformed by the view matrix first. So basically, the view matrix "moves" every single object to a position relative to the camera. However, at no point are any of the tiles or objects actually moved. That is, at no point is there a loop or any kind of structure wherein the game visits every tile and moves it. The "moving" happens during the render process, and takes place on the graphics hardware merely as a pre-transform step before rendering. As far as the actual game is concerned, the world remains static and it is the camera itself that moves around. And yes, performing the view matrix transform on the GPU is lightning fast.

Share this post


Link to post
Share on other sites
Alex131    151
Optimizations are always useful, but it depends on how much content you are going to render on the screen so that there aren't any notable fps drops.

Some time ago I was trying to make such a game in delphi (didn't get too far cause of some bad design decisions and having to rewrite everything about 3-4 times), read some information and decided to go with this concept:
1)Have a startX and startY representing the beginning of the map.
2)Render everything that should be on the screen based on some calculations with the startX and startY positions.
3)If the character wants to move, change startX and startY.

At first it seemed like a good concept but in the library I was using, entities had to be separate from the map, thus causing sometimes to not move along with it. You can see what I am talking about [url="https://rapidshare.com/files/1241911420/Distribution.zip"]here[/url] if you want to.

Depending on the library and language you are using however you can make it work pretty easily.

I started rewriting the rendering algorithm in SFML (C++) and I there no problems were present (sorry for the library specific information, I hope that you will get the general sense of how I made it work). What I did there was use several *views* like this:
1)Have the same algorithm for deciding what to draw on the screen, but instead of using startX and startY to move the tiles, I used them to move the view where the map and entities were rendered - this way everything moved along.
2)In the same view draw the character and move him according to startX and startY, so that he stays in the center of the screen (better to move the view and the character than only the entire map + entities + whatnot).
3)Have a second static view for gui elements and whatever.

However due to recent movement to windows 7 and some file deletion I couldn't find the 2nd project, so you will have to decide how to make it work.

P.S. If you want some further info you can always PM me.

Share this post


Link to post
Share on other sites
essbee    103
Thanks a lot for the input JTippetts.

And for Alex131, okay that's good, you guys gave me great advices and I'll be sure to check the file you sent me. I'll pm you if I have any question.

And for your information, I'm currently using C# and OpenGL.

Thank you guys.

Edit: I think I have something interesting.

[code]
protected override void OnClientSizeChanged(EventArgs e)
{
base.OnClientSizeChanged(e);
Gl.glViewport(0, 0, this.ClientSize.Width, this.ClientSize.
Height);
Setup2DGraphics(ClientSize.Width, ClientSize.Height);
}

private void Setup2DGraphics(double width, double height)
{
double halfWidth = width / 2;
double halfHeight = height / 2;
Gl.glMatrixMode(Gl.GL_PROJECTION);
Gl.glLoadIdentity();
Gl.glOrtho(-halfWidth, halfWidth, -halfHeight, halfHeight,
-100, 100);
Gl.glMatrixMode(Gl.GL_MODELVIEW);
Gl.glLoadIdentity();
}
[/code]

Could these lines:
Gl.glViewport(0, 0, this.ClientSize.Width, this.ClientSize.
Height);
Setup2DGraphics(ClientSize.Width, ClientSize.Height);

be what I'm looking to play with to change the viewpoint and what coordinates you are supposed to have on your screen? I'll try it.

Edit 2: Okay I think this is exactly what I'm supposed to play with, it changes my viewpoint so I can always put it on my character and render the world depending on where I am.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this