public int getHeight(int x, int y) { if (x >= 0 && x < map.getWidth() && y >= 0 && y < map.getHeight()) { return map.getHeightAt(x, y); } else { return 0; } }
/** * Checks two map coordiantes if they are on the map. * * @param x * The y coordinate in map space. * @param y * The x coordinate in map space. * @return If the map coordinates are on the map. */ public boolean checkMapCoordinates(int x, int y) { return x >= 0 && x < this.map.getWidth() && y >= 0 && y < this.map.getHeight(); }
final short mapHeight = map.getHeight();
/** * Creates a new map context for a given map. * * @param map * The map. */ public MapDrawContext(IGraphicsGrid map) { this.map = map; float incline = DrawConstants.DISTANCE_X / 2.0f / DrawConstants.DISTANCE_Y; int mapHeight = map.getHeight() * DrawConstants.DISTANCE_Y; int mapWidth = map.getWidth() * DrawConstants.DISTANCE_X; this.screen = new ScreenPosition(mapWidth, mapHeight, incline); this.converter = MapCoordinateConverter.get(DrawConstants.DISTANCE_X, DrawConstants.DISTANCE_Y, map.getWidth(), map.getHeight() ); }
/** * @param screenX * The x coordinate in draw space * @param screenY * The y coordinate in draw space. * @return The map position under the point. */ private ShortPoint2D getPositionUnder(float screenX, float screenY) { // do a three step iteration by using the coordinate transformation and the map height int mapX = getConverter().getMapX(screenX, screenY); int mapY = getConverter().getMapY(screenX, screenY); if (mapX < 0 || map.getWidth() <= mapX || mapY < 0 || map.getHeight() <= mapY) { return new ShortPoint2D(mapX, mapY); } float height = map.getHeightAt(mapX, mapY); mapX = (int) (getConverter().getExactMapXwithHeight(screenX, screenY, height) + 0.5); mapY = (int) (getConverter().getExactMapYwithHeight(screenX, screenY, height) + 0.5); height = map.getHeightAt(mapX, mapY); mapX = (int) (getConverter().getExactMapXwithHeight(screenX, screenY, height) + 0.5); mapY = (int) (getConverter().getExactMapYwithHeight(screenX, screenY, height) + 0.5); return new ShortPoint2D(mapX, mapY); }
private void addColorPointToGeometry(MapDrawContext context, ByteBuffer buffer, int x, int y, int fogOffset) { float fColor; if (x <= 0 || x >= context.getMap().getWidth() - 2 || y <= 0 || y >= context.getMap().getHeight() - 2 || context.getVisibleStatus(x, y) <= 0) { fColor = 0; } else { int height1 = context.getHeight(x, y - 1); int height2 = context.getHeight(x, y); fColor = 0.85f + (height1 - height2) * .15f; if (fColor > 1.0f) { fColor = 1.0f; } else if (fColor < 0.4f) { fColor = 0.4f; } fColor *= (float) fogOfWarStatus[fogOffset] / CommonConstants.FOG_OF_WAR_VISIBLE; } if(useFloatColors) { buffer.putFloat(fColor); } else { byte color; fColor *= 255f; color = (byte) (int) fColor; buffer.put(color); buffer.put(color); buffer.put(color); buffer.put((byte) 255); } }
public Minimap(MapDrawContext context, MinimapMode modeSettings) { this.context = context; IGraphicsGrid map = context.getMap(); stride = MiniMapLayoutProperties.getStride(map.getWidth()) / map.getWidth(); converter = new MapCoordinateConverter(map.getWidth(), map.getHeight(), 1, 1); miniMapShapeCalculator = new MiniMapShapeCalculator(stride, converter); lineLoader = new LineLoader(this, modeSettings); Thread miniMapThread = new Thread(lineLoader, "minimap loader"); miniMapThread.setDaemon(true); miniMapThread.start(); }
if(shapeHandle == null) { bufferWidth = context.getMap().getWidth()-1; bufferHeight = context.getMap().getHeight()-1;
height = map.getHeight(); this.gameTimeProvider = game.getGameTimeProvider(); this.textDrawPosition = textDrawPosition;