}
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);
}
}
}