コード例 #1
0
 public Droid(Bitmap[] bitmap, float x, float y, float speed, Game game, boolean isAlive) {
   super(bitmap, x, y, speed, game.getLevel().getGrid(), game, isAlive);
   mGame = game;
 }
コード例 #2
0
ファイル: Human.java プロジェクト: MarkClaessens/PTS31D
  /**
   * check if the human interacts with ghost, key, door or wall
   *
   * @param game
   * @throws java.lang.InterruptedException
   * @throws java.io.IOException
   */
  public void checkInteract(Game game) throws InterruptedException, IOException {
    DirectionType doorDisplacement = game.getLevel().getDoorDirection();
    Point2D door =
        new Point2D.Double(
            game.getLevel().getDoorLocation().getX(), game.getLevel().getDoorLocation().getY());
    switch (doorDisplacement) {
      case UP:
        door.setLocation(door.getX(), door.getY() - 100);
        break;
      case RIGHT:
        door.setLocation(door.getX() + 100, door.getY());
        break;
      case LEFT:
        door.setLocation(door.getX() - 100, door.getY());
        break;
      case DOWN:
        door.setLocation(door.getX(), door.getY() + 100);
        break;
    }
    Point2D key = game.getLevel().getKeyLocation();

    // door collision
    if ((checkHitboxCollision(
            new Point2D.Double(this.getPosition().getX() + 10, this.getPosition().getY() + 10),
            80,
            80,
            new Point2D.Double(door.getX() - 5, door.getY() - 5),
            110,
            110)
        && this.hasKey)) // key collision
    {
      this.enterDoor(game);
    }
    // key collision
    if (checkHitboxCollision(this.getPosition(), 80, 80, key, 80, 80)) {
      this.pickUpKey();
    }
    // flashlight and ghost collision
    if (this.checkGhostCollision(game) != null) {
      this.checkGhostCollision(game).possess(game);
    }
    setFlashlight();
    game.getGhosts()
        .stream()
        .forEach(
            (g) -> {
              if (g.isVulnerable() && !g.getRip() && !g.getDead()) {
                boolean hit = false;
                for (Point2D p : g.getHitboxPoints()) {
                  if (flashlightCollision(p)) {
                    hit = true;
                    break;
                  }
                }
                if (hit) {
                  g.setTimeOfDeath();
                  g.vanish(game);
                }
              }
            });
  }
コード例 #3
0
ファイル: Door.java プロジェクト: jimbobmaggot/Wolf3DClone
 public void render() {
   Shader shader = Game.getLevel().getShader();
   shader.updateUniforms(
       transform.getTransformation(), transform.getProjectedTransformation(), material);
   mesh.draw();
 }
コード例 #4
0
ファイル: LevelPanel.java プロジェクト: zjw0358/zw-schoolwork
 /**
  * Basic drawing implementation for the game.
  *
  * <p>Fills the background (white) and calls Level's drawing method.
  *
  * @param g A Graphics context.
  */
 protected void paintComponent(Graphics g) {
   Rectangle size = g.getClipBounds();
   g.setColor(Color.white);
   g.fillRect(size.x, size.y, size.width, size.height);
   game.getLevel().draw(g);
 }
コード例 #5
0
 /** paintComponent Draws the level of the game */
 public void paintComponent(Graphics g) {
   super.paintComponent(g);
   game.getLevel().draw(g);
 }