Exemple #1
0
 private void calculateCameraPosition(float horizDistance, float verticDistance) {
   float theta = player.getRotY() + angleAroundPlayer;
   float offsetX = (float) (horizDistance * Math.sin(Math.toRadians(theta)));
   float offsetZ = (float) (horizDistance * Math.cos(Math.toRadians(theta)));
   position.x = player.getPosition().x - offsetX;
   position.z = player.getPosition().z - offsetZ;
   position.y = player.getPosition().y + verticDistance;
 }
Exemple #2
0
 public void landOnField(Player player) {
   getFeltBesked(player);
   if (!player.equals(owner)) {
     if (owner == null) buyFieldOption(player);
     else getRent(player);
   }
 }
Exemple #3
0
 /*
  * (non-Javadoc)
  *
  * @see entities.items.Item#action(entities.Player)
  */
 @Override
 public void action(Player p) {
   int b_x = Box.fitToBlock(p.x);
   int b_y = Box.fitToBlock(p.y);
   Game.entities.add(new Trap(b_x, b_y, p));
   p.item = null;
 }
  /**
   * Permet au boss de se déplacer
   *
   * @param delta La durée d'une ittération
   */
  @Override
  public void update(int delta) {
    if (player.getX() < this.x + aggroRange
        && player.getX() > this.x - aggroRange
        && player.getY() < this.y + aggroRange
        && player.getY() > this.y - aggroRange) {
      moving = true;
      aggro = true;
    }
    if (moving && knockbackTimer <= 0 && !attaquing) {
      int relativeX = Math.abs((int) this.x - (int) player.getX()),
          relativeY = Math.abs((int) this.y - (int) player.getY());
      if (this.x < player.getX() && relativeX > relativeY) {
        this.direction = 3;
      } else if (this.x > player.getX() && relativeX > relativeY) {
        this.direction = 1;
      } else if (this.y < player.getY() && relativeY > relativeX) {
        this.direction = 2;
      } else if (this.y > player.getY() && relativeY > relativeX) {
        this.direction = 0;
      }
      if (!map.isCollision(futurX(delta), futurY(delta))) {
        this.x = futurX(delta);
        this.y = futurY(delta);
      }
      this.attack();
    } else if (knockbackTimer > 0) {
      moving = true;
      float tempSpeed = speed;
      speed = 0.5f;
      if (!map.isCollision(futurX(-delta), futurY(-delta))) {
        this.x = futurX(-delta);
        this.y = futurY(-delta);
      }
      speed = tempSpeed;
      knockbackTimer -= delta;

    } else if (attCounter > 0 && attaquing) {
      attCounter -= delta;
      if (attCounter <= 0) {
        attaquing = false;
        xOff = -16;
        yOff = -60;
        hitBox = new Box(x + xOff, y + yOff, 32, 60);
      }
    }
    if (attCooldown > 0) {
      attCooldown -= delta;
    }
    hitBox.setPos(x + xOff, y + yOff);
  }
Exemple #5
0
 public void move() {
   calculateZoom();
   calculatePitch();
   calculateAngleAroundPlayer();
   float horiztonalDistance = calculateHorizontalDistance();
   float verticalDistance = calculateVerticalDistance();
   calculateCameraPosition(horiztonalDistance, verticalDistance);
   this.yaw = 180 - (player.getRotY() + angleAroundPlayer);
 }
Exemple #6
0
 private void globaldraw() {
   GL11.glMatrixMode(GL11.GL_PROJECTION);
   GL11.glLoadIdentity();
   GL11.glOrtho(
       0, Display.getDisplayMode().getWidth(), 0, Display.getDisplayMode().getHeight(), -1, 1);
   GL11.glMatrixMode(GL11.GL_MODELVIEW);
   GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_STENCIL_BUFFER_BIT);
   for (int i = 0; i < blocks.size(); i++) blocks.get(i).onDraw(xorig);
   player.onDraw();
   Display.sync(120);
   setPoints();
 }
Exemple #7
0
  public boolean move() {
    Vector3f oldPos = new Vector3f(position.x, position.y, position.z);
    float oldPitch = pitch;
    float oldYaw = yaw;
    float oldRoll = roll;
    boolean hasMoved = false;
    calculateZoom();
    calculatePitch();
    calculateAngleAroundPlayer();
    float horizontalDistance = calculateHorizontalDistance();
    float verticalDistance = calculateVerticalDistance();
    calculateCameraPosition(horizontalDistance, verticalDistance);
    this.yaw = 180 - (player.getRotY() + angleAroundPlayer);

    if (oldPos.x != position.x
        || oldPos.y != position.y
        || oldPos.z != position.z
        || oldPitch != pitch
        || oldYaw != yaw
        || oldRoll != roll) hasMoved = true;

    return hasMoved;
  }
  @Override
  public void render(float delta) {
    Gdx.gl.glClearColor(1F, 1F, 1F, 1F);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    batch.begin();
    batch.draw(Assets.background, 0, 0, W, H);
    batch.end();

    switch (state) {
      case PAUSE:
        batch.begin();
        batch.draw(
            Assets.avoid,
            (W / 2) - (Assets.avoid.getWidth() / 2),
            H - (augH + Assets.avoid.getHeight()));
        batch.draw(Assets.touch, (W / 2) - (Assets.touch.getWidth() / 2), augH);
        batch.draw(Assets.player, player.getPosition().x, player.getPosition().y);
        batch.end();
        Timer.schedule(
            new Task() {
              @Override
              public void run() {
                touch();
              }
            },
            0.3f);

        break;
      case RUN:
        if (playing) {
          if (gameover == false) {
            time += Gdx.graphics.getDeltaTime();
            meteorIterator = meteor.iterator();
            while (meteorIterator.hasNext()) {
              Meteor cur = meteorIterator.next();
              cur.update();
              batch.begin();
              batch.draw(
                  Assets.meteor,
                  cur.getPosition().x,
                  cur.getPosition().y,
                  Assets.meteor.getWidth() / 2f,
                  Assets.meteor.getHeight() / 2f,
                  Assets.meteor.getWidth(),
                  Assets.meteor.getHeight(),
                  1,
                  1,
                  cur.getMetSp().getRotation(),
                  0,
                  0,
                  Assets.meteor.getWidth(),
                  Assets.meteor.getHeight(),
                  false,
                  false);
              batch.end();
              cur.getMetSp().rotate(8f);
              if (Intersector.overlaps(cur.getmBounds(), player.getpBounds())) {
                gameover = true;
              }
            }
            enemyIterator = enemy.iterator();
            enemyIterator = enemy.iterator();
            while (enemyIterator.hasNext()) {
              Enemy cur = enemyIterator.next();
              cur.update();
              batch.begin();
              batch.draw(
                  Assets.enemy1,
                  cur.getPosition().x,
                  cur.getPosition().y,
                  scX / 2f,
                  scY / 2f,
                  scX,
                  scY,
                  1,
                  1,
                  cur.getRotate().getRotation());
              batch.end();
              cur.getRotate().rotate(-5f);
              if (Intersector.overlaps(cur.getBounds(), player.getpBounds())) {
                gameover = true;
              }
            }
            batch.begin();
            if (time > 40) {
              e2.update();
              batch.draw(Assets.enemy2, e2.getPosition().x, e2.getPosition().y);
              if (Intersector.overlaps(player.getpBounds(), e2.getBounds())) {
                gameover = true;
              }
            }
            if (Assets.H && !Assets.N) {
              if (time > 80) {
                e4.update();
                batch.draw(Assets.enemy2, e4.getPosition().x, e4.getPosition().y);
                if (Intersector.overlaps(player.getpBounds(), e2.getBounds())) {
                  gameover = true;
                }
              }
            }
            batch.draw(Assets.player, player.getPosition().x, player.getPosition().y);
            batch.end();
          } else {
            if (Assets.N) {
              Assets.setBestTime(time, true);
            } else {
              Assets.setBestTime(time, false);
            }
            Assets.setCurrentTime(time);
            exp.currentFrame = exp.anime.getKeyFrame(delta, false);
            batch.begin();
            batch.draw(exp.currentFrame, player.getPosition().x, player.getPosition().y);
            batch.end();
            if (!Assets.boom.isPlaying()) {
              Assets.boom.play();
            }
            Timer.schedule(
                new Task() {
                  @Override
                  public void run() {
                    playing = false;
                  }
                },
                0.7f);
          }
        } else {
          game.setScreen(new Replay(game));
        }

        if (gameover == false) {
          player.movement();
          player.update();
        } else if (gameover) {
          Assets.bgm.stop();
        }
        break;
    }
  }
Exemple #9
0
 private void calculateAngleAroundPlayer() {
   if (Mouse.isButtonDown(0) && !Player.getEdit()) {
     float angleChange = Mouse.getDX() * 0.3f;
     angleAroundPlayer -= angleChange;
   }
 }
 /** L'animation d'attaque du boss */
 public void attack() {
   boolean isInRange = false;
   switch (direction) {
     case 0:
       if (player.getX() > this.x - 32
           && player.getX() < this.x + 32
           && player.getY() > this.y - 128
           && player.getY() < this.y - 64) {
         isInRange = true;
       }
       break;
     case 1:
       if (player.getX() > this.x - 96
           && player.getX() < this.x - 32
           && player.getY() > this.y - 64
           && player.getY() < this.y) {
         isInRange = true;
       }
       break;
     case 2:
       if (player.getX() > this.x - 32
           && player.getX() < this.x + 32
           && player.getY() > this.y
           && player.getY() < this.y + 64) {
         isInRange = true;
       }
       break;
     case 3:
       if (player.getX() < this.x + 96
           && player.getX() > this.x + 32
           && player.getY() > this.y - 64
           && player.getY() < this.y) {
         isInRange = true;
       }
       break;
   }
   if (isInRange && attCooldown <= 0) {
     attaquing = true;
     attCooldown = 1000;
     attCounter = 500;
     for (int i = 0; i < attackAnimation.length; i++) {
       attackAnimation[i].restart();
     }
     switch (direction) {
       case 0:
         yOff = -124;
         hitBox = new Box(x + xOff, y + yOff, 32, 128);
         break;
       case 1:
         xOff = -76;
         hitBox = new Box(x + xOff, y + yOff, 96, 60);
         break;
       case 2:
         hitBox = new Box(+xOff, y + yOff, 32, 128);
         break;
       case 3:
         hitBox = new Box(+xOff, y + yOff, 96, 60);
         break;
     }
   }
 }