private boolean checkWin() { if (player1.getLocalTranslation().getCol(3).getX() >= 365) { return true; } else { return false; } }
public void initAudio() { audioMgr = AudioManagerFactory.createAudioManager("sage.audio.joal.JOALAudioManager"); if (!audioMgr.initialize()) { System.out.println("Audio Manager failed to initialize!"); return; } resource1 = audioMgr.createAudioResource( "src/sounds/Kai_Engel_-_07_-_February.wav", AudioResourceType.AUDIO_SAMPLE); // resource1 = audioMgr.createAudioResource("src/12345.wav", // AudioResourceType.AUDIO_SAMPLE); // System.out.println(resource1.getIsLoaded()); // System.out.println(resource1.getAudioFormat()); // System.out.println(resource1.getFileName()); // System.out.println(resource1.getAudioType()); backgroundMusic = new Sound(resource1, SoundType.SOUND_EFFECT, 100, true); backgroundMusic.initialize(audioMgr); backgroundMusic.setMaxDistance(50.0f); backgroundMusic.setMinDistance(3.0f); backgroundMusic.setRollOff(5.0f); backgroundMusic.setLocation(new Point3D(player1.getWorldTranslation().getCol(3))); setEarParameters(); // musicSound.play(); backgroundMusic.play(); resource1 = audioMgr.createAudioResource( "src/sounds/Splat-SoundBible.wav", AudioResourceType.AUDIO_SAMPLE); splatSound = new Sound(resource1, SoundType.SOUND_EFFECT, 100, true); splatSound.initialize(audioMgr); splatSound.setMaxDistance(50.0f); splatSound.setMinDistance(3.0f); splatSound.setRollOff(5.0f); splatSound.setLocation(new Point3D(player1.getWorldTranslation().getCol(3))); }
public void setEarParameters() { Matrix3D avDir = (Matrix3D) (player1.getWorldRotation().clone()); float camAz; if (!isGPOn) { camAz = cam1Controller.getAzimuth(); } else { camAz = cam1GPController.getAzimuth(); } avDir.rotateY(180.0f - camAz); Vector3D camDir = new Vector3D(0, 0, 1); camDir = camDir.mult(avDir); audioMgr.getEar().setLocation(camera1.getLocation()); audioMgr.getEar().setOrientation(camDir, new Vector3D(0, 1, 0)); }
private void initPlayers() { File file = new File(File.pathSeparator); System.out.println(file.getAbsolutePath()); OgreXMLParser loader = new OgreXMLParser(); try { model = loader.loadModel( "src/animated_objects/Cube.mesh.xml", "src/animated_objects/chicken.material", "src/animated_objects/Cube.skeleton.xml"); model.updateGeometricState(0, true); java.util.Iterator<SceneNode> modelIterator = model.iterator(); player1 = (Model3DTriMesh) modelIterator.next(); } catch (Exception e) { e.printStackTrace(); System.exit(1); } Texture chickenTexture = TextureManager.loadTexture2D("src/animated_objects/green_chicken.jpg"); chickenTexture.setApplyMode(sage.texture.Texture.ApplyMode.Replace); chickenTextureState = (TextureState) display.getRenderer().createRenderState(RenderState.RenderStateType.Texture); chickenTextureState.setTexture(chickenTexture, 0); chickenTextureState.setEnabled(true); player1.setRenderState(chickenTextureState); player1.updateRenderStates(); player = physicsEngine.addSphereObject( physicsEngine.nextUID(), ballMass, player1.getWorldTransform().getValues(), 1.0f); player.setBounciness(0.0f); player1.setPhysicsObject(player); player1.scale(.35f, .35f, .35f); addGameWorldObject(player1); // player1.translate(133f, 13f, 123f); playerInitM = new Matrix3D(); playerInitM.concatenate((Matrix3D) player1.getLocalTranslation().clone()); playerInitM.concatenate((Matrix3D) player1.getLocalRotation().clone()); playerInitM.concatenate((Matrix3D) player1.getLocalScale().clone()); camera1 = new JOGLCamera(renderer); camera1.setPerspectiveFrustum(60, 1, 1, 1000); camera1.setViewport(0.0, 1.0, 0.0, 1); }
public Matrix3D getPlayerPosition() { Matrix3D playerM = new Matrix3D(); playerM.concatenate(player1.getLocalTranslation()); playerM.concatenate(player1.getLocalRotation()); return playerM; }
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); }