| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 493 人关注过本帖
标题:现金回谢!请帮忙
只看楼主 加入收藏
lokasdfjkl
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2010-5-29
结帖率:0
收藏
 问题点数:0 回复次数:2 
现金回谢!请帮忙
必须在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);
    }
}
搜索更多相关主题的帖子: 现金 
2010-05-29 21:58
zzg123
Rank: 1
等 级:新手上路
帖 子:39
专家分:7
注 册:2009-3-1
收藏
得分:0 
1随机走:随机生成敌人坦克的四个方向 direct=(int)(Math.random()*4),然后使用线程实现敌人坦克的自由移动。
2当游戏一开始就自动走:初始化随机走时所写的线程。
3十字走法(意思是上,下,左,右,的走,而不能斜着走):直接x++,x--,y++,y--即可。
任何游戏里的东西都不得越界线:根据敌人坦克的坐标和你panel的坐标做限制,比如你的panel的大学是(400,300),如果敌人坦克的横坐标<400,即可以继续向右走。
2010-05-31 08:33
chenyu329134
Rank: 2
等 级:论坛游民
帖 子:36
专家分:21
注 册:2010-9-17
收藏
得分:0 
早自己做过这个游戏  比你需要的功能还强点吧。还可以八个方向走,八个方向开炮!
2010-09-17 12:53
快速回复:现金回谢!请帮忙
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.011638 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved