| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 510 人关注过本帖
标题:一段代码编译问题,请大家看看!关于赛车游戏
只看楼主 加入收藏
Timgise
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2012-3-8
收藏
 问题点数:0 回复次数:1 
一段代码编译问题,请大家看看!关于赛车游戏
import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;
public class G1P2 extends JFrame{
    final int WIDTH=900,HEIGTH=650;
    double p1Speed= .5,p2Speed= .5;

    Rectangle left=new Rectangle(0,0,WIDTH/9,HEIGHT);

    Rectangle right=new Rectangle((WIDTH/9)*8,0,WIDTH/9,HEIGHT);

    Rectangle top=new Rectangle(0,0,WIDTH,HEIGHT);

    Rectangle bottom=new Rectangle(0,(HEIGHT/9)*8,(HEIGHT/9)*9,HEIGHT/9);

    Rectangle center=new Rectangle((int)((WIDTH/9)*2.5),(int)((HEIGHT/9)*2.5),(int)((WIDTH/9)*5),(HEIGHT/9)*4);

    Rectangle obstacle=new Rectangle(WIDTH/2,(int)(HEIGHT/9)*7,WIDTH/10,HEIGHT/9);

    Rectangle obstacle2=new Rectangle(WIDTH/3,(int)(HEIGHT/9)*5,WIDTH/10,HEIGHT/4);

    Rectangle obstacle3=new Rectangle((WIDTH/3)*2,(int)(HEIGHT/9)*5,WIDTH/10,HEIGHT/4);

    Rectangle obstacle4=new Rectangle(WIDTH/3,HEIGHT/9,WIDTH/30,HEIGHT/9);

    Rectangle obstacle5=new Rectangle(WIDTH/2,(int)((HEIGHT/9)*1.5),WIDTH/30,HEIGHT/4);

    Rectangle finish=new Rectangle(WIDTH/9,(HEIGHT/2)-HEIGHT/9,(int)((WIDTH/9)*1.5),HEIGHT/70);

    Rectangle p1=new Rectangle(WIDTH/9,HEIGHT/2,WIDTH/30,WIDTH/30);

    Rectangle p2=new Rectangle(((WIDTH/9)+((int)(WIDTH/9*1.5)/2)),(HEIGHT/2)+(HEIGHT/10),WIDTH/30,WIDTH/30);

    public G1P2(){

         super("Radical Racing");

         setSize(WIDTH,HEIGHT);

         setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

         setVisible(true);

         Move1 m1 = new Move1();

         Move2 m2 = new Move2();

         m1.start();

         m2.start();
         }

     public void paint(Graphics g){

        super.paint(g);

        g.setColor(Color.DARK_GRAY);
        g.fillRect(0,0,WIDTH,HEIGHT);
        g.setColor(Color.GREEN);

        Rectangle lineO = new Rectangle(WIDTH/9,HEIGHT/2,(int)((WIDTH/9)*1.5)/2,HEIGHT/140);
        Rectangle lineI = new Rectangle(((WIDTH/9)+((int)((WIDTH/9)*1.5)/2)),(HEIGHT/2)+(HEIGHT/10),(int)((WIDTH/9)*1.5)/2,HEIGHT/140);

        g.fillRect(left.x,left.y,left.width,left.height);
        g.fillRect(right.x,right.y,right.width,right.height);
        g.fillRect(top.x,top.y,top.width,top.height);
        g.fillRect(bottom.x,bottom.y,bottom.width,bottom.height);
        g.fillRect(center.x,center.y,center.width,center.height);
        g.fillRect(obstacle.x,obstacle.y,obstacle.width,obstacle.height);
        g.fillRect(obstacle2.x,obstacle2.y,obstacle2.width,obstacle2.height);
        g.fillRect(obstacle3.x,obstacle3.y,obstacle3.width,obstacle3.height);
        g.fillRect(obstacle4.x,obstacle4.y,obstacle4.width,obstacle4.height);
        g.fillRect(obstacle5.x,obstacle5.y,obstacle5.width,obstacle5.height);

        g.setColor(Color.WHITE);
        g.fillRect(lineO.x,lineO.y,lineO.width,lineO.height);
        g.fillRect(lineI.x,lineI.y,lineI.width,lineI.height);
        g.setColor(Color.YELLOW);
        g.fillRect(finish.x,finish.y,finish.width,finish.height);
        g.setColor(Color.BLUE);
        g.fill3DRect(p1.x,p1.y,p1.width,p1.height,true);
        g.setColor(Color.RED);
        g.fill3DRect(p2.x,p2.y,p2.width,p2.height,true);
        }

       public class Movel extends Thread{

            public void run(){

             while(true){

                 try{

                      repaint();

                      if(p1Speed<=5){

                          p1Speed+= .2;
                          }
                       p1.y-=p1Speed;
                       Thread.sleep(75);

                      }catch(Exception e){

                          break;

                     }
                  }
               }
           }
        public class Move2 extends Thread{

             public void run(){

               while(true){

                   try{

                         repaint();
                         if(p2Speed<=5){
                            p2Speed+=2;
                            }
                            p2.y-=p2Speed;
                            Thread.sleep(75);

                            }catch(Exception e){

                               break;
                              }
                        }
                  }
          }
          public static void main(String[] args){

               new G1P2();
              }
          }
编译结果:
D:\test\FTP\G1P2.java:45: 找不到符号
符号: 类 Move1
位置: 类 G1P2
         Move1 m1 = new Move1();
         ^
D:\test\FTP\G1P2.java:45: 找不到符号
符号: 类 Move1
位置: 类 G1P2
         Move1 m1 = new Move1();
                        ^
2 错误

Tool completed with exit code 1
搜索更多相关主题的帖子: 赛车游戏 public bottom 
2012-03-22 15:05
布林一角
Rank: 1
来 自:安徽
等 级:新手上路
帖 子:7
专家分:0
注 册:2012-2-19
收藏
得分:0 
public class Movel extends Thread 中的 Movel 写错了! 应该是Move1 ,最后一个字母你写成L了。
2012-04-03 00:50
快速回复:一段代码编译问题,请大家看看!关于赛车游戏
数据加载中...
 
   



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

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