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

📄 infointerface.java

📁 一个用JAVA APPLET编写的俄罗斯方块游戏.俄螺丝方块这个游戏不用多介绍了吧
💻 JAVA
字号:
package russion;import java.awt.*;/** * <p>Title: RussionCube</p> * <p>Description: TheClassicGame</p> * <p>Copyright: Copyright (c) 2002</p> * <p>Company: Cqu</p> * @author Ghostliang * @version 1.0 */public class InfoInterface{  private Cube nextCube;  private int startX,startY,height;  private int level,score,delRows,baseLevel;  private Color backGround,frontGround;  public InfoInterface(Cube nextCube)  {    this(260,20,400,nextCube,Color.white,Color.black,1);  }  public InfoInterface(int startX,int startY,int height,Cube nextCube,Color backGround,Color frontGround,int baseLevel)  {    this.startX = startX;    this.startY = startY;    this.height = height;    this.nextCube = nextCube;    this.backGround = backGround;    this.frontGround = frontGround;    this.score = 0;    this.baseLevel = baseLevel;    this.level = baseLevel + this.score / 2000;    this.delRows = 0;  }  public int getStartX()  {    return this.startX;  }  public int getStartY()  {    return this.startY;  }  public int getHeight()  {    return this.height;  }  public void setNextCube(Cube nextCube)  {    this.nextCube = nextCube;  }  public void setBackGround(Color color)  {    this.backGround = color;  }  public Color getBackGround(Color color)  {    return backGround;  }  public void setFrontGround(Color color)  {    this.frontGround = color;  }  public Color getFrontGround()  {    return frontGround;  }  public int getLevel()  {    return this.level;  }  public void clear()  {    this.level = baseLevel;    this.score = 0;    this.delRows = 0;  }  public void update(int rows)  {    switch(rows)    {      case 0:        score += 10;        break;      case 1:        score += 100;        break;      case 2:        score += 300;        break;      case 3:        score += 600;        break;      case 4:        score += 1000;        break;      default:        break;    }    delRows += rows;    level = baseLevel + score/2000;  }  public int getEvent(int x,int y)  {    int event;    int width;    width = 40 + 4 * nextCube.getBlockSize();    if(width < 120)      width = 120;    if(x > startX + 20 + (width - 80) / 2 &&       x < startX + 20 + (width - 80) / 2 + 80&&       y > startY + 20 + 4 * nextCube.getBlockSize() + 140 &&       y < startY + 20 + 4 * nextCube.getBlockSize() + 160)      event = 1;    else if(x > startX + 20 + (width - 80) / 2 &&       x < startX + 20 + (width - 80) / 2 + 80&&       y > startY + 20 + 4 * nextCube.getBlockSize() + 170 &&       y < startY + 20 + 4 * nextCube.getBlockSize() + 190)      event = 2;    else if(x > startX + 20 + (width - 80) / 2 &&       x < startX + 20 + (width - 80) / 2 + 80&&       y > startY + 20 + 4 * nextCube.getBlockSize() + 200 &&       y < startY + 20 + 4 * nextCube.getBlockSize() + 220)      event = 3;    else      event = 0;    return event;  }  public void paint(Graphics g)  {    Position now;    g.translate(startX,startY);    if(height < 40 + 3 * nextCube.getBlockSize() + 230)      height = 40 + 3 * nextCube.getBlockSize() + 230;    int width;    width = 40 + 4 * nextCube.getBlockSize();    if(width < 120)      width = 120;    g.setColor(Color.black);    g.drawRect(0,0,width,height);    g.setColor(frontGround);    g.drawString("Next:",(width - 4 * nextCube.getBlockSize()) / 2,16);    g.setColor(frontGround);    g.drawRect((width - 4 * nextCube.getBlockSize()) / 2,20,4 * nextCube.getBlockSize(),4 * nextCube.getBlockSize());    g.setColor(backGround);    g.fillRect((width - 4 * nextCube.getBlockSize()) / 2 + 1,20 + 1,4 * nextCube.getBlockSize() - 1,4 * nextCube.getBlockSize() - 1);    g.translate((width - 4 * nextCube.getBlockSize()) / 2,20 + nextCube.getBlockSize());    nextCube.paint(g);    g.translate(-(width - 4 * nextCube.getBlockSize()) / 2,-20 - nextCube.getBlockSize());    g.setColor(frontGround);    g.drawString("等级:" + this.level,(width - 80) / 2 + 20,20 + 4 * nextCube.getBlockSize() + 20 + 16);    g.drawString("分数:" + this.score,(width - 80) / 2 + 20,20 + 4 * nextCube.getBlockSize() + 60 + 16);    g.drawString("行数:" + this.delRows,(width - 80) / 2 + 20,20 + 4 * nextCube.getBlockSize() + 100 + 16);    g.drawRect((width - 80) / 2,20 + 4 * nextCube.getBlockSize() + 140,80,20);    g.drawString("开始",(width - 80) / 2 + 28,20 + 4 * nextCube.getBlockSize() + 140 + 14);    g.drawRect((width - 80) / 2,20 + 4 * nextCube.getBlockSize() + 170,80,20);    g.drawString("暂停",(width - 80) / 2 + 28,20 + 4 * nextCube.getBlockSize() + 170 + 14);    g.drawRect((width - 80) / 2,20 + 4 * nextCube.getBlockSize() + 200,80,20);    g.drawString("重新开始",(width - 80) / 2 + 20,20 + 4 * nextCube.getBlockSize() + 200 + 14);    g.translate(-startX,-startY);  }  public void repaint(Graphics g)  {    g.translate(startX,startY);    int width;    width = 40 + 4 * nextCube.getBlockSize();    if(width < 120)      width = 120;    g.setColor(backGround);    g.fillRect((width - 4 * nextCube.getBlockSize()) / 2 + 1,20 + 1,4 * nextCube.getBlockSize() - 1,4 * nextCube.getBlockSize() - 1);    g.translate((width - 4 * nextCube.getBlockSize()) / 2,20 + nextCube.getBlockSize());    nextCube.paint(g);    g.translate(-(width - 4 * nextCube.getBlockSize()) / 2,-20 - nextCube.getBlockSize());    g.setColor(backGround);    g.fillRect((width - 80) / 2 + 20,20 + 4 * nextCube.getBlockSize() + 20,80,100);    g.setColor(frontGround);    g.drawString("等级:" + this.level,(width - 80) / 2 + 20,20 + 4 * nextCube.getBlockSize() + 20 + 16);    g.drawString("分数:" + this.score,(width - 80) / 2 + 20,20 + 4 * nextCube.getBlockSize() + 60 + 16);    g.drawString("行数:" + this.delRows,(width - 80) / 2 + 20,20 + 4 * nextCube.getBlockSize() + 100 + 16);    g.translate(-startX,-startY);  }}

⌨️ 快捷键说明

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