Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (475)
Games in Android Showcase (106)
games submitted by our members
Games in WIP (530)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Isometric Help?  (Read 1493 times)
0 Members and 1 Guest are viewing this topic.
Offline LordChandar

Junior Member


Projects: 1



« Posted 2012-11-03 01:22:05 »

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 = tilex*isoTileWidth;
    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...
Offline LordChandar

Junior Member


Projects: 1



« Reply #1 - Posted 2012-11-03 02:02:34 »

Figured it out... Nevermind...
Offline sproingie

JGO Kernel


Medals: 201



« Reply #2 - Posted 2012-11-03 03:47:02 »

Care to share what the solution was, just in case some future generation has the same problem and googles this thread?
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline LordChandar

Junior Member


Projects: 1



« Reply #3 - Posted 2012-11-03 03:49:14 »

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);
  }
Offline Gjallar

JGO Coder


Medals: 13
Projects: 1


Follower of Nurgle


« Reply #4 - Posted 2012-11-03 03:51:43 »

Could we get a screenshot of the 2.5D or even a comparison to the old one? Would be great  Cheesy
Offline LordChandar

Junior Member


Projects: 1



« Reply #5 - Posted 2012-11-03 03:58:50 »

Sure thing... :-)
Offline LordChandar

Junior Member


Projects: 1



« Reply #6 - Posted 2012-11-03 03:59:39 »

Offline Gjallar

JGO Coder


Medals: 13
Projects: 1


Follower of Nurgle


« Reply #7 - Posted 2012-11-03 04:12:06 »

Thanks! Looks fancy
Offline LordChandar

Junior Member


Projects: 1



« Reply #8 - Posted 2012-11-03 04:23:10 »

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.
Offline Gjallar

JGO Coder


Medals: 13
Projects: 1


Follower of Nurgle


« Reply #9 - Posted 2012-11-03 04:40:01 »

Simple you say?

May I show you my current project

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline LordChandar

Junior Member


Projects: 1



« Reply #10 - Posted 2012-11-03 04:41:41 »

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.
Offline Gjallar

JGO Coder


Medals: 13
Projects: 1


Follower of Nurgle


« Reply #11 - Posted 2012-11-03 04:45:04 »

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"  Grin
Offline LordChandar

Junior Member


Projects: 1



« Reply #12 - Posted 2012-11-03 04:46:27 »

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 :-(

I love your system though.  I bet it ends up being awesome.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

ctomni231 (35 views)
2014-07-18 06:55:21

Zero Volt (31 views)
2014-07-17 23:47:54

danieldean (26 views)
2014-07-17 23:41:23

MustardPeter (28 views)
2014-07-16 23:30:00

Cero (43 views)
2014-07-16 00:42:17

Riven (45 views)
2014-07-14 18:02:53

OpenGLShaders (34 views)
2014-07-14 16:23:47

Riven (35 views)
2014-07-14 11:51:35

quew8 (31 views)
2014-07-13 13:57:52

SHC (67 views)
2014-07-12 17:50:04
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!