⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cdanceui.java

📁 网上收集的
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
package chiidanceapp;


import java.awt.Graphics;
import java.awt.Image;
import java.awt.Panel;
import javax.swing.JPanel;
import java.awt.Font;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.util.ResourceBundle;


public class CDanceUI implements Runnable{
/////////////////////////////////////////////////////////////////////////////////////////////

  private byte LoadCount;
  private byte ReadyCount;
  private byte MessageCount;
  private int PoseIndex;
  private int xUpArrow    = 20,
              yUpArrow    = 50;
  private int xDownArrow  = 80,
              yDownArrow  = 50;
  private int xLeftArrow  = 140,
              yLeftArrow  = 50;
  private int xRightArrow = 200,
              yRightArrow = 50;


  private int yMoveUpArrow,
              yMoveUpArrow2;
  private int yMoveDownArrow,
              yMoveDownArrow2;
  private int yMoveLeftArrow,
              yMoveLeftArrow2;
  private int yMoveRightArrow,
              yMoveRightArrow2;

  private int Interval        = 1000;
  private int Act             = 1;
  private int Score           = 0;
  private int ScoreCounter    = 0;
  private int Hits            = 0;
  private int HitsCounter     = 0;
  private int TimeCounter     = 0;
  private int Total           = 0;
  private int TotalCounter    = 0;
  private int Level           = 1;
  private int NameIndex       = 2;
  private int MenuIndex       = 0;

  private int xLoad           = 0;
  private int xPalm           = 310;
  private int yPalm           = 255;
  private int xTime           = 407;//407
  private int xLife           = 0;


  private int rUpMove;
  private int rDownMove;
  private int rLeftMove;
  private int rRightMove;
  private int rCloseEyes;
  private int rFight;

  private String MenuItem[]  = {
   "回到游戏",
   "重新开始",
   "回到主标题",
   "退出游戏"
  } ;

  private boolean isPaint            = true;
  private boolean isUpArrowHit       = false;
  private boolean isDownArrowHit     = false;
  private boolean isLeftArrowHit     = false;
  private boolean isRightArrowHit    = false;
  private boolean isNormalPose       = true;

  private boolean isLoaded           = false;
  private boolean isHit              = false;
  private boolean showUpHit          = false;
  private boolean showDownHit        = false;
  private boolean showLeftHit        = false;
  private boolean showRightHit       = false;
  private boolean canRun             = true;
  private boolean isGaming           = false;
  private boolean isMenuVisible      = false;
  private boolean isShowReadyMessage = false;
  private boolean isPalmFront        = true;
  private boolean isTimeOut          = false;
  private boolean isShowMessage      = false;
  private boolean isFinished         = false;
  private boolean isReach            = false;
  private boolean isActRushed        = false;
  private boolean isImageLoaded      = false;

  //######################################################################################

  private Image UpArrow1;
  private Image UpArrow2;
  private Image DownArrow1;
  private Image DownArrow2;
  private Image LeftArrow1;
  private Image LeftArrow2;
  private Image RightArrow1;
  private Image RightArrow2;


  private Image MoveUpArrow;
  private Image MoveDownArrow;
  private Image MoveLeftArrow;
  private Image MoveRightArrow;

  //######################################################################################

  private Image NormalPose;
  private Image ChiiUp;
  private Image ChiiDown;
  private Image ChiiLeft;
  private Image ChiiRight;
  private Image SumomoUp;
  private Image SumomoDown;
  private Image SumomoLeft;
  private Image SumomoRight;


  private Image MenuFrame;
  private Image TimeFrame;
  private Image PortraitFrame;
  private Image Palm;
  private Image Stick;
  private Image ReadyImage;
  private Image ActIcon;
  private Image Number[] = new Image[3];
  private Image Ready;
  private Image Go;
  private Image RecordPanel;
  private Image NextAct;


  private Image Chii;
  private Image Freya;
  private Image Aiangel_OpenEyes;
  private Image Aiangel_CloseEyes;
  private Image YourPortrait;

  private Image Pause;
  private Image Qface;
  private Image Shader;//暂停用图片


//#######################################################################################
  private Image LoadingImage;
  private Image Stage;

  private Thread GameThread;

  CImage initImage = new CImage();

  CMidiThread MidiThread;
/////////////////////////////////////////////////////////////////////////////////////////
//#######################################################################################
  public CDanceUI() {
    canRun             = true;
    isGaming           = false;
    isShowReadyMessage = true;

    LoadCount          = 0;
    ReadyCount         = 0;
    MessageCount       = 0;

    yMoveUpArrow    = -50;
    yMoveDownArrow  = -50;
    yMoveLeftArrow  = -50;
    yMoveRightArrow = -50;

    yMoveUpArrow2    = -50;
    yMoveDownArrow2  = -50;
    yMoveLeftArrow2  = -50;
    yMoveRightArrow2 = -50;

    GameThread   = new Thread( this );
    GameThread.start();

    LoadingImage       = initImage.LoadImage( "Resource/img/g23.jpg" );
  }

  public CDanceUI( int Act,int NameIndex,int Score ) {

    this.Act           = Act;
    this.NameIndex     = NameIndex;
    this.Score         = Score;

    LoadingImage       = initImage.LoadImage( "Resource/img/g23.jpg" );
    TimeFrame          = initImage.LoadImage( "Resource/images/timeframe.png" );
    Stick              = initImage.LoadImage( "Resource/img/stick.gif" );

    canRun             = true;
    isGaming           = false;
    isShowReadyMessage = true;
    isReach            = false;

    LoadCount          = 0;
    ReadyCount         = 0;
    MessageCount       = 0;

    yMoveUpArrow       = -50;
    yMoveDownArrow     = -50;
    yMoveLeftArrow     = -50;
    yMoveRightArrow    = -50;

    yMoveUpArrow2      = -50;
    yMoveDownArrow2    = -50;
    yMoveLeftArrow2    = -50;
    yMoveRightArrow2   = -50;

    GameThread         = new Thread( this );
    GameThread.start();
  }
//#######################################################################################
/////////////////////////////////////////////////////////////////////////////////////////
  public boolean isLoaded()
  {
    return this.isLoaded;
  }


  public boolean getIsHit()
  {
    return this.isHit;
  }

  public int getMenuIndex()
  {
    return this.MenuIndex;
  }

  public int getNameIndex()
  {
    return this.NameIndex;
  }

  public boolean getIsGaming()
  {
    return this.isGaming;
  }

  public boolean isFinished()
  {
    return this.isFinished;
  }

  public boolean isReach()
  {
    return this.isReach;
  }

  public int getAct()
  {
    return this.Act;
  }

  public boolean getIsUpArrowHit()
  {
    return this.isUpArrowHit;
  }

  public boolean getIsDownArrowHit()
  {
    return this.isDownArrowHit;
  }

  public boolean getIsLeftArrowHit()
  {
    return this.isLeftArrowHit;
  }

  public boolean getIsRightArrowHit()
  {
    return this.isRightArrowHit;
  }

  public int getScore()
  {
    return this.Total;
  }

  public boolean isShowReadyMessage()
  {
    return isShowReadyMessage;
  }
  ///////////////////////////////////////////////////////////////////////////////////////////////
  public int getLevel()
  {
    return Level;
  }
  //////////////////////////////////////////////////////////////////////////////////////////////
  public boolean getActRusned()
  {
    return this.isActRushed;
  }
  ////////////////////////////////////////////////////////////////////////////////////////////////
  public void IsHit()
  {
    if( yMoveUpArrow >= yUpArrow && yMoveUpArrow < ( yUpArrow+13 ) )
    {
      this.isUpArrowHit = true;
    }
    else if( yMoveDownArrow >= yDownArrow  && yMoveDownArrow < ( yDownArrow+13 ) )
    {
      this.isDownArrowHit = true;
    }
    else if( yMoveLeftArrow >= yLeftArrow  && yMoveLeftArrow < ( yLeftArrow+13 ) )
    {
      this.isLeftArrowHit = true;
    }
    else if( yMoveRightArrow >= yRightArrow && yMoveRightArrow < ( yRightArrow+13 ) )
    {
      this.isRightArrowHit = true;
    }
    else if( yMoveUpArrow2 >= yUpArrow && yMoveUpArrow2 < ( yUpArrow+13 ) )
    {
      this.isUpArrowHit = true;
    }
    else if( yMoveDownArrow2 >= yDownArrow  && yMoveDownArrow2 < ( yDownArrow+13 ) )
    {
      this.isDownArrowHit = true;
    }
    else if( yMoveLeftArrow2 >= yLeftArrow  && yMoveLeftArrow2 < ( yLeftArrow+13 ) )
    {
      this.isLeftArrowHit = true;
    }
    else if( yMoveRightArrow2 >= yRightArrow && yMoveRightArrow2 < ( yRightArrow+13 ) )
    {
      this.isRightArrowHit = true;
    }
    else
    {
      setDefault();
    }
  }

  public boolean getIsMenuVisible( )
  {
    return isMenuVisible;
  }

  public boolean isTimeOut()
  {
    return this.isTimeOut;
  }

  public void setPoseIndex( int PoseIndex )
  {
    this.PoseIndex = PoseIndex;
  }

//#######################################################################################################
  public void addMenuIndex()
  {
    if( MenuIndex < 3 )
       MenuIndex++;
  }

  public void subMenuIndex()
  {
    if( MenuIndex > 0 )
       MenuIndex --;
  }

  public void setTime()
  {
    this.xTime = 407;
  }

  public void setAct( int Act )
  {
    this.Act = Act;
  }

  public void setDefault()
  {
    isUpArrowHit    = false;
    isDownArrowHit  = false;
    isLeftArrowHit  = false;
    isRightArrowHit = false;
  }

  /////////////////////////////////////////////////////////////////////////////////////////////////
  public void setDefaultLocation()
  {
    this.yMoveUpArrow    = -60;
    this.yMoveDownArrow  = -60;
    this.yMoveLeftArrow  = -60;
    this.yMoveRightArrow = -60;

    this.yMoveUpArrow2    = -60;
    this.yMoveDownArrow2  = -60;
    this.yMoveLeftArrow2  = -60;
    this.yMoveRightArrow2 = -60;

  }

  public void setNameIndex( int NameIndex )
  {
    this.NameIndex = NameIndex;
  }

  public void setMenuVisible( boolean isMenuVisible )
  {
    this.isMenuVisible = isMenuVisible;
  }

  public void setShowReadyVisible( boolean isShowReadyMessage )
  {
    this.isShowReadyMessage = isShowReadyMessage;

    if( isShowReadyMessage == true )
    {
      MessageCount = 0;
    }
  }

  public void setRunnable( boolean canRun )
  {
    this.canRun = canRun;

  }

  public void setIsGaming( boolean isGaming )
  {
    this.isGaming = isGaming;
    setDefaultLocation();
  }

  public void showUpHit()
  {
    this.showUpHit = true;
  }

  public void showDownHit()
  {
    this.showDownHit = true;
  }

  public void showLeftHit()
  {
    this.showLeftHit = true;
  }

  public void showRightHit()
  {
    this.showRightHit = true;
  }

  public void addScore()
  {
    Score += 10;
    Hits  ++;
  }

  public void addLife()
  {
    xLife++;
  }
//##########################################################################################
////////////////////////////////////////////////////////////////////////////////////////////
  public void Load()
  {
    switch( Act )
    {
      case 1:
       Stage          = initImage.LoadImage( "Resource/images/bg_1.jpg" );
       break;
      case 2:
       Stage          = initImage.LoadImage( "Resource/images/bg_2.jpg" );
       break;
      case 3:
       Stage          = initImage.LoadImage( "Resource/images/bg_3.jpg" );
       break;
      case 4:
       Stage          = initImage.LoadImage( "Resource/images/bg_4.jpg" );
       break;
      case 5:
       Stage          = initImage.LoadImage( "Resource/images/bg_5.jpg" );
       break;
    };xLoad += 10;

    UpArrow1       = initImage.LoadImage( "Resource/images/up.jpg" );xLoad += 10;
    UpArrow2       = initImage.LoadImage( "Resource/images/up_press.jpg" );xLoad += 10;
    DownArrow1     = initImage.LoadImage( "Resource/images/down.jpg" );xLoad += 10;
    DownArrow2     = initImage.LoadImage( "Resource/images/down_press.jpg" );xLoad += 10;
    LeftArrow1     = initImage.LoadImage( "Resource/images/left.jpg" );xLoad += 10;
    LeftArrow2     = initImage.LoadImage( "Resource/images/left_press.jpg" );xLoad += 10;
    RightArrow1    = initImage.LoadImage( "Resource/images/right.jpg" );xLoad += 10;
    RightArrow2    = initImage.LoadImage( "Resource/images/right_press.jpg" );xLoad += 10;

    MoveUpArrow    = initImage.LoadImage( "Resource/images/uparrow.png" );xLoad += 10;
    MoveDownArrow  = initImage.LoadImage( "Resource/images/downarrow.png" );xLoad += 10;
    MoveLeftArrow  = initImage.LoadImage( "Resource/images/leftarrow.png" );xLoad += 10;
    MoveRightArrow = initImage.LoadImage( "Resource/images/rightarrow.png" );xLoad += 10;

    SumomoUp       = initImage.LoadImage( "Resource/images/sumomoup.jpg" );xLoad += 10;
    SumomoDown     = initImage.LoadImage( "Resource/images/sumomodown.jpg" );xLoad += 10;
    SumomoLeft     = initImage.LoadImage( "Resource/images/sumomoleft.jpg" );xLoad += 10;
    SumomoRight    = initImage.LoadImage( "Resource/images/sumomoright.jpg" );xLoad += 10;
    NormalPose     = initImage.LoadImage( "Resource/images/normal.jpg" );xLoad += 10;
    ChiiUp         = initImage.LoadImage( "Resource/images/chiiup.jpg" );xLoad += 10;
    ChiiDown       = initImage.LoadImage( "Resource/images/chiidown2.jpg" );xLoad += 10;
    ChiiLeft       = initImage.LoadImage( "Resource/images/chiileft2.jpg" );xLoad += 10;
    ChiiRight      = initImage.LoadImage( "Resource/images/chiiright2.jpg" );xLoad += 10;

    MenuFrame      = initImage.LoadImage( "Resource/images/diologframe.png" );xLoad += 10;

    PortraitFrame  = initImage.LoadImage( "Resource/images/frame.png" );xLoad += 10;
    Palm           = initImage.LoadImage( "Resource/img/arrow.png" );xLoad += 10;

    ReadyImage     = initImage.LoadImage( "Resource/images/Gameover.GIF" );xLoad += 10;
    ActIcon        = initImage.LoadImage( "Resource/images/continue.png" );xLoad += 10;
    Number[ 0 ]    = initImage.LoadImage( "Resource/img/1.png" );xLoad += 10;
    Number[ 1 ]    = initImage.LoadImage( "Resource/img/2.png" );xLoad += 10;
    Number[ 2 ]    = initImage.LoadImage( "Resource/img/3.png" );xLoad += 10;
    RecordPanel    = initImage.LoadImage( "Resource/img/RecordPanel.png" );xLoad += 10;
    NextAct        = initImage.LoadImage( "Resource/img/nextact.png" );xLoad += 10;

    Ready          = initImage.LoadImage( "Resource/img/ready.png" );xLoad += 10;
    Go             = initImage.LoadImage( "Resource/img/go.png" );

    Chii              = initImage.LoadImage( "Resource/images/chii.gif" );
    Freya             = initImage.LoadImage( "Resource/images/freya.gif" );
    Aiangel_CloseEyes = initImage.LoadImage( "Resource/images/p_closeeyes.png" );

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -