# Isometric in SDL?

you mean to render a screen in isometric perspective using SDL, such as for a 2D game? It’s simple, just map the coordinates out yourself.
of course SDL doesn’t provide facilities for that, it’s a simple layer over the operating system code; not a generic game programming library.

It’s really easy though. If you think of each pixel as a square on the floor, when you move across the screen horizontally or vertically you’re changing both X and Y values by the same amount; and if you move perfectly diagonally across the screen (IE, the same change in screen’s X and screen’s Y) then you’re only changing one while the other is constant.

It sounds a lot more confusing than it really is.

Or maybe you’re talking about something else completely and I’m just making an ass out of myself here.

I am talking about moving my player Isometricly

like this

\ /
\ /
\ /

basically I am not sure how the math would work. Any examples? I don’t want complete source dont get me wrong I am just new to Isometric math an it’s something you can’t find on the web much lol

What I do is represent everything in a standard 2D map,
but then simply display it using isometric tiles:

/
/

Because isometric makes it easy to do a 3rd dimension,
I create a basic little map that was WxHx2.
(The ground, and objects sitting on the ground.)

I then displayed them in such a way that things
overlapped correctly. A simple “painter’s method.”

for (z = 0; z < 2; z++) { /* Ground, then objects /
for (y = 0; y < 10; y++) { /
Scrolling around a 10x10 view of the map /
for (x = 0; x < 10; x++) {
c = map[z][y + mapy][x + mapx]; /
mapx,mapy is where we’ve scrolled */

``````    drawshape(CTRX + x * 32 - y * 32, TOPY + y * 16 + x * 16, c);

/* CTRX,TOPY is top middle of where window into the map is to be drawn;
tiles are 64x64 */
}
}
``````

}

Here are three example tiles (at approx 1/10th scale ;^) ):

1. A cube:

…XX…
XXXXXX
==XX–On Fri, Nov 13, 2009 at 07:52:47PM -0800, Tivoilos wrote:

I am talking about moving my player Isometricly

===—
===—
…=-…

1. Ground

…##…

…##…

2. Tree

…88…
.8888.
…88…
…||…
…||…

In this case, if I were to draw the ground first, then the wall, the
ground would be completely covered by my wall. But with the tree,
I get:

…88…
.8888.
…88…
…||…
##||##
…##…

And, of course, when multiple objects are drawn adjacent to each other,
they tile nicely:

``````          ......
......
............
............
..88....XX........
.8888.XXXXXX......
..88..++XX--......
..||..+++---......
##||##+++---......
..######+-###.....
############
..########..
######
..##..
``````

Or there 'bouts.

I wrote a little program that let me pan around an iso map.
It was about 415 lines of code.

-bill!

There’s a whole subforum devoted to isometric game making over at gamedev.net.
As well as tutorials. You might want to check that out.

Tivoilos wrote:

I am talking about moving my player Isometricly

basically I am not sure how the math would work. Any examples? I don’t want complete source dont get me wrong I am just new to Isometric math an it’s something you can’t find on the web much lol

Like I said, to move diagonally you only change one isometric (x, y) coordinate value.
You’d probably want X to be moving like this \ and y to be moving like this /, or at least that’s how I usually do it (because, like I said, I like to think of it as rotating the scene 45 degrees)
So, to move your player like \ you’d only increment the x coordinate value. To move him like / you’d increment the y coordinate value.
To map those to screen coordinates, it’d be like: scr_x = iso_x - iso_y; scr_y = iso_x + iso_y;
The concept behind that is that scr_x should increase going across the screen from left to right, and scr_y should increase going across the screen from top to bottom.
Since iso_x increases going across the screen from top-left to bottom-right (), it increments both scr_x and scr_y with each increment.
Since iso_x increases going across the screen from top-right to bottom-left (/), it decrements scr_x and increments scr_y with each increment.

Of course, I’ve never written a complete isometric game, only toyed around with the perspective, so there are surely people more knowledgeable than myself worth discussing this with.

-sorry double post-

would it be more along the lines like this

Code:

int iso_x;
int iso_y;

int x = iso_x - iso_y;
int y = iso_x + iso_y;

void iso_key_input()
{
if(event.type == SDL_KEYDOWN)
{
switch(event.key.keysym.sym)
{
case SDLK_UP:
iso_x + =spriteheight /2; break;
iso_y + =spriteheight/2; break;

`````` case SDLK_DOWN:
iso_x -= spriteheight/2;break;
iso_y -= spriteheight/2;break;
``````

}
}
}

something more along the lines of that?

Not so much.

Your first code was more correct, you just need to switch up and right. Also, are you new to programming? Why would you initialize x and y in the global scope?
try: #define SCR_X (iso_x - iso_y) and #define SCR_Y (iso_x + iso_y)

Hello LIBSDL!!!

perfect opurtunity for me to throw crazeeman0.4 in the mix!

its in the zip at http://www.crashedcomputers.co.uk/indexgames.php

it has 8 way isometric stuff going on, still a few rendering issues, but
nothing major. the code
is broken i think but one of the executables works, it also has a level
designer in there,
someone please step up and help me make my dream of an 8 way isometricish
pacman
clone a reality. the code is a mess, but its there for someone to finish…
i’m trying to get to
grips with basic SDL1.3