Добавил:
nyan
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:Александр Б. / Основы Java / Labs / src / Lab7 / Game
.java package Lab7;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Random;
import javax.imageio.ImageIO;
import javax.swing.*;
public class Game extends Thread {
public ActionListener onFinish;
private int delay, speed, angle, x, y, H;
private JLabel comp;
double G = 9.8;
public Game(int delayTime, int startingSpeed, int tiltAngle, int X, int Y, JLabel component, int HEIGHT) {
delay = delayTime;
speed = startingSpeed;
angle = tiltAngle;
x = X; y = Y;
comp = component;
H = HEIGHT;
}
public void run() {
try {
double[] params = {100, x, y, speed, angle}; // Анонимный объект:
BodyFlight bf = new BodyFlight(params);
for(int i =0; i < bf.val.size(); i++) {
int x = bf.val.get(i).valueX;
int y = bf.val.get(i).valueY;
comp.setLocation(x, H - y - comp.getHeight());
//System.out.println(bf.val.get(i).valueX + " " + bf.val.get(i).valueY);
sleep(delay);
}
if (onFinish != null) {
ActionEvent ev = new ActionEvent(comp,new Random().nextInt(),"");
onFinish.actionPerformed(ev);
}
//MyShooting.form.stopFlight(comp);
} catch (InterruptedException e) {
//comp.setVisible(false);
return;
}
}
}
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Random;
import javax.imageio.ImageIO;
import javax.swing.*;
public class Game extends Thread {
public ActionListener onFinish;
private int delay, speed, angle, x, y, H;
private JLabel comp;
double G = 9.8;
public Game(int delayTime, int startingSpeed, int tiltAngle, int X, int Y, JLabel component, int HEIGHT) {
delay = delayTime;
speed = startingSpeed;
angle = tiltAngle;
x = X; y = Y;
comp = component;
H = HEIGHT;
}
public void run() {
try {
double[] params = {100, x, y, speed, angle}; // Анонимный объект:
BodyFlight bf = new BodyFlight(params);
for(int i =0; i < bf.val.size(); i++) {
int x = bf.val.get(i).valueX;
int y = bf.val.get(i).valueY;
comp.setLocation(x, H - y - comp.getHeight());
//System.out.println(bf.val.get(i).valueX + " " + bf.val.get(i).valueY);
sleep(delay);
}
if (onFinish != null) {
ActionEvent ev = new ActionEvent(comp,new Random().nextInt(),"");
onFinish.actionPerformed(ev);
}
//MyShooting.form.stopFlight(comp);
} catch (InterruptedException e) {
//comp.setVisible(false);
return;
}
}
}
Соседние файлы в папке Lab7