package home;

import java.awt.event.KeyEvent;

import javax.media.opengl.GL;

import object.Model;
import util.WAV;
import world.GameObject;

public class Rocket extends GameObject {
	
	Model rocket;
	
	WAV chime = new WAV("/audio/FX/Chime.wav");
	
	public Rocket() {
		
		rocket = new Model();
		
		rocket.setMode(true, false);
		rocket.parseObjectFile(ClassLoader.getSystemResourceAsStream(
						"visual/models/Rocket.obj"));
		
		rocket.setSize(1000, 1000, 2000);
		rocket.setColor(0, 0, 1);
		rocket.setRotation(-90, 0, 0);
		
		rocket.setPosition(3000, 1000, 3000);
		
		chime.play();
	}
	
	public void update() {
		
		if(Math.sqrt(Math.pow(rocket.getXPosition() - camera.getXPosition(), 2) +
			Math.pow(rocket.getZPosition() - camera.getZPosition(), 2)) < 300)
			
			for(int i = 0; i < input.getKeysDown().size(); i++)
				
				if(input.getKeysDown().get(i) == KeyEvent.VK_SPACE) {
					
					chime.stop();
					
					triggeredGameState = "Level, Space";
					endScene();
				}
	}
	
	public void render(GL gl) {
		rocket.render(gl);
	}
}