Search in sources :

Example 1 with Square

use of org.asassecreations.engine.math.Square in project Voxel_Game by ASasseCreations.

the class Inventory method init.

public final void init() throws MalformedURLException, IOException {
    final String[] data = Tools.getFileAsString("/textures/inventory.def").split(Tools.getNewLine());
    bounds = new Square[data.length];
    for (int i = 0; i < bounds.length; i++) {
        final String[] tokens = data[i].split(Tools.getWhiteSpace());
        final int x = Integer.parseInt(tokens[0]);
        final int y = Integer.parseInt(tokens[1]);
        bounds[i] = new Square(x, y, 32, 32);
    }
}
Also used : Square(org.asassecreations.engine.math.Square)

Example 2 with Square

use of org.asassecreations.engine.math.Square in project Voxel_Game by ASasseCreations.

the class Notifier method render.

public static final void render() {
    IMAGE.clear();
    final Color color = Color.WHITE;
    final float messageHeight = 30;
    for (int i = 0; i < NOTIFICATIONS.size(); i++) {
        final Notification n = NOTIFICATIONS.get(i);
        final float x;
        if (n.state == 0)
            x = Mathf.map(n.timer.percent(), 0, 1, 0, WIDTH_PIXELS);
        else if (n.state == 1)
            x = 0;
        else
            x = Mathf.map(n.timer.percent(), 0, 1, WIDTH_PIXELS, 0);
        IMAGE.graphics().setColor(new Color(0f, 0f, 0f, .7f).awtColor());
        IMAGE.graphics().fillRect((int) x, (int) (i * messageHeight), WIDTH_PIXELS, (int) messageHeight);
        IMAGE.centerString(n.message, color, new Square(x, i * messageHeight, WIDTH_PIXELS, messageHeight));
    }
    if (TEXTURE != null)
        TEXTURE.delete();
    TEXTURE = IMAGE.toTexture(null);
}
Also used : Color(org.asassecreations.engine.render.Color) Square(org.asassecreations.engine.math.Square)

Example 3 with Square

use of org.asassecreations.engine.math.Square in project Voxel_Game by ASasseCreations.

the class Debugger method render.

public static final void render() {
    image.clear();
    image.graphics().setColor(new Color(0f, 0f, 0f, .75f).awtColor());
    image.graphics().fillRect(0, 0, image.image().getWidth(), image.image().getHeight());
    image.centerString("Player position: " + playerPosition.x + ", " + playerPosition.y + ", " + playerPosition.z, Color.WHITE, new Square(0, 0, image.image().getWidth(), 100));
    image.centerString("Chunks loaded: " + chunksLoaded, Color.WHITE, new Square(0, 100, image.image().getWidth(), 100));
    if (texture != null)
        texture.delete();
    texture = image.toTexture(null);
}
Also used : Color(org.asassecreations.engine.render.Color) Square(org.asassecreations.engine.math.Square)

Example 4 with Square

use of org.asassecreations.engine.math.Square in project Voxel_Game by ASasseCreations.

the class Inventory method render.

public final void render() {
    renderer.clear();
    if (!open) {
        if (texture != null)
            texture.delete();
        texture = renderer.toTexture(null);
        return;
    }
    renderer.graphics().drawImage(background, 0, 0, null);
    for (int i = 0; i < inventory.length; i++) {
        final ItemStack stack = inventory[i];
        if (stack == null)
            continue;
        final Square s = bounds[i];
        final BufferedImage image = stack.item.image;
        renderer.graphics().drawImage(image, (int) s.x, (int) s.y, (int) s.w, (int) s.h, null);
        renderer.centerString(stack.amount + "", Color.WHITE, new Square(s.x + 16, s.y + 16, s.w / 2, s.h / 2));
    }
    for (int i = 0; i < craft.length; i++) {
        final ItemStack stack = craft[i];
        if (stack == null)
            continue;
        final Square s = bounds[i + 36];
        final BufferedImage image = stack.item.image;
        renderer.graphics().drawImage(image, (int) s.x, (int) s.y, (int) s.w, (int) s.h, null);
        renderer.centerString(stack.amount + "", Color.WHITE, new Square(s.x + 16, s.y + 16, s.w / 2, s.h / 2));
    }
    if (temp != null) {
        renderer.graphics().drawImage(temp.item.image, (int) mx, (int) my, 32, 32, null);
        renderer.centerString(temp.amount + "", Color.WHITE, new Square(mx + 16, my + 16, 16, 16));
    }
    if (result != null) {
        final Square s = bounds[40];
        renderer.graphics().drawImage(result.item.image, (int) s.x, (int) s.y, (int) s.w, (int) s.h, null);
        renderer.centerString(result.amount + "", Color.WHITE, new Square(s.x + 16, s.y + 16, s.w / 2, s.h / 2));
    }
    if (texture != null)
        texture.delete();
    texture = renderer.toTexture(null);
}
Also used : Square(org.asassecreations.engine.math.Square) BufferedImage(java.awt.image.BufferedImage)

Aggregations

Square (org.asassecreations.engine.math.Square)4 Color (org.asassecreations.engine.render.Color)2 BufferedImage (java.awt.image.BufferedImage)1