/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package spiel; import java.awt.Component; import javax.swing.JLabel; import javax.swing.Timer; /** * * @author 0wg3viol */ public class Schuss extends Thread { //Attribute public int startPositionX; public int startPositionY; private Component bullet; private JLabel spielfigur; private int oben; //Konstruktor public Schuss(Component bullet, JLabel spielfigur, int oben) { this.bullet = bullet; this.spielfigur = spielfigur; this.oben = oben; } public void run() { bullet.setVisible(true); int bulletX = bullet.getX(); int bulletY = bullet.getY(); int spielfigurX = spielfigur.getX(); int spielfigurY = spielfigur.getY(); bullet.setLocation(spielfigurX, spielfigurY + 50); for (int i = spielfigurY; i >= this.oben; i = i - 10) { bullet.setLocation(spielfigurX, i); try { sleep(50); } catch (InterruptedException tz) { } } } }