• Advertisement
Sign in to follow this  

Orthogonal projection of 2D map.

This topic is 1859 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi folks.
I am using SDL for my (first)2D game attempt, I am not using OpenGL, just SDL_FillRect and SDL_BlitSurface. For my 2D game I asked a lot of people and different people recommended different things, one side recommended to stick with SDL's BlitSurface, others recommended me to do it on OpenGL even if it was 2D. I think I will stick with just SDL for now, unless it is necessary. OpenGL is too hard for me at this point, especially when it requires more code to do the same thing I do with SDL with less functions.

Anyway, what I am trying to do is make my view/projection/map/whatever orthogonal, i.e I want the map to look like this game http://fortune3.to/game/ where it looks as if the map and character are viewed under an angle. Another game like that is https://s3.amazonaws...ld22/index.html. My map is tile-based right now, I use these sheets http://i.imgur.com/4cURq.png.
The red,green and..not sure what the other color is, square are what I walk on, the other things are the walls.

For my character I use these http://i.imgur.com/sUAE4.png Nothing fancy, at all. I just found them randomly and google, and decided to use them.
When you mash that, it looks like this http://i.imgur.com/LlPCt.png. The tiles it feels as if I am looking from above, but the character as if I am looking from the side. What I want it to look like is the games I showed you, not the same textures obviously, but I hope you got the point. But I have no idea whether a code change is needed, or the sprites need to be changed, or both.

Now, let me say this, the programming language I am using is C, because I have over a year experience with it, whereas C++ or say C# I have none, plus I don't like them, so using some game library/game engine which is written in C++ is not on my agenda(It's possible to mix C and C++, but you get why I don't want to use it). Actually, I want to write my own engine, just for myself of course, so I can use it for other projects. If possible, spare me the talk how C++ is better smile.png. Edited by farmdve

Share this post


Link to post
Share on other sites
Advertisement
It might be useful if you could post a screenshot or two of the games you are trying to imitate. The first link wants me to install Java which I won't do, and the second link is broken.

Share this post


Link to post
Share on other sites
You are the second person to interpret it differently. Some say it's Axonometric, others tell me it's Orthogonal. Anyway, you can see the difference here http://gamedev.stackexchange.com/questions/22277/difference-between-orthogonal-map-and-isometric-map

So definitely orthogonal.

Share this post


Link to post
Share on other sites
You seem to have your terminology a little bit confused.

Orthographic projections are any class of projection where the projection lines (the lines along which points are projected onto the 2D view plane) are all orthogonal (ie, perpendicular) to the view plane. That is, there is no shrinking or perspective as the object gets further away.

Video games commonly use a subset of orthographic projections that are loosely called isometric projections, but are more accurately called axonometric projections.

The most common axonometric projection used in games is one where the camera is oriented at an angle 30 degrees above the horizon, 45 degrees around the vertical axis. This results in a dimetric projection. This projection is nice because it results in the classic 2:1 tile ratio (ie, tiles on the ground are twice as wide as they are tall) making it fit neatly in the powers-of-2 requirement for textures on older hardware. The first 2 Diablo games used this projection (though D2 provided an optional skewing to fake perspective) Many F2P MMOs and many RTS games also use this projection. In this projection, the X and Y axes (lying parallel to the ground plane) are equally fore-shortened, while the vertical (Z) axis is foreshortened a different amount.


An angle of ~35 degrees above the horizon results in a true isometric projection in which all 3 axes are equally foreshortened. This is used somewhat less frequently, as the tile sizes are weird.

Some older RPGs used a trimetric projection, where all 3 axes were unequally foreshortened, usually by using some value other than 45 degrees for the rotation around the vertical axis. These, also, are somewhat less common, again for the weird tile sizes.

Again, it might be helpful to give us a screenshot of what you want, for those of us who don't let Java onto our machines. Edited by JTippetts

Share this post


Link to post
Share on other sites
Well, these http://i.imgur.com/ZZ5fx.jpg http://i.imgur.com/EfZY3.jpg http://i.imgur.com/9zTuH.png

The textures are not the same, but to me it looks like the map or something is being viewed under an angle. Hopefully those clear it up.
But I have no idea if the textures or the code or both need to be changed. It would also be nice if I can be pointed to to a code example, if it's not too much to ask :) Edited by farmdve

Share this post


Link to post
Share on other sites
Ah, that. Yeah, that's not really any consistent projection. That type of map typically just implements a basic layered square tile map and draws it back-to-front using an orthographic projection matrix. No rotation around the Z-axis, no special coding required at all. Any basic layered tile map tutorial should tell you what you need to know. Those types of games typically fake the camera angle simply by the way the sprite graphics are drawn, rather than through positioning of an in-game camera or any kind of tricky coding.

Share this post


Link to post
Share on other sites

Would you mind pointing me to such a tutorial?


It would have to be an art-style tutorial for how to draw pixel sprite graphics.
From the gamecodes perspective, its just square 2D sprites in a tilemap, without any projection at all. Edited by Olof Hedman

Share this post


Link to post
Share on other sites
Considering there are a lot of open source 2D games, and artists sharing their work, I've yet(whole week) to find tiles/sprites that are drawn the way I explained above. I am not an artist, I am not blessed with much accuracy and trust me, I can barely draw a 2D head, let alone whole tiles and sprites the way I want them to.

The character sprites I've found so far seem to have an animation for moving right, but not left. Edited by farmdve

Share this post


Link to post
Share on other sites
The sprites you have probably assumed the game would 'flip' the sprites horizontally at runtime. Left is can be seen as the same as right, just mirror image opposites. Another option is to flip the sprites in an image editor. Even MS Paint has a flip option.

Share this post


Link to post
Share on other sites
I tried flipping the image with GIMP and pasting the flipped images on to the sprite sheet. But something is wrong. When the object moves right, the movement is jerky. When it moves left, it's smooth. Edited by farmdve

Share this post


Link to post
Share on other sites
Are you sure it is an exact mirror of the original? If you don't align the images in the spritesheet an exact distance (usually) then the actual texture will be slightly bigger than the sum of all the animation frames, meaning the frame width/height will be calculated incorrectly Edited by dAND3h

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement