Exemplo n.º 1
0
  @SuppressWarnings("unchecked")
  public GameOver(String text, int score, boolean victory) {
    this.text = text;
    this.score = score;
    this.victory = victory;
    font = new UnicodeFont(Database.instance().getDefaultFont().getFont(), 50, true, false);

    font.addAsciiGlyphs();
    font.getEffects().add(new ColorEffect());
    try {
      font.loadGlyphs();
    } catch (SlickException e1) {
      e1.printStackTrace();
    }

    nameInput =
        new TextField(
            GameCore.getInstance().getApp(),
            Database.instance().getDefaultFont(),
            150,
            20,
            500,
            Database.instance().getDefaultFont().getLineHeight() + 20,
            new ComponentListener() {
              public void componentActivated(AbstractComponent source) {
                input = nameInput.getText();
              }
            });
    nameInput.setFocus(true);
    nameInput.setBorderColor(Color.black);
    nameInput.setText("Anonymous");
    nameInput.setMaxLength(20);
  }
Exemplo n.º 2
0
 public void init(GameContainer gc, StateBasedGame sbg) throws SlickException {
   super.init(gc, sbg);
   multiLb = new MKLabelNode("Multiplayer");
   multiLb.setPostion(new MKPoint(50, 50));
   multiLb.setFont(new Font("Verdana", Font.BOLD, 50));
   // gc font x y w h
   textField =
       new TextField(
           gc, new TrueTypeFont(new Font("Verdana", Font.BOLD, 30), false), 50, 10, 500, 50);
   textField.setText("username...");
   textField.setCursorPos("username...".length());
 }
Exemplo n.º 3
0
 @Override
 public void render(GameContainer gc, StateBasedGame sbg, Graphics g) throws SlickException {
   knight.draw(594, 360);
   mage.draw(784, 360);
   thief.draw(976, 360);
   g.setColor(Color.white);
   g.drawString("Name:", 650, 500);
   tf.render(gc, g);
   tf.setFocus(true);
   for (int i = 0; i < buttons.size(); i++) {
     buttons.get(i).draw(g);
   }
 }
Exemplo n.º 4
0
  @Override
  public void render(GameContainer container, Graphics g) throws SlickException {
    nameInput.render(container, g);
    float w = font.getWidth(text);
    float h = font.getLineHeight();
    font.drawString(container.getWidth() / 2 - w / 2, container.getHeight() / 2 - h / 2, text);

    UnicodeFont namefont = Database.instance().getDefaultFont();
    namefont.drawString(
        container.getWidth() / 8, container.getHeight() / 2 - h / 2 + font.getLineHeight(), name);
    nameInput.setLocation(
        container.getWidth() / 8 + namefont.getWidth(name) + 20,
        (int) (container.getHeight() / 2 - h / 2 + font.getLineHeight()));

    nameInput.render(container, g);
  }
Exemplo n.º 5
0
  @Override
  public void init(GameContainer gc, StateBasedGame sbg) throws SlickException {
    am = (AtlasMain) sbg.getState(2);
    tf = new TextField(gc, gc.getDefaultFont(), 700, 500, 200, 25);
    tf.setBackgroundColor(Color.white);
    tf.setTextColor(Color.black);

    buttons = new ArrayList<Button>();
    try {
      rm = new ResourceManager();
    } catch (FileNotFoundException e) {
      e.printStackTrace();
    }
    knight = rm.getSprite("knight.png").getSubImage(0, 0, 32, 32);
    mage = rm.getSprite("mage.png").getSubImage(0, 0, 32, 32);
    thief = rm.getSprite("thief.png").getSubImage(0, 0, 32, 32);

    Button button1 = new Button(520, 400, "Choose Knight", 0);
    Button button2 = new Button(710, 400, "Choose Mage", 1);
    Button button3 = new Button(900, 400, "Choose Thief", 2);
    buttons.add(button1);
    buttons.add(button2);
    buttons.add(button3);
  }
Exemplo n.º 6
0
  @Override
  public void update(GameContainer gc, StateBasedGame sbg, int delta) throws SlickException {
    Input in = gc.getInput();
    float mouseX = in.getMouseX();
    float mouseY = in.getMouseY();

    if (mouseX != lastMouseX || mouseY != lastMouseY) {
      for (int i = 0; i < buttons.size(); i++) {
        buttons.get(i).checkMouseHover(new Vector2f(mouseX, mouseY));
      }
      lastMouseX = mouseX;
      lastMouseY = mouseY;
    }
    if (in.isMousePressed(Input.MOUSE_LEFT_BUTTON)) {
      for (int i = 0; i < buttons.size(); i++) {
        boolean temp = buttons.get(i).checkMouseClick(new Vector2f(mouseX, mouseY), 0);
        if (temp && tf.getText().length() > 0) {
          int e = buttons.get(i).getButtonID();
          Vector2f point = rm.getMap("World_1.tmx").getStartLocation();
          int x = (int) point.x;
          int y = (int) point.y;
          switch (e) {
            case 0:
              p =
                  new Player(
                      Settings.PLAYER_X,
                      Settings.PLAYER_Y,
                      rm.getSprite("knight.png"),
                      tf.getText(),
                      CType.KNIGHT,
                      x,
                      y,
                      rm.getLog());
              break;
            case 1:
              p =
                  new Player(
                      Settings.PLAYER_X,
                      Settings.PLAYER_Y,
                      rm.getSprite("mage.png"),
                      tf.getText(),
                      CType.MAGE,
                      x,
                      y,
                      rm.getLog());
              break;
            case 2:
              p =
                  new Player(
                      Settings.PLAYER_X,
                      Settings.PLAYER_Y,
                      rm.getSprite("thief.png"),
                      tf.getText(),
                      CType.THIEF,
                      x,
                      y,
                      rm.getLog());
              break;
          }
          am = new AtlasMain(p, rm, 2);
          sbg.addState(am);
          am.init(gc, sbg);
          sbg.enterState(2);
        }
      }
    }
    if (in.isKeyPressed(Input.KEY_ESCAPE)) {
      System.exit(0);
    }
  }
Exemplo n.º 7
0
 public void render(GameContainer gc, StateBasedGame sbg, Graphics g) throws SlickException {
   super.render(gc, sbg, g);
   multiLb.render(gc, g);
   textField.render(gc, g);
 }