Package net.sertik.genesia.util

Examples of net.sertik.genesia.util.Coords


    // when the mouse is moved, update the hovering tile accordingly
    inputCapture.setOnMouseMoved(new EventHandler<MouseEvent>() {
      @Override
      public void handle(MouseEvent me) {
        Coords mapCoords = calcMapCoordFromMouseCoord(me.getX(), me.getY());
        if (renderer.getWorld().setHoverCoords(mapCoords)) {
          render();
        }
      }
    });

    // when the mouse is clicked, update the selected tile if there was a tile
    inputCapture.setOnMouseClicked(new EventHandler<MouseEvent>() {
      @Override
      public void handle(MouseEvent me) {
        if (me.isStillSincePress()) {
          Coords mapCoords = calcMapCoordFromMouseCoord(me.getX(), me.getY());
          if (renderer.getWorld().isPointWithinBounds(mapCoords)) {
            Tile selectedTile = renderer.getWorld().getTile(mapCoords.getX(), mapCoords.getY());
            if (selectedTileInfo.getTileNode() == null
                    || !selectedTile.equals(selectedTileInfo.getTileNode().getTile())) {
              selectedTileInfo.setTileNode(renderer.getResourceLoader().createResource(selectedTile));
            }
          }
View Full Code Here


        break;
      case MOUSEMAP_CENTER:
        break;
    }

    return new Coords(mapX, mapY);
  }
View Full Code Here

  public void render(Group container, double width, double height) {
    renderTiles(container, width, height);

    // render hover tile
    Coords hoverWorldCoords = world.getHoverWorldCoords();
    if (hoverWorldCoords.getX() != -1 && hoverWorldCoords.getY() != -1) {
      if (hoverTile == null) {
        hoverTile = resourceLoader.createResource(Scenery.HOVER_TILE);
        hoverTile.setUserData(new Integer(1));
        container.getChildren().add(hoverTile);
      }
      hoverTile.setLayoutX(World.TILE_WIDTH / 2 * (hoverWorldCoords.getX() - hoverWorldCoords.getY()));
      hoverTile.setLayoutY(World.TILE_HEIGHT / 2 * (hoverWorldCoords.getX() + hoverWorldCoords.getY()));
    }
  }
View Full Code Here

  @Test
  public void testWithinBounds() {
    World world = new World(4, 16);

    assertTrue(world.isPointWithinBounds(new Coords(0, 0)));
    assertTrue(world.isPointWithinBounds(new Coords(5, 5)));
    assertTrue(world.isPointWithinBounds(new Coords(7, 7)));
    assertFalse(world.isPointWithinBounds(new Coords(8, 1)));
    assertFalse(world.isPointWithinBounds(new Coords(1, 8)));
    assertFalse(world.isPointWithinBounds(new Coords(9, 9)));
    assertFalse(world.isPointWithinBounds(new Coords(-4, 4)));
    assertFalse(world.isPointWithinBounds(new Coords(4, -4)));
    assertFalse(world.isPointWithinBounds(new Coords(-4, -4)));
    assertFalse(world.isPointWithinBounds(new Coords(-4, 10)));
    assertFalse(world.isPointWithinBounds(new Coords(10, -4)));
  }
View Full Code Here

    World world = new World(4, 16);

    assertEquals(world.getHoverWorldCoords().getX(), -1);
    assertEquals(world.getHoverWorldCoords().getY(), -1);

    assertTrue(world.setHoverCoords(new Coords(0, 0)));
    assertEquals(world.getHoverWorldCoords().getX(), 0);
    assertEquals(world.getHoverWorldCoords().getY(), 0);

    assertTrue(world.setHoverCoords(new Coords(4, 2)));
    assertEquals(world.getHoverWorldCoords().getX(), 4);
    assertEquals(world.getHoverWorldCoords().getY(), 2);

    assertFalse(world.setHoverCoords(new Coords(4, 2)));
    assertEquals(world.getHoverWorldCoords().getX(), 4);
    assertEquals(world.getHoverWorldCoords().getY(), 2);

    assertFalse(world.setHoverCoords(new Coords(8, 2)));
    assertEquals(world.getHoverWorldCoords().getX(), 4);
    assertEquals(world.getHoverWorldCoords().getY(), 2);

    assertFalse(world.setHoverCoords(new Coords(2, 8)));
    assertEquals(world.getHoverWorldCoords().getX(), 4);
    assertEquals(world.getHoverWorldCoords().getY(), 2);

    assertFalse(world.setHoverCoords(new Coords(-2, 4)));
    assertEquals(world.getHoverWorldCoords().getX(), 4);
    assertEquals(world.getHoverWorldCoords().getY(), 2);

    assertFalse(world.setHoverCoords(new Coords(2, -4)));
    assertEquals(world.getHoverWorldCoords().getX(), 4);
    assertEquals(world.getHoverWorldCoords().getY(), 2);

    assertTrue(world.setHoverCoords(new Coords(2, 6)));
    assertEquals(world.getHoverWorldCoords().getX(), 2);
    assertEquals(world.getHoverWorldCoords().getY(), 6);
  }
View Full Code Here

TOP

Related Classes of net.sertik.genesia.util.Coords

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.