/*
* Flugzeug.java
*
* Created on 1. April 2005, 17:33
*/
package dogfight;
import java.awt.*;
import java.awt.Image.*;
import java.awt.image.*;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.event.*;
import java.net.*;
import java.io.*;
/**
*
* @author Administrator
*/
public class Flugzeug extends Canvas implements Serializable{
private String name;
private int posX = 0;
private int posY = 0;
private int resetX = 0;
private int resetY = 0;
private int richtung = 8;
private int l_richtung = 8;
private double geschwindigkeit = 0;
private boolean aktiv = false;
private String farbe;
private int id;
private String imgPath = "images/"+farbe+"/"+richtung+".gif";
private Image bild;
private static Hauptmenue derFrame;
private static Spielfeld Playground;
private Bewegung Flug;
private GreenFilter filter;
/** Creates a new instance of Flugzeug */
public Flugzeug(Hauptmenue derFrame, Spielfeld Playground, String farbe, int id, int posX, int posY) {
this.derFrame = derFrame;
this.Playground = Playground;
this.farbe = farbe;
this.id = id;
this.posX=posX;
this.posY = posY;
this.richtung = 8;
this.resetX = posX;
this.resetY = posY;
setImg();
}
public boolean getAktiv(){
return aktiv;
}
public int getPosX(){
return posX;
}
public int getPosY(){
return posY;
}
public int getResetX(){
return resetX;
}
public int getResetY(){
return resetY;
}
public void setPosX(int arg){
if (arg > 800){
System.err.println(arg);
posX = 0;
}
else if (arg < -60){
posX = 800;
}
else
posX = arg;
}
public void setPosY(int arg){
if (arg>550){
aktiv = false; //Abgestürzt
geschwindigkeit = 0;
richtung = 8;
posX = resetX;
posY = resetY;
setImg();
Playground.move(id, true);
}
else
posY = arg;
}
public int getRichtung(){
return richtung;
}
public int getLastRichtung(){
return l_richtung;
}
public void setLastRichtung(){
l_richtung = richtung;
}
public int getId(){
return id;
}
public double getGeschwindigkeit(){
return geschwindigkeit;
}
public String getName(){
return name;
}
public String getImg(){
return imgPath;
}
public void setImg(){
imgPath = "images/"+farbe+"/"+richtung+".gif";
bild=Toolkit.getDefaultToolkit().getImage(imgPath);
}
public void setRichtung(int i){
richtung = i;
}
public void setGeschwindigkeit(double arg){
geschwindigkeit = arg;
}
public void shoot(){
Schuss shot = new Schuss(this, Playground, richtung, geschwindigkeit);
Thread T = new Thread(shot);
T.start();
}
public void steer(char RL){
if(RL == 'l'){
if(richtung ==0){
richtung =15;
}
else{
richtung-=1;
}
}
if(RL == 'r'){
if(richtung==15){
richtung = 0;
}
else{
richtung+=1;
}
}
setImg();
Playground.move(id, false);
}
public void fliegen(){
aktiv = true;
Flug = new Bewegung(this, Playground);
Thread T = new Thread(Flug);
geschwindigkeit=50;
T.start();
}
public void paint(Graphics g){
g.drawImage(bild, 0, 0, this);
}
}