我现在实现了小球撞墙,要想实现小球在运动过程中把运动轨迹画出来应该怎么修改代码?求高手解答,以下是现在的代码importjava.awt.*;publicclassMyTest3{publicstaticvoidmain(Strin...
我现在实现了小球撞墙,要想实现小球在运动过程中把运动轨迹画出来应该怎么修改代码?求高手解答,以下是现在的代码
import java.awt.*;
public class MyTest3 {
public static void main(String[] args) {
Frame w = new Frame();
w.setSize(300, 400);
MyPanel mp = new MyPanel();
w.add(mp);
Thread t = new Thread(mp);
t.start();
w.show();
}
}
class MyPanel extends Panel implements Runnable {
int x = 30;
int y = 30;
int att = 1;
public void paint(Graphics g) {
g.fillOval(x, y, 30, 30);
}
public void run() {
while(true) {
//定义小球飞行姿态
if(att == 1) {
x +