Package org.newdawn.fizzy

Examples of org.newdawn.fizzy.Body


  }
 
  private void handleMove(String move, GameContainer gc, StateBasedGame sbg, int delta) throws SlickException{
   
    Body currentBeaverBody = currentPlayer.getCurrentBeaver().getBody();
    Beaver currentBeaver = currentPlayer.getCurrentBeaver();
    this.radius = currentBeaver.getCurrentWeapon().getBlastRadius();
   
   
    if(move.equalsIgnoreCase("r")){
      System.out.println(crosshairAngle);
      crosshairAngle = 45;
    }

    if(move.equalsIgnoreCase("q")){
      currentPlayer.getCurrentBeaver().cycleWeapon();
     
    }

    if (move.equalsIgnoreCase("o")) {
      endTurn = 5000;
    }


    if (move.equalsIgnoreCase("right")) {
      if(endTurn>0){
        return;
      }

      if (crosshairAngle > 180) crosshairAngle = 180-(crosshairAngle-180);
      team1MovingR.update(delta*100);
      team2MovingR.update(delta*100);
      currentPlayer.getCurrentBeaver().setFacingR(true);
      if (currentBeaverBody.getAngularVelocity() > -1.5)
        currentBeaverBody.setAngularVelocity(currentBeaverBody
            .getAngularVelocity() - 0.05f);
      currentBeaverBody.setAngularVelocity(-1.5f);
    }

    if (move.equalsIgnoreCase("left")) {
      if(endTurn>0){
        return;
      }
      if (crosshairAngle < 180) crosshairAngle = 180+(180-crosshairAngle);
      team1Moving.update(delta*100);
      team2Moving.update(delta*100);
      currentPlayer.getCurrentBeaver().setFacingR(false);
      if (currentBeaverBody.getAngularVelocity() < 1.5)
        currentBeaverBody.setAngularVelocity(currentBeaverBody.getAngularVelocity() + 0.05f);
      currentBeaverBody.setAngularVelocity(1.5f);
    }

    if (move.equalsIgnoreCase("up")){
      if(endTurn>0){
        return;
      }
      if (crosshairAngle < 180 && crosshairAngle > 0) crosshairAngle -= 0.1f;
      else if (crosshairAngle > 180 && crosshairAngle < 360) crosshairAngle += 0.1f;
    }

    if (move.equalsIgnoreCase("down")){
      if(endTurn>0){
        return;
      }
      if (crosshairAngle < 180 && crosshairAngle > 0) crosshairAngle += 0.1f;
      else if (crosshairAngle > 180 && crosshairAngle < 360) crosshairAngle -= 0.1f;
    }

    if (move.equalsIgnoreCase("enter")) {
      if(endTurn>0){
        return;
      }
      if(currentPlayer.getCurrentBeaver().getCurrentWeapon().getAmmo()>0){
        currentPlayer.getCurrentBeaver().useWeapon();
        if (!powerSeqEngaged) {
          power = 1;
          powerSeqEngaged = true;
        }
        else {
          powerSeqEngaged = false;
          currentBeaverBody.setActive(false);
          bullet = new DynamicBody(new Circle(5),currentBeaverBody.getX(),currentBeaverBody.getY());
          bullet.setBullet(true);
          bullet.setRestitution(0);
          float x = (float) (Math.sin(Math.toRadians(crosshairAngle)));
          float y = (float) (Math.cos(Math.toRadians(crosshairAngle)));
          float xForce = (power/50)*(x)*10000000f;
          float yForce = (power/50)*(y)*10000000f;
          //System.out.println("x is "+x+", y is "+y+", angle at"+crosshairAngle);
          world.add(bullet);
          world.addBodyListener(bullet, this);
          bullet.applyForce(xForce, yForce);
          //Shot is fired, turn is over
          cameraOnBullet = true;
        }
      }

    }

    if (move.equalsIgnoreCase("space")) {
      if (currentBeaverBody.getYVelocity() < 0.7 && currentBeaver.getFacingR()) {
        currentBeaverBody.applyForce(0, 1500000f);// /updates);
      }
      if (currentBeaverBody.getYVelocity() > -0.7 && !currentBeaver.getFacingR()) {
        currentBeaverBody.applyForce(0, 1500000f);// /updates);
      }
    }


  }
View Full Code Here


    g.pushTransform();
    g.translate(worldCenterX, worldCenterY);
    g.scale(scale, -scale);

    for (int i = 0; i < world.getBodyCount(); i++) {
      Body body = world.getBody(i);
      if (!body.equals(terrainBody) && !body.equals(boundary)) {
        g.setColor(Color.black);
        drawBody(g, body);
      }
    }
    g.popTransform();
View Full Code Here

TOP

Related Classes of org.newdawn.fizzy.Body

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.