Isometric Help?

Greetings.

I am trying to convert my game from flat 2D to Isometric 2.5D. I have mocked up a prototype demo that displays all the tiles correctly, but when I go to move the Y jumps from up to left and from down to right…

I am sure I am doing something stupid…

Before I get into the technical details, if someone would be willing to jump onto Skype, I am signed on as jcannonb, and would be happy to send the prototype project in full over.

My method for converting the coordinates is:
public static Point getIsoXY(int tilex, int tiley, int isoTileWidth, int isoTileHeight)
{
int x = tilexisoTileWidth;
int y = tiley
isoTileHeight/2;
if (tiley %2 == 1)
{
x = x- isoTileWidth/2;
}
//y -= isoTileHeight/2;
return new Point(x, y);
}

When I am moving up down left and right, I do this:
if (k == KeyEvent.VK_UP)
{
gamePanel.images.showY–;
}
if (k == KeyEvent.VK_DOWN)
{
gamePanel.images.showY++;
}

   if (k == KeyEvent.VK_LEFT)
   {
       gamePanel.images.showX--;
   }
   if (k == KeyEvent.VK_RIGHT)
   {
       gamePanel.images.showX++;
   }

ShowX and ShowY manipulate the top most portion of the map to be displayed in this case…

To display the map, I do this:
public void draw(Graphics g)
{
BufferedImage current;
wvp.clearBuffer();
for (int y = 0; y < 30; y++)
{
for (int x = 0; x < 10; x++)
{
current = Map[x+showX][y+showY]==0?grass:water;
wvp.WriteTile(current, x, y, 0, 0);
}
}

    //Place player in the center
    wvp.WriteTile(dirt, (10/2)-1, 30/2-1, 0, 0);
    
    g.drawImage(vp.getSurface(), 20, 20, null);
  }

Finally, Writing the tile looks like this:

public void WriteTile(Image i, int tilex, int tiley, int stepX, int stepY)
{

    Point xy = IsoUtil.getIsoXY(tilex, tiley, terrain_width, terrain_height);
    
    //System.out.printf("Writing at %d:%d\n",xy.x-stepX,xy.y-stepY);
    vp.WriteImage(i, xy.x-stepX,xy.y-stepY);

}

Thanks in advance…

Figured it out… Nevermind…

Care to share what the solution was, just in case some future generation has the same problem and googles this thread?

I completely changed the rendering algo…

Right now the x and y offsets are hard coded, but will make them dynamic in the end.

This renders the map from the center of the view area in diamond shape down, right and left…

This is Proof Of Concept:
public void WriteTile(Image i, int tilex, int tiley, int stepX, int stepY)
{
Point xy = IsoUtil.getScreenIsoPos(tilex, tiley, terrain_width, terrain_height);

    xy.x+=250; //based on a width of 600
    xy.y-=150; //based on a height of 480   
    
    xy.x -= (i.getWidth(null)-terrain_width)/2;
    xy.y -= (i.getHeight(null)-terrain_height)/2;
    
    vp.WriteImage(i, xy.x-stepX,xy.y-stepY);
    //vp.WriteDebug(i, (xy.x-stepX)+terrain_width-10,xy.y-stepY,tilex,tiley);
    
}

//Translate a screen tile coordinate to a screen position
public static Point getScreenIsoPos(int tilex, int tiley, int isoTileWidth, int isoTileHeight)
{
int x = (isoTileWidth/2)(tilex-tiley);
int y = (isoTileHeight/2)
(tilex+tiley);

  return new Point(x, y);

}

Could we get a screenshot of the 2.5D or even a comparison to the old one? Would be great :smiley:

Sure thing… :slight_smile:

Thanks! Looks fancy

It is simple and may not look like much, but its great for a turn based old school RPG. Anyone who writes me graham.norville@me.com I will send the sample project to.

Simple you say?

May I show you my current project

http://img29.imageshack.us/img29/8326/secretsi.png

Nice system…

The presentation layer is all I am changing. It is going into
www.fabuladivina.com

I love my flat 2D game, but I think more people will love it if it is isometric…

The game engine is pretty much written, I just wanted to change the presentation system.

Well you could mix it like me and make it front-view 2.5D. Creates somewhat of a depth but is still pretty 2D-ish

edit: I totally saw that you edited “haha” to “Nice system” ;D

I pondered front view isometric, I pondered orthogonal which still uses square tiles (which I love), but the graphic artists convinced me to do diamonds :frowning:

I love your system though. I bet it ends up being awesome.