import java.awt.BorderLayout;
import java.awt.Button;
import java.awt.Color;
import java.awt.Frame;
import java.awt.Graphics;
import java.awt.Panel;
import java.awt.Point;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.util.List;
public class Test extends Frame implements Runnable,ActionListener
{
/**
*
*/
private static final long serialVersionUID = 8949551757703428621L;
double x1 = 100,y1 = 500;//A的起始位置
double x2 = 100,y2 =500;//B的起始位置
double s2 = 26;//B的水平速度
double g = 9.8;//G
double v1=70;
long time = 10000;//模拟10秒钟
double py = 1;//y轴比例尺
List<Point> list1 = new ArrayList<Point>();
List<Point> list2 = new ArrayList<Point>();
MPanel p1 = new MPanel();
Button b1 = new Button("启动");
Thread t ;
public Test()
{
b1.addActionListener(this);
this.add(b1,BorderLayout.NORTH);
this.add(p1,BorderLayout.CENTER);
this.setSize(800,600);
this.addWindowListener(new WindowAdapter(){ public void windowClosing(WindowEvent e) { System.exit(0); }});
this.setVisible(true);
}
public void run()
{
list1 = new ArrayList<Point>();
list2 = new ArrayList<Point>();
double xx1 = x1,yy1 = y1,xx2 = x2,yy2 = y2;//本时刻位置
long start = System.currentTimeMillis();
long end = start;
while(end-start<=time)
{
end = System.currentTimeMillis();
double t = (end - start)/1000.0;
yy1 = y2- (v1*t - g*t*t/2);
xx2 = x1 +s2*t;
yy2 =y2- (v1*t - g*t*t/2);
int sx1 = (int)xx1;
int sy1 = (int)yy1;
int sx2 = (int)xx2;
import java.awt.Button;
import java.awt.Color;
import java.awt.Frame;
import java.awt.Graphics;
import java.awt.Panel;
import java.awt.Point;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.util.List;
public class Test extends Frame implements Runnable,ActionListener
{
/**
*
*/
private static final long serialVersionUID = 8949551757703428621L;
double x1 = 100,y1 = 500;//A的起始位置
double x2 = 100,y2 =500;//B的起始位置
double s2 = 26;//B的水平速度
double g = 9.8;//G
double v1=70;
long time = 10000;//模拟10秒钟
double py = 1;//y轴比例尺
List<Point> list1 = new ArrayList<Point>();
List<Point> list2 = new ArrayList<Point>();
MPanel p1 = new MPanel();
Button b1 = new Button("启动");
Thread t ;
public Test()
{
b1.addActionListener(this);
this.add(b1,BorderLayout.NORTH);
this.add(p1,BorderLayout.CENTER);
this.setSize(800,600);
this.addWindowListener(new WindowAdapter(){ public void windowClosing(WindowEvent e) { System.exit(0); }});
this.setVisible(true);
}
public void run()
{
list1 = new ArrayList<Point>();
list2 = new ArrayList<Point>();
double xx1 = x1,yy1 = y1,xx2 = x2,yy2 = y2;//本时刻位置
long start = System.currentTimeMillis();
long end = start;
while(end-start<=time)
{
end = System.currentTimeMillis();
double t = (end - start)/1000.0;
yy1 = y2- (v1*t - g*t*t/2);
xx2 = x1 +s2*t;
yy2 =y2- (v1*t - g*t*t/2);
int sx1 = (int)xx1;
int sy1 = (int)yy1;
int sx2 = (int)xx2;