Пример #1
0
  public void inicia() {

    Level spawn = new SpawnLevel("/textures/level.png");
    Level spawn2 = new SpawnLevel("/textures/level2.png");

    audio = new Audio();
    menuu = new Menu();
    falas = new Falas();
    frame = new JFrame();
    digni = new Dignidade();
    key = new Keyboard();
    Dimension size = new Dimension(width * scale, height * scale);
    setPreferredSize(size);
    player = new Player(playerSpawn.x(), playerSpawn.y(), key);
    ea = new EstadoAtual();
    projectile = new WizardProjectile(17, 40, -0.17);
    screen = new Screen(width, height);
    if (ea.fase == ea.fase.UM) level = spawn;
    if (ea.fase == ea.fase.DOIS) level = spawn2;
    level.add(player);
    addKeyListener(key);
    Mouse mouse = new Mouse();
    if (ea.State == ea.State.MENU) Dignidade.dign = 245;
    addMouseListener(mouse);
    addMouseMotionListener(mouse);

    // cursor do mouse
    Cursor hourglassCursor = new Cursor(Cursor.CROSSHAIR_CURSOR);
    setCursor(hourglassCursor);
  }
Пример #2
0
 private void attackMoveSelected(int x, int y) {
   attackMoveClicked = false;
   GameSprite target = level.getSpriteAt(x, y);
   for (GameSprite sprite : selected) {
     if (target == null) sprite.goTo(x, y, true, shiftDown());
     else sprite.goTo(target, true, shiftDown());
   }
 }
Пример #3
0
 public static void onLevelCOmplete(int number, boolean isComplete) {
   if (isComplete) {
     JOptionPane.showMessageDialog(null, "Mission Complete!");
   } else {
     JOptionPane.showMessageDialog(null, "Mission Failed");
   }
   if (number == 1) {
     Level.setLevel1(null);
   } else if (number == 2) {
     Level.setLevel2(null);
   } else if (number == 3) {
     Level.setLevel3(null);
   } else if (number == 4) {
     Level.setLevel4(null);
   } else if (true) {
     ThrowCrash("The level was not unloaded correctly");
   }
 }
Пример #4
0
 private void rightMouseClick(int x, int y) {
   attackMoveClicked = false;
   GameSprite target = level.getSpriteAt(x, y);
   for (GameSprite sprite : selected) {
     if (sprite.onTeam(playerTeam)) {
       if (target == null) sprite.goTo(x, y, false, shiftDown());
       else sprite.goTo(target, false, shiftDown());
     }
   }
 }
Пример #5
0
  public void update() {

    ea.update();
    key.update();

    level.update();

    // O level.update() ja da update ne todo resto (player, particulas, mobs, projeteis.. etc)

  }
Пример #6
0
 private void leftMouseClick(int x, int y) {
   if (attackMoveClicked) {
     attackMoveSelected(x, y);
   } else {
     GameSprite sprite = level.getSpriteAt(x, y);
     if (sprite != null) {
       selected.clear();
       selected.add(sprite);
     }
   }
 }
Пример #7
0
  private void handleInput() {
    if (input.clicked(0)) leftMouseClick(input.getX(), input.getY());
    else if (input.clicked(2)) rightMouseClick(input.getX(), input.getY());

    if (input.createdBox()) {
      ArrayList<GameSprite> boxedSprites = level.getSpritesAt(input.getDragBox());
      ArrayList<GameSprite> boxedFriendly = new ArrayList<GameSprite>();
      for (GameSprite sprite : boxedSprites) {
        if (sprite.onTeam(playerTeam)) boxedFriendly.add(sprite);
      }
      if (!boxedFriendly.isEmpty()) {
        selected = boxedFriendly;
      }
    }

    if (input.keyDown(KeyEvent.VK_A)) attackMoveClicked = true;
    if (input.keyDown(KeyEvent.VK_S)) stopSelected();

    if (input.keyDown(KeyEvent.VK_LEFT)) scrollLeft();
    if (input.keyDown(KeyEvent.VK_RIGHT)) scrollRight();
    if (input.keyDown(KeyEvent.VK_UP)) scrollUp();
    if (input.keyDown(KeyEvent.VK_DOWN)) scrollDown();
  }
Пример #8
0
  public void render() {
    BufferStrategy bs = getBufferStrategy();

    if (bs == null) {
      createBufferStrategy(3);
      return;
    }

    screen.clear();

    int xScroll = player.getX() - screen.width / 2;
    int yScroll = player.getY() - screen.height / 2;
    level.render(xScroll, yScroll, screen);

    for (int i = 0; i < pixels.length; i++) {

      pixels[i] = screen.pixels[i];
    }

    Graphics g = bs.getDrawGraphics();

    if (ea.State == ea.State.MENU) {
      menuu.renderMenu(g);
    } else if (ea.State == ea.State.CONVERSAINICIAL) {
      falas.renderFala(g);
    } else if (ea.State == ea.State.CREDITS) {
      menuu.renderCredits(g);
    } else if (ea.State == ea.State.GAME) {
      g.drawImage(image, 0, 0, getWidth(), getHeight(), null);
      digni.render(g);
    } else if (ea.State == ea.State.CONVERSAORC) {
      falas.renderFala(g);
    }

    g.dispose();
    bs.show();
  }
Пример #9
0
 public void render(Graphics g) {
   level.render(selected, screenX, screenY, g);
   GUI.render(input, screenX, screenY, g);
 }
Пример #10
0
 public void tick(Input input) {
   this.input = input;
   handleInput();
   level.tick();
 }