public void update(float elapsedTimeMS) { super.update(elapsedTimeMS); player1.updateAnimation(elapsedTimeMS); if (!isGPOn) { cam1Controller.update(elapsedTimeMS); } else { cam1GPController.update(elapsedTimeMS); } if (gameClient != null) { gameClient.sendUpdate(getPlayerPosition()); gameClient.processPackets(); } physicsEngine.update(20.0f); Matrix3D mat; Vector3D translateVec; for (SceneNode s : getGameWorld()) { if (s.getPhysicsObject() != null) { if (s.getWorldBound().intersects(player1.getWorldBound()) && (s.getName().equals("src/Models/car.obj") || s.getName().equals("src/Models/truck.obj"))) { playerHit = true; s.setLocalTranslation(new Matrix3D()); s.translate(0, 10, 0); } if (s.getName().equals(player1.getName())) { mat = s.getLocalTranslation(); translateVec = mat.getCol(3); s.getLocalTranslation().setCol(3, translateVec); } else { mat = new Matrix3D(s.getPhysicsObject().getTransform()); translateVec = mat.getCol(3); s.getLocalTranslation().setCol(3, translateVec); } } else if (s instanceof TriMesh && s.getWorldBound().intersects(player1.getWorldBound()) && (s.getName().equals("src/Models/car.obj") || s.getName().equals("src/Models/truck.obj"))) { playerHit = true; } } player1ScoreString.setText("Score = " + player1Score); player1HPString.setText("HP: " + player1HP); Matrix3D camTranslation = new Matrix3D(); camTranslation.translate( camera1.getLocation().getX(), camera1.getLocation().getY(), camera1.getLocation().getZ()); skybox.setLocalTranslation(camTranslation); if (playerHit) { splatSound.play(100, false); player1.translate(133f, 13f, 123f); playerHit = false; } if (gameOver) { player1GameOverString.setText("LOOOOOOOSER!"); } else if (!player1Won) { if (checkWin()) { gameClient.sendWonMessage(); player1Won = true; player1GameOverString.setText("WINNER!"); } } }
public void initPlayerLocation(Vector3D loc) { player1.translate((float) loc.getX(), (float) loc.getY(), (float) loc.getZ()); // player1.translate(133f, 13f, 123f); }