现金回谢!请帮忙
必须在6月1号前解决!(6月1号交这作业)本人在做一个类似于小时候玩的"坦克大战"的小游戏,
我的问题是
1,我想设置敌方的所有坦克(10辆)所走的路线有这样的规律:
1,随机走
2,当游戏一开始就自动走
3,十字走法(意思是上,下,左,右,的走,而不能斜着走)
2,我要设置一个边框,就等于是游戏界面的边框,任何游戏里的东西都不得越界线,
而且当敌方坦克走到界面尽头(就是碰到边框的时候),会自动调头或者左右转方向走.
因为是要交到学校算学分的,
所以请高手说的详细点,或者+498569708QQ说
能帮我解决了问题的话,我会付酬劳,但是不多(100-200RMB)绝不食言!
如果还能交到朋友就更好.
以下是学校给我们的3个JAVA文件,
学过的人看了会知道我们大概学到什么范围
所以不要太深入的方法来做,只用最基础的
谢谢.
-----------------------
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class MyJPanel extends JPanel {
public MyJPanel() {
}
public void paintComponent(Graphics g){
super.paintComponent(g);
}
}
----------------
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class MyJFrame extends JFrame {
public MyJFrame(String title, int x, int y, int width, int height) {
// Set the title, top left location, and close operation for the frame
setTitle(title);
setLocation(x, y);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// Create an instance of the JPanel class, and set this to define the
// content of the window
JPanel frameContent = new MyJPanel();
Container visibleArea = getContentPane();
visibleArea.add(frameContent);
// Set the size of the content pane of the window, resize and validate the
// window to suit, obtain keyboard focus, and then make the window visible
frameContent.setPreferredSize(new Dimension(width, height));
pack();
frameContent.requestFocusInWindow();
setVisible(true);
}
}
--------
/*
The application class for the CompSci 101 graphical user interface
The constructor for the MyJFrame object takes the following parameters:
- a title
- the x position of the top corner of the window
- the y position of the top corner of the window
- the width of the content pane of the window
- the height of the content pane of the window
*/
public class MyApp {
public static void main(String[] args) {
MyJFrame gui = new MyJFrame("My GUI", 0, 0, 800, 600);
}
}