}
}
for (int i = 0; i < Constants.UPDATES; i++) {
Input input = gc.getInput();
if (input.isKeyPressed(Input.KEY_C)) {
worldCenterX = gc.getWidth()/2 - (currentBeaverBody.getX()*scale);
worldCenterY = gc.getHeight()/2 - (currentBeaverBody.getY()*-scale);
}
if (input.isKeyDown(Input.KEY_Z)) {
if (scale > 0.001f) {
scale = scale - 0.001f;
worldCenterX = gc.getWidth()/2 - (currentBeaverBody.getX()*scale);
worldCenterY = gc.getHeight()/2 - (currentBeaverBody.getY()*-scale);
}
}
if (input.isKeyDown(Input.KEY_X)) {
scale = scale + 0.001f;
worldCenterX = gc.getWidth()/2 - (currentBeaverBody.getX()*scale);
worldCenterY = gc.getHeight()/2 - (currentBeaverBody.getY()*-scale);
}
if (input.isKeyDown(Input.KEY_W)) {
worldCenterY += 0.2f;// /updates;
}
if (input.isKeyDown(Input.KEY_S)) {
worldCenterY -= 0.2f;// /updates;
}
if(input.isKeyPressed(Input.KEY_R)){
System.out.println(crosshairAngle);
crosshairAngle = 45;
}
if(input.isKeyPressed(Input.KEY_Q)){
currentPlayer.getCurrentBeaver().cycleWeapon();
}
if (input.isKeyDown(Input.KEY_A)) {
worldCenterX += 0.2f;// /updates;
}
if (input.isKeyPressed(Input.KEY_O)) {
endTurn(gc);
}
if (input.isKeyDown(Input.KEY_D)) {
worldCenterX -= 0.2f;// /updates;
}
if (input.isKeyDown(Input.KEY_RIGHT)) {
if(endTurn>0){
continue;
}
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 (input.isKeyDown(Input.KEY_LEFT)) {
if(endTurn>0){
continue;
}
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 (input.isKeyDown(Input.KEY_UP)){
if(endTurn>0){
continue;
}
if (crosshairAngle < 180 && crosshairAngle > 0) crosshairAngle -= 0.1f;
else if (crosshairAngle > 180 && crosshairAngle < 360) crosshairAngle += 0.1f;
}
if (input.isKeyDown(Input.KEY_DOWN)){
if(endTurn>0){
continue;
}
if (crosshairAngle < 180 && crosshairAngle > 0) crosshairAngle += 0.1f;
else if (crosshairAngle > 180 && crosshairAngle < 360) crosshairAngle -= 0.1f;
}
if (input.isKeyPressed(Input.KEY_ENTER)) {
if(endTurn>0){
continue;
}
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 (input.isKeyPressed(Input.KEY_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);
}
}
if (input.isKeyPressed(Input.KEY_ESCAPE)){
sbg.enterState(BeaversGame.MAINMENUSTATE);
}
if (drawCircle) {
addExplosionToTerrain((int) collisionX, (int) collisionY, this.radius);