/** * @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer) */ public void init(GameContainer container) throws SlickException { this.container = container; rect = new Rectangle(400,100,200,150); round = new RoundedRectangle(150,100,200,150,50); round2 = new RoundedRectangle(150,300,200,150,50); center = new Rectangle(350,250,100,100); poly = new Polygon(); poly.addPoint(400,350); poly.addPoint(550,320); poly.addPoint(600,380); poly.addPoint(620,450); poly.addPoint(500,450); gradient = new GradientFill(0,-75,Color.red,0,75,Color.yellow,true); gradient2 = new GradientFill(0,-75,Color.blue,0,75,Color.white,true); gradient4 = new GradientFill(-50,-40,Color.green,50,40,Color.cyan,true); }
/** * @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer) */ public void init(GameContainer container) throws SlickException { shapes = new ArrayList(); rect = new Rectangle(10, 10, 100, 80); shapes.add(rect); roundRect = new RoundedRectangle(150, 10, 60, 80, 20); shapes.add(roundRect); ellipse = new Ellipse(350, 40, 50, 30); shapes.add(ellipse); circle = new Circle(470, 60, 50); shapes.add(circle); polygon = new Polygon(new float[]{550, 10, 600, 40, 620, 100, 570, 130}); shapes.add(polygon); keys = new boolean[256]; lastChar = new char[256]; createPoly(200,200); }
public void render(GameContainer gameContainer) { this.bgImage.draw(); Graphics graphics = gameContainer.getGraphics(); graphics.setColor(Color.gray); RoundedRectangle rect = new RoundedRectangle(50, 50, game.getWidth() - 100, game.getHeight() - 100, 20); graphics.draw(rect); graphics.fill(rect); graphics.setColor(Color.blue); graphics.drawString(this.text, (game.getWidth() / 2) - (this.textWidth / 2), (110) - (this.textHeight / 2)); for (Player player : playerList) { player.render(); graphics.draw(player.getBoundingBox()); } drawSaveInfo(gameContainer, graphics); }
public void render(GameContainer gameContainer) { Graphics graphics = gameContainer.getGraphics(); Font font = graphics.getFont(); this.bgImage.draw(); graphics.setAntiAlias(true); for (ButtonData buttonData : buttons) { RoundedRectangle button = buttonData.getButton(); String message = buttonData.getMessage(); Color buttonColour = buttonData.getColour(); graphics.setColor(buttonColour); graphics.fillRoundRect(button.getMinX(), button.getMinY(), button.getWidth(), button.getHeight(), (int) Math.floor(button.getCornerRadius())); if (buttonColour == Color.cyan) { graphics.setColor(Color.black); } else { graphics.setColor(Color.white); } graphics.drawString(message, button.getCenterX() - (font.getWidth(message) / 2), button.getCenterY() - (font.getHeight(message) / 2)); } }
public void update(GameContainer gameContainer, int deltaTime) throws SlickException { float mouseX = gameContainer.getInput().getMouseX(); float mouseY = gameContainer.getInput().getMouseY(); for (ButtonData buttonData : buttons) { RoundedRectangle button = buttonData.getButton(); if (mouseX < button.getMaxX() * this.game.getScaleX() && mouseX > button.getMinX() * this.game.getScaleX() && mouseY < button.getMaxY() * this.game.getScaleY() && mouseY > button.getMinY() * this.game.getScaleY()) { buttonData.setColour(Color.blue); if (gameContainer.getInput().isMousePressed(Input.MOUSE_LEFT_BUTTON)) { if (buttonData.getMessage() == "Exit") { System.exit(0); } } } else { if (buttonData.getColour() != Color.cyan) { buttonData.setColour(Color.cyan); } } } }
/** * The constructor. * * @param x The x position of the textbox * @param y The y position of the textbox * @param width The width of the textbox * @param height The height of the textbox */ public Textbox(float x, float y, float width, float height){ super(x, y, width, height); textContainer = new RoundedRectangle(x, y, width, height, 10f); headerContainer = new RoundedRectangle(x, y - 40, 100, 35, 10f); graphicTextLines = new ArrayList<GraphicText>(); textFont = new TrueTypeFont(new java.awt.Font("Calibri", java.awt.Font.PLAIN, 16), false); text = new ArrayList<String>(); header = new ArrayList<String>(); KeyInput.addInputCommand("Run Textbox Action", Input.KEY_ENTER, 0); }
/** * The constructor * * @param x The x position * @param y The y position * @param width The width * @param height The height */ public Confirmbox(float x, float y, float width, float height) { super(x, y, width, height); selectionBox = new RoundedRectangle(x, y, width - margins[LEFT_MARGIN] - margins[RIGHT_MARGIN], textFont.getHeight(), 5f); columnWidth = selectionBox.getWidth(); KeyInput.addInputCommand("Confirm Dialogbox Key Up", Input.KEY_UP, 0); KeyInput.addInputCommand("Confirm Dialogbox Key Down", Input.KEY_DOWN, 0); KeyInput.addInputCommand("Confirm Dialogbox Key Left", Input.KEY_LEFT, 0); KeyInput.addInputCommand("Confirm Dialogbox Key Right", Input.KEY_RIGHT, 0); }
/** * Renders this tile and its value (if necessary). * * @param g */ public void render(Graphics g) { // Drawing the tile g.setColor(colours[ColourScheme.TILE_COLOUR_IDX]); g.fill(new RoundedRectangle((int) position.getX() + 1, (int) position.getY() + 1, (int) size.getWidth(), (int) size.getHeight(), 8)); // Drawing the tile value, if the tile is valid if (value != -1) { g.setColor(colours[ColourScheme.TEXT_COLOUR_IDX]); g.drawString(Integer.toString(value), valueRenderPosX, valueRenderPosY); } }
public GameOverScreen(SteampunkZelda game) throws SlickException { super(game, 1280, 720); this.bgImage = new Image("res/screens/gameover.png"); this.buttons.add(new ButtonData(new RoundedRectangle((this.game.getWindowSize().getX() / 4) * 3 - 100f, (this.game.getWindowSize().getY() / 4) * 3, 100f, 25f, 2f), "Exit", Color.cyan)); }
public ButtonData(RoundedRectangle rectangle, String message, Color colour) { this.button = rectangle; this.message = message; this.colour = colour; }
public RoundedRectangle getButton() { return this.button; }