Author Topic: Extremely Newb Question.. please forgive me  (Read 55 times)

Offline ConanMan

  • byte
  • *
  • Posts: 3
    • View Profile
Extremely Newb Question.. please forgive me
« on: October 14, 2019, 11:48:26 am »
I am exploring whether jpct.net is a viable option for my project.

(I appreciate this is probably kind of often asked but I ask you to perhaps bear with me and indulge me. I'm simply a the stage where I need actual advice from real developers!)

I want to produce a 3D engine game with a hex grid. On mobile. Native Android and iOS.

I am already a developer in iOS and Android.

The game grid will be basically similar to Civilisation. It will have a fog of war. It can drag scroll. It will have a hex grid, a underlay of a tile (green grass water etc) and a 3D unit icon model oerlay (sometimes). For human interface I need to had "push square (hex)" popover menu, that will uiblock anything until the user chooses an option or cancels, probably semi transparent (or a glow effect). I also want to have some fairly simple travel animations and an overlay to show pathing. I also want to overlay lighting effects in 3D on top of the unit.


It does not need to be rotating hex grid. The units do not need to rotate. But they will be slightly animated (gun flashes)

would JPCT do it do you think?


Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12001
    • View Profile
    • http://www.jpct.net
Re: Extremely Newb Question.. please forgive me
« Reply #1 on: October 14, 2019, 12:57:17 pm »
Hex grid means an isometric view?

Offline Jakes

  • byte
  • *
  • Posts: 26
    • View Profile
Re: Extremely Newb Question.. please forgive me
« Reply #2 on: October 16, 2019, 12:58:00 am »
Basically, to all your questions: Yes

Hexagon grid, some tips to help you go on the right way:

private void drawHexGridLoop(Point origin, int size, int radius, int padding) {
    double ang30 = Math.toRadians(30);
    double xOff = Math.cos(ang30) * (radius + padding);
    double yOff = Math.sin(ang30) * (radius + padding);
    int half = size / 2;

    for (int row = 0; row < size; row++) {
        int cols = size - java.lang.Math.abs(row - half);

        for (int col = 0; col < cols; col++) {
            int xLbl = row < half ? col - row : col - half;
            int yLbl = row - half;
            int x = (int) (origin.x + xOff * (col * 2 + 1 - cols));
            int y = (int) (origin.y + yOff * (row - half) * 3);

            drawHex(xLbl, yLbl, x, y, radius);
        }
    }
}

basicall you need to have a regular grid (2D array) but the columns should be slightly offset a bit, like in the example above.

here is the source: https://stackoverflow.com/questions/20734438/algorithm-to-generate-a-hexagonal-grid-with-coordinate-system

about you questions if jPCT will do the trick, well it depends on your skills and goals, if you want to see  out some works that use grid based structure and layout, you can check some of my work below: