Button finalization!

This commit is contained in:
oitsjustjose 2017-11-14 17:31:59 -05:00
commit 064fe1f4ca
5 changed files with 23 additions and 13 deletions

View file

@ -4,8 +4,8 @@ import com.oitsjustjose.crawlnbrawl.Entity.Living.EntityMonster;
import com.oitsjustjose.crawlnbrawl.Manager.AudioManager;
import com.oitsjustjose.crawlnbrawl.Manager.SceneManager;
import com.oitsjustjose.crawlnbrawl.Manager.ScreenshotManager;
import com.oitsjustjose.crawlnbrawl.Scene.Dungeon;
import com.oitsjustjose.crawlnbrawl.Scene.Button;
import com.oitsjustjose.crawlnbrawl.Scene.Dungeon;
import com.oitsjustjose.crawlnbrawl.Scene.Menu;
import com.oitsjustjose.crawlnbrawl.Scene.Scene;
import com.oitsjustjose.crawlnbrawl.Util.Config;
@ -52,8 +52,9 @@ public class Game
public void initGame()
{
Menu menu = new Menu();
menu.addButton(new Button((Display.getWidth() / 2) - 128, (Display.getHeight() / 2), 256, 64, "Play", new Color(200, 200, 200), new Color(85, 124, 0)), new Dungeon());
menu.addButton(new Button((Display.getWidth() / 2) - 128, (Display.getHeight() / 2), 256, 64, "Exit", new Color(200, 200, 200), new Color(85, 124, 0)), null);
menu.addButton(new Button(256, 64, "Play", new Color(200, 200, 200), new Color(85, 124, 0)), new Dungeon());
menu.addButton(new Button(256, 64, "Exit", new Color(200, 200, 200), new Color(85, 124, 0)), null);
menu.adjustButtons();
Scene currScene = menu;
while (currScene.go())

View file

@ -25,9 +25,14 @@ public class Button
private TrueTypeFont font;
private boolean hovering;
public Button(int x, int y, int w, int h, String text)
public Button(int w, int h, String text)
{
this(x, y, w, h, text, new Color(0, 0, 0), new Color(0.9F, 0.9F, 0.9F));
this(0, 0, w, h, text, new Color(0, 0, 0), new Color(0.9F, 0.9F, 0.9F));
}
public Button(int w, int h, String text, Color textColor, Color color)
{
this(0, 0, w, h, text, textColor, color);
}
public Button(int x, int y, int w, int h, String text, Color textColor, Color color)

View file

@ -168,17 +168,16 @@ public class Dungeon extends SceneLevel
}
Menu menu = new Menu();
if (player == null || player.getState() == EntityPlayer.State.DEAD)
{
menu.addButton(new Button((Display.getWidth() / 2) - 64, (Display.getHeight() / 2) - 64, 128, 32, "Play Again", new org.newdawn.slick.Color(200, 200, 200), new org.newdawn.slick.Color(85, 124, 0)), new Dungeon());
menu.addButton(new Button(256, 64, "Play Again", new org.newdawn.slick.Color(200, 200, 200), new org.newdawn.slick.Color(85, 124, 0)), new Dungeon());
}
else
{
menu.addButton(new Button((Display.getWidth() / 2) - 64, (Display.getHeight() / 2) - 64, 128, 32, "Resume", new org.newdawn.slick.Color(200, 200, 200), new org.newdawn.slick.Color(85, 124, 0)), this);
menu.addButton(new Button(256, 64, "Resume", new org.newdawn.slick.Color(200, 200, 200), new org.newdawn.slick.Color(85, 124, 0)), this);
}
menu.addButton(new Button((Display.getWidth() / 2) - 64, (Display.getHeight() / 2) - 16, 128, 32, "Exit", new org.newdawn.slick.Color(200, 200, 200), new org.newdawn.slick.Color(85, 124, 0)), null);
menu.addButton(new Button(256, 64, "Exit", new org.newdawn.slick.Color(200, 200, 200), new org.newdawn.slick.Color(85, 124, 0)), null);
menu.adjustButtons();
return menu;
}

View file

@ -1,6 +1,7 @@
package com.oitsjustjose.crawlnbrawl.Scene;
import com.oitsjustjose.crawlnbrawl.Game;
import com.oitsjustjose.crawlnbrawl.Tile.TileBackground;
import com.oitsjustjose.crawlnbrawl.Util.FileUtils;
import org.lwjgl.LWJGLException;
import org.lwjgl.input.Keyboard;
@ -22,6 +23,7 @@ public class Menu extends Scene
private LinkedHashMap<Button, Scene> buttons;
private Scene nextScene;
private TrueTypeFont titleFont;
private TileBackground bg;
public Menu()
{
@ -38,6 +40,7 @@ public class Menu extends Scene
Font awtFont = Font.createFont(Font.TRUETYPE_FONT, font).deriveFont(titleAttributes).deriveFont(64F);
titleFont = new TrueTypeFont(awtFont, false);
bg = new TileBackground("menu");
}
catch (IOException | FontFormatException e)
{
@ -72,6 +75,7 @@ public class Menu extends Scene
GL11.glOrtho(0, Display.getWidth(), Display.getHeight(), 0, 1, -1);
}
GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0);
bg.draw();
titleFont.drawString((Display.getWidth() / 2) - (titleFont.getWidth("Crawl 'n Brawl") / 2), 64F, "Crawl 'n Brawl", new org.newdawn.slick.Color(0, 123, 124));
updateButtons();
drawButtons();

View file

@ -122,13 +122,14 @@ public class Surface extends SceneLevel
Menu menu = new Menu();
if (player == null || player.getState() == EntityPlayer.State.DEAD)
{
menu.addButton(new Button((Display.getWidth() / 2) - 64, (Display.getHeight() / 2) - 64, 128, 32, "Play Again", new Color(200, 200, 200), new Color(85, 124, 0)), new Dungeon());
menu.addButton(new Button(256, 64, "Play Again", new Color(200, 200, 200), new Color(85, 124, 0)), new Dungeon());
}
else
{
menu.addButton(new Button((Display.getWidth() / 2) - 64, (Display.getHeight() / 2) - 64, 128, 32, "Resume", new Color(200, 200, 200), new Color(85, 124, 0)), this);
menu.addButton(new Button(256, 64, "Resume", new Color(200, 200, 200), new Color(85, 124, 0)), this);
}
menu.addButton(new Button((Display.getWidth() / 2) - 64, (Display.getHeight() / 2) - 16, 128, 32, "Exit", new Color(200, 200, 200), new Color(85, 124, 0)), null);
menu.addButton(new Button(256, 64, "Exit", new Color(200, 200, 200), new Color(85, 124, 0)), null);
menu.adjustButtons();
return menu;
}