Search in sources :

Example 1 with SoftwareImage

use of org.asassecreations.engine.tools.SoftwareImage in project Voxel_Game by ASasseCreations.

the class MenuGuiSystem method init.

public static final void init(final MenuState state) {
    menuContainer = new GuiPanel(0f, 0f, .8f, .8f, new Color(0f, 0f, 0f, .75f));
    startButton = new GuiButton(0f, .5f, .5f, .1f, data -> state.manager().push(new GameState(100)), menuContainer);
    settingsButton = new GuiButton(0f, 0f, .5f, .1f, data -> {
    }, menuContainer);
    quitButton = new GuiButton(0f, -.5f, .5f, .1f, data -> state.manager().pop(), menuContainer);
    text = new SoftwareImage((int) startButton.getScreenWidth(), (int) startButton.getScreenHeight());
    text.clear();
    text.graphics().setFont(new Font("Arial", Font.PLAIN, 32));
    text.centerString("Start", Color.WHITE, null);
    startImage = new GuiImage(0f, 0f, 1f, 1f, text.toTexture(null), startButton);
    text.clear();
    text.graphics().setFont(new Font("Arial", Font.PLAIN, 32));
    text.centerString("Settings", Color.WHITE, null);
    settingsImage = new GuiImage(0f, 0f, 1f, 1f, text.toTexture(null), settingsButton);
    text.clear();
    text.graphics().setFont(new Font("Arial", Font.PLAIN, 32));
    text.centerString("Quit", Color.WHITE, null);
    quitImage = new GuiImage(0f, 0f, 1f, 1f, text.toTexture(null), quitButton);
    menuContainer.add();
}
Also used : GuiImage(org.asassecreations.engine.gui.GuiImage) Color(org.asassecreations.engine.render.Color) GuiButton(org.asassecreations.engine.gui.GuiButton) MenuState(org.asassecreations.voxelgame.state.MenuState) Font(java.awt.Font) SoftwareImage(org.asassecreations.engine.tools.SoftwareImage) GuiPanel(org.asassecreations.engine.gui.GuiPanel) GameState(org.asassecreations.voxelgame.state.GameState) GuiImage(org.asassecreations.engine.gui.GuiImage) GuiButton(org.asassecreations.engine.gui.GuiButton) SoftwareImage(org.asassecreations.engine.tools.SoftwareImage) GuiPanel(org.asassecreations.engine.gui.GuiPanel) Color(org.asassecreations.engine.render.Color) GameState(org.asassecreations.voxelgame.state.GameState) Font(java.awt.Font)

Example 2 with SoftwareImage

use of org.asassecreations.engine.tools.SoftwareImage in project Voxel_Game by ASasseCreations.

the class Debugger method init.

public static final void init() {
    image = new SoftwareImage(640, 360);
    image.graphics().setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
    image.graphics().setFont(new Font("Arial", Font.PLAIN, 22));
    render();
}
Also used : SoftwareImage(org.asassecreations.engine.tools.SoftwareImage) Font(java.awt.Font)

Example 3 with SoftwareImage

use of org.asassecreations.engine.tools.SoftwareImage in project Voxel_Game by ASasseCreations.

the class MenuState method init.

public final void init() {
    MouseSystem.enable();
    // Setup background image
    backgroundTexture = TextureLoader.getTexture("/textures/background.png", null);
    backgroundImage = new GuiImage(0f, 0f, 1f, 1f, backgroundTexture);
    backgroundImage.background = true;
    backgroundImage.add();
    // Setup container
    container = new GuiPanel(0f, 0f, .75f, .75f, new Color(0f, 0f, 0f, .75f));
    container.add();
    // Setup start button
    startButton = new GuiButton(0f, .5f, 0f, .1f, data -> {
        if (MouseInput.isButtonJustPressed(0)) {
            manager.pop();
            manager.push(new GameState(100f));
        }
    }, container);
    startButton.setLocalWidth(startButton.getLocalWidth() * 2f);
    startButton.add();
    // Setup software image
    final SoftwareImage image = new SoftwareImage(startButton.getScreenWidth(), startButton.getScreenHeight());
    image.graphics().setFont(new Font("Arial", Font.PLAIN, 32));
    image.clear();
    image.centerString("Start", new Color(1f, 1f, 1f), null);
    startText = image.toTexture(null);
    startImage = new GuiImage(0, 0, 1, 1, startText, startButton);
    startImage.add();
    // Setup options button
    optionsButton = new GuiButton(0f, 0f, 0f, .1f, data -> {
    }, container);
    optionsButton.setLocalWidth(optionsButton.getLocalWidth() * 2f);
    optionsButton.add();
    image.clear();
    image.centerString("Options", new Color(1f, 1f, 1f), null);
    optionsText = image.toTexture(null);
    optionsImage = new GuiImage(0, 0, 1, 1, optionsText, optionsButton);
    optionsImage.add();
    // Setup quit button
    quitButton = new GuiButton(0f, -.5f, 0f, .1f, data -> {
        if (MouseInput.isButtonJustPressed(0))
            VoxelGame.loop.stop();
    }, container);
    quitButton.setLocalWidth(quitButton.getLocalWidth() * 2f);
    quitButton.add();
    image.clear();
    image.centerString("Quit", new Color(1f, 1f, 1f), null);
    quitText = image.toTexture(null);
    quitImage = new GuiImage(0, 0, 1, 1, quitText, quitButton);
    quitImage.add();
    image.destroy();
}
Also used : Color(org.asassecreations.engine.render.Color) Font(java.awt.Font) Texture(org.asassecreations.engine.texture.Texture) MouseSystem(org.asassecreations.voxelgame.input.MouseSystem) VoxelGame(org.asassecreations.voxelgame.VoxelGame) StateManager(org.asassecreations.engine.state.StateManager) SoftwareImage(org.asassecreations.engine.tools.SoftwareImage) GuiImage(org.asassecreations.engine.gui.GuiImage) TextureLoader(org.asassecreations.engine.texture.TextureLoader) GuiButton(org.asassecreations.engine.gui.GuiButton) State(org.asassecreations.engine.state.State) MouseInput(org.asassecreations.engine.input.MouseInput) GuiSystem(org.asassecreations.voxelgame.gui.GuiSystem) GuiPanel(org.asassecreations.engine.gui.GuiPanel) GuiImage(org.asassecreations.engine.gui.GuiImage) GuiButton(org.asassecreations.engine.gui.GuiButton) SoftwareImage(org.asassecreations.engine.tools.SoftwareImage) GuiPanel(org.asassecreations.engine.gui.GuiPanel) Color(org.asassecreations.engine.render.Color) Font(java.awt.Font)

Aggregations

Font (java.awt.Font)3 SoftwareImage (org.asassecreations.engine.tools.SoftwareImage)3 GuiButton (org.asassecreations.engine.gui.GuiButton)2 GuiImage (org.asassecreations.engine.gui.GuiImage)2 GuiPanel (org.asassecreations.engine.gui.GuiPanel)2 Color (org.asassecreations.engine.render.Color)2 MouseInput (org.asassecreations.engine.input.MouseInput)1 State (org.asassecreations.engine.state.State)1 StateManager (org.asassecreations.engine.state.StateManager)1 Texture (org.asassecreations.engine.texture.Texture)1 TextureLoader (org.asassecreations.engine.texture.TextureLoader)1 VoxelGame (org.asassecreations.voxelgame.VoxelGame)1 GuiSystem (org.asassecreations.voxelgame.gui.GuiSystem)1 MouseSystem (org.asassecreations.voxelgame.input.MouseSystem)1 GameState (org.asassecreations.voxelgame.state.GameState)1 MenuState (org.asassecreations.voxelgame.state.MenuState)1