Advertisement
huneater

GUI.class

Apr 21st, 2013
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.17 KB | None | 0 0
  1. package gui;
  2.  
  3. import org.newdawn.slick.Color;
  4. import org.newdawn.slick.GameContainer;
  5. import org.newdawn.slick.Graphics;
  6.  
  7. /**
  8.  * User: Zsolt
  9.  * Date: 2013.04.21.
  10.  * Time: 17:53
  11.  */
  12.  
  13. public abstract class GUI {
  14.     protected int x, y, width, height;
  15.     protected ActionHandler handler;
  16.     protected Color color = Color.darkGray;
  17.  
  18.     public GUI(int x, int y, int width, int height) {
  19.         this.x = x;
  20.         this.y = y;
  21.         this.width = width;
  22.         this.height = height;
  23.     }
  24.  
  25.     public void setX(int x) {
  26.         this.x = x;
  27.     }
  28.  
  29.     public void setY(int y) {
  30.         this.y = y;
  31.     }
  32.  
  33.     public void setColor(Color color) {
  34.         this.color = color;
  35.     }
  36.  
  37.     public void add(ActionHandler handler) {
  38.         this.handler = handler;
  39.     }
  40.  
  41.     public ActionHandler getHandler() {
  42.         return handler;
  43.     }
  44.  
  45.     public boolean checkClick(float mouseX, float mouseY) {
  46.         if (mouseX > x - width / 2 && mouseX < x + width / 2 && mouseY > y - height / 2 && mouseY < y + height / 2) {
  47.             return true;
  48.         }
  49.  
  50.         return false;
  51.     }
  52.  
  53.     public abstract void render(GameContainer gc, Graphics g);
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement