private void titelPosition() throws ArithmeticException { // errechnet für Bildschirmgröße x,y die Position der Fonts xtitle1 = (width / 2 - menüSchriftStart.getWidth("START") / 2); xtitle2 = (width / 2 - menüSchriftStart.getWidth("OPTIONEN") / 2); xtitle3 = (width / 2 - menüSchriftStart.getWidth("CREDITS") / 2); ytitle1 = ((height / 4) - ((menüSchriftStart.getHeight("START")) / 2)); ytitle2 = ((height / 2) - ((menüSchriftStart.getHeight("OPTIONEN")) / 2)); ytitle3 = ((3 * height / 4) - ((menüSchriftStart.getHeight("CREDITS")) / 2)); }
/** * @see org.newdawn.slick.state.BasicGameState#render(org.newdawn.slick.GameContainer, * org.newdawn.slick.state.StateBasedGame, org.newdawn.slick.Graphics) */ public void render(GameContainer container, StateBasedGame game, Graphics g) { // Hintergrund rendern background.draw(0, 0); g.setFont(font); g.setColor(Color.white); g.drawString("GAME PAUSED", container.getWidth() / 2 - (font.getWidth("GAME PAUSED") / 2), 180); for (int i = 0; i < options.length; i++) { g.setColor(Color.white); if (selected == i) { g.setColor(Color.red); // g.drawRect(200, 390 + (i * 50), 400, 50); } g.drawString(options[i], 400 - (font.getWidth(options[i]) / 2), 230 + (i * 50)); } }
public void init(GameContainer gc, StateBasedGame sbg) throws SlickException { // throws=nicht um Exception kümmern Image unscaledBackground = new Image("res/Pics/background.jpg"); background = unscaledBackground.getScaledCopy(0.6f); schriftSchwarz = new AngelCodeFont( "res/Fonts/TakeCoverSchwarz.fnt", new Image("res/Fonts/TakeCoverSchwarz.png")); schriftRot = new AngelCodeFont("res/Fonts/TakeCover.fnt", new Image("res/Fonts/TakeCover.png")); menüSchriftStart = schriftSchwarz; menüSchriftOptionen = schriftSchwarz; menüSchriftCredits = schriftSchwarz; this.titelPosition(); // Achtung Image = null!!! startKnopf = new MouseOverArea( gc, null, xtitle1, ytitle1, menüSchriftStart.getWidth("START"), menüSchriftStart.getHeight("START")); optionenKnopf = new MouseOverArea( gc, null, xtitle2, ytitle2, menüSchriftStart.getWidth("OPTIONEN"), menüSchriftStart.getHeight("OPTIONEN")); creditsKnopf = new MouseOverArea( gc, null, xtitle3, ytitle3, menüSchriftStart.getWidth("CREDITS"), menüSchriftStart.getHeight("CREDITS")); knopfGedrueckt = new Sound("res/Sounds/button-29.ogg"); }
public Pause(Font font, int widht, int height) { this.height = height; this.widht = widht; this.font = font; colorB = Color.black; colorB.a = 0.6f; x = widht / 2 - font.getWidth(pause) / 2; y = height / 2 - font.getHeight(pause) / 2; colorF = Color.white; }