Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


Orthogonal projection of 2D map.


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
13 replies to this topic

#1 farmdve   Members   -  Reputation: 194

Like
0Likes
Like

Posted 16 December 2012 - 09:59 AM

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 Posted Image.

Edited by farmdve, 16 December 2012 - 10:27 AM.


Sponsor:

#2 JTippetts   Moderators   -  Reputation: 8659

Like
0Likes
Like

Posted 16 December 2012 - 10:10 AM

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.

#3 Gavin Williams   Members   -  Reputation: 779

Like
0Likes
Like

Posted 16 December 2012 - 10:28 AM

I think you mean isometric ?

#4 farmdve   Members   -  Reputation: 194

Like
0Likes
Like

Posted 16 December 2012 - 10:37 AM

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.

#5 JTippetts   Moderators   -  Reputation: 8659

Like
4Likes
Like

Posted 16 December 2012 - 06:06 PM

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, 16 December 2012 - 06:07 PM.


#6 farmdve   Members   -  Reputation: 194

Like
0Likes
Like

Posted 16 December 2012 - 06:24 PM

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, 16 December 2012 - 06:25 PM.


#7 JTippetts   Moderators   -  Reputation: 8659

Like
0Likes
Like

Posted 16 December 2012 - 08:31 PM

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.

#8 farmdve   Members   -  Reputation: 194

Like
0Likes
Like

Posted 17 December 2012 - 08:13 AM

Would you mind pointing me to such a tutorial?

#9 Olof Hedman   Crossbones+   -  Reputation: 2954

Like
0Likes
Like

Posted 17 December 2012 - 08:29 AM

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, 17 December 2012 - 08:30 AM.


#10 farmdve   Members   -  Reputation: 194

Like
0Likes
Like

Posted 18 December 2012 - 04:31 PM

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, 18 December 2012 - 04:32 PM.


#11 nobodynews   Crossbones+   -  Reputation: 2113

Like
0Likes
Like

Posted 18 December 2012 - 05:07 PM

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.

C++: A Dialog | C++0x Features: Part1 (lambdas, auto, static_assert) , Part 2 (rvalue references) , Part 3 (decltype) | Write Games | Fix Your Timestep!


#12 nobodynews   Crossbones+   -  Reputation: 2113

Like
0Likes
Like

Posted 18 December 2012 - 05:18 PM

As for tiles that are similar to what you're looking for, are any of the ones here good? http://hasgraphics.com/category/tilesets/

C++: A Dialog | C++0x Features: Part1 (lambdas, auto, static_assert) , Part 2 (rvalue references) , Part 3 (decltype) | Write Games | Fix Your Timestep!


#13 farmdve   Members   -  Reputation: 194

Like
0Likes
Like

Posted 19 December 2012 - 02:13 PM

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, 19 December 2012 - 02:14 PM.


#14 dAND3h   Members   -  Reputation: 214

Like
0Likes
Like

Posted 21 December 2012 - 04:02 PM

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, 21 December 2012 - 04:03 PM.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS