コード例 #1
0
ファイル: GUI.java プロジェクト: actorclavilis/InsaneMouse
  public void paintComponent(Graphics g) {
    super.paintComponent(g);

    height = this.getHeight();
    width = this.getWidth();

    drawPlayers(g);
    g.setColor(Color.WHITE);
    g.drawString("Score", width - 60, 25);
    g.drawString(String.valueOf(score), width - 60, 40);

    if (countdownF) {
      g.drawString(String.valueOf(counterN), width / 2 - 10, height / 2);
    } else {
      if ((spawnCircleB) && (spawnIncrease)) {
        spawnCircles();
      }
      if (spawnMonsterB) {
        spawnMonsters();
      }
      if (spawnRandomersB) {
        spawnRandomers();
      }
      if (spawnRainB) {
        spawnRain();
      }
      if (spawnBombB()) {
        spawnBomb();
      }

      try {
        Iterator i = enemies.iterator();
        while (i.hasNext()) {
          Enemy e = (Enemy) i.next();
          Iterator j = players.iterator();
          while (j.hasNext()) {
            Player p = (Player) j.next();
            e.move(players, programSpeedAdjust /*/players.size()*/);
            if ((e.collidesWith(p.getX(), p.getY())) && (!p.getImmunity())) {
              p.decLives(p.getX(), p.getY());
              p.setImmunity(true);
            }
          }
          e.paint(g);
        }
      } catch (Exception e) {
      }
    }
    drawLayout(g);
  }
コード例 #2
0
ファイル: DemoGame.java プロジェクト: vfseanm/Vooga2
 @Override
 public void render(Graphics2D arg0) {
   myBackground.render(arg0);
   myPlayfield.render(arg0);
   myEnemy.render(arg0);
   renderFSM(arg0);
 }
コード例 #3
0
ファイル: DemoGame.java プロジェクト: vfseanm/Vooga2
  private void initEnemyFSM() {
    List<String> images = new ArrayList<String>();
    images.add("resources/Bowser.jpg");
    myEnemy = new Enemy(1500, 200, images);
    myEnemy.setState(PassiveState.getInstance());
    myEnemy.setGroup("UNIQUE");

    List<String> images2 = new ArrayList<String>();
    images2.add("resources/Fireball.jpg");
    AnimatedGameSprite wep = new AnimatedGameSprite(-1000, -1000, images2);
    Weapon weapon = new Fireball(wep, -0.1, 100000000, 200);
    Attribute att = new ProjectileAttack(weapon);
    myEnemy.addAttribute(att);
    allSprites.add(myEnemy);
    myPlayfield.add(myEnemy);
  }
コード例 #4
0
ファイル: GUI.java プロジェクト: actorclavilis/InsaneMouse
 private boolean spawnBombB() {
   boolean bombPartsExist = false;
   try {
     Iterator i = enemies.iterator();
     while (i.hasNext()) {
       Enemy e = (Enemy) i.next();
       if (e.getClass().equals(EnemyTypes.Bomb.class)
           || (e.getClass().equals(EnemyTypes.Shrapnel.class))) {
         bombPartsExist = true;
         break;
       }
     }
   } catch (Exception e) {
   }
   return !bombPartsExist;
 }
コード例 #5
0
ファイル: DemoGame.java プロジェクト: vfseanm/Vooga2
  @Override
  public void update(long elapsedTime) {

    updateFSM(elapsedTime);
    myEnemy.update(elapsedTime);
    myCollisions.checkCollision();
    myPlayfield.update(elapsedTime);
    myFighter.update(elapsedTime);
    mySidescroller.update(elapsedTime);
  }
コード例 #6
0
  public static void disappearIntoTrap(Enemy e) {
    double startSuck = TrapDroppedGBS.animationTime2;
    double shouldbeGone = TrapDroppedGBS.animationTime3;
    long cT = MazeRunner.currentTime;
    if (e.TOD + shouldbeGone > cT && cT > e.TOD + startSuck) {
      // x translaten
      double gewenstX = e.getTrappedX();
      double curX = e.locationX;
      double deltaX = gewenstX - curX;
      double x = e.locationX + deltaX * (cT - startSuck - e.TOD) / shouldbeGone;
      e.setLocationX(x);

      // y translaten
      double gewenstY = MazeRunner.level.getMaze(MazeRunner.level.getCurrentMaze(e)).mazeY + 0.1;
      double curY = e.locationY;
      double deltaY = gewenstY - curY;
      double y = e.locationY + deltaY * (cT - startSuck - e.TOD) / shouldbeGone;
      e.setLocationY(y);

      // z translaten
      double gewenstZ = e.getTrappedZ();
      double curZ = e.locationZ;
      double deltaZ = gewenstZ - curZ;
      double z = e.locationZ + deltaZ * (cT - startSuck - e.TOD) / shouldbeGone;
      e.setLocationZ(z);

      // Down-scalen
      double gewenstS = 0;
      double curS = e.getSize();
      double deltaS = gewenstS - curS;
      double s = e.getSize() + deltaS * (cT - startSuck - e.TOD) / shouldbeGone;
      e.setSize(s);
    }
    if (e.TOD + shouldbeGone < cT) {
      e.setDead(true);
    }
  }