亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? blocks.java

?? 一個JAVA編寫的俄羅斯方塊
?? JAVA
字號:
import java.awt.*;
import java.applet.Applet;

public class Blocks extends Applet implements Runnable
{
  Dimension	d;
  Font 		largefont = new Font("Helvetica", Font.BOLD, 28);
  Font		smallfont = new Font("Helvetica", Font.BOLD, 10);
  Color		textcolor1= new Color(96,128,255);
  Color		textcolor2= new Color(255,160,64);
  FontMetrics	fmsmall, fmlarge;  
  Graphics	goff;
  Image		ii;
  Thread	thethread;
  boolean	ingame=false;
  final short	xblocks=10;
  final short   yblocks=20;
  final int	blocksize=16;
  final int	width=xblocks*blocksize;
  final int	height=yblocks*blocksize;
  short[][]	screendata;
  final short	maxcolors=6;
  Color[]	blocks;
  final int	barwidth=8;
  final Color	barcolor=new Color(128,255,64);
  final Color   background=new Color(0,0,0);
  int		score;
  short		emptyline;
  int		objectx, objecty;
  int		objectdx;
  short		objecttype;
  short		objectcolor;
  int		objectrotation;
  int		objectrotationd=0;
  short		objectptr;
  short		checkptr;
  final short	itemcount=7;
  final short   itemrotlen=8;
  final short	itemlen=itemrotlen*4;
  short 	count;
  final short	maxcount=5;
  short		curcount;
  boolean	fast=false;
  final	short	screendelay=40;
  short		screencount=40;
  boolean	showtitle=true;
  int           items[]={
                          0,0,   -1,0,  0,-1, -1,-1,    // 四方形, 正常狀態
                          0,0,   -1,0,  0,1,  -1,1,     // 被旋轉90度
			  0,0,   1,0,   0,1,   1,1,     // 被旋轉180度
                          0,0,   1,0,   0,-1,  1,-1,    // 被旋轉270度

                          0,0,   0,-1,  0,-2, 0,-3,     // 直線形,正常狀態
                          0,0,  -1,0,  -2,0, -3,0,	// 被旋轉90度
                          0,0,   0,1,   0,2,  0,3, 	// 被旋轉180度
                          0,0,   1,0,   2,0,  3,0,	// 被旋轉270度

			  0,0,   1,0,   0,-1, -1,-1,    // 不規則形1,正常狀態
                          0,0,   0,-1,  -1,0, -1, 1,	// 被旋轉90度
			  0,0,  -1,0,   0,1,  1,1,	// 被旋轉180度
                          0,0,   0,1,   1,0,  1,-1,	// 被旋轉270度

                          0,0,   -1,0,  0,-1,  1,-1,    // 不規則形2,正常狀態
			  0,0,   0,1,   -1,0,  -1,-1,	// 被旋轉90度
			  0,0,   1,0,   0,1,   -1,1,	// 被旋轉180度
			  0,0,   0,-1,  1,0,   1,1,	// 被旋轉270度

			  0,0,   1,0,   -1,0,  0,-1,    // L形1,正常狀態
                          0,0,   0,1,   0,-1,  -1,0,	// 被旋轉90度
			  0,0,   0,1,   -1,0,  1,0,	// 被旋轉180度
			  0,0,   1,0,   0,-1,  0,1,	// 被旋轉270度

			  0,0,   0,-1,  1,-1,  0,1,	// L形1,正常狀態
			  0,0,   -1,0,  -1,-1, 1,0,	// 被旋轉90度
			  0,0,   -1,1,  0,1,   0,-1,	// 被旋轉180度
			  0,0,   -1,0,  1,0,   1,1,	// 被旋轉270度

			  0,0,   0,1,  0,-1,  -1,-1,	// 凸形,正常狀態
			  0,0,   1,0, -1,0,   -1,1,	// 被旋轉90度
			  0,0,   0,-1,  0,1,  1,1,	// 被旋轉180度
			  0,0,   -1,0, 1,0,   1,-1	// 被旋轉270度
                        };

  int           checks[]={ 
                           -1,1, 0,1, -1,1,  0,1,        // check四方形, 正常狀態
                           -1,2, 0,2, -1,2,  0,2,        // check, 被旋轉90度
			   0,2,  1,2,  0,2,  1,2,        // check, 被旋轉180度
                           0,1,  1,1,  0,1,  1,1,        // check, 被旋轉270度

                           0,1,  0,1,  0,1,  0,1,
                           0,1, -1,1, -2,1, -3,1,
                           0,4,  0,4,  0,4,  0,4,        // 直線形
                           0,1,  1,1,  2,1,  3,1,
 
			   0,1,  -1,0, 1,1,  0,1,	// 不規則形1
			   0,1,  -1,2, 0,1, -1,2,
			   0,2,  1,2,  -1,2, 0,2,
			   0,2,  1,1,  0,2,  1,1,

			   -1,1,  0,1, 1,0,  1,0,	// 不規則形2
			   -1,1,  0,2, 0,2,  -1,1,
			   -1,2,  0,2, 1,1,  1,1,
			   0,1,   1,2,  0,1,  1,2,

			   -1,1,  0,1,  1,1, 1,1,	// 凸形
			   -1,1,  0,2,  0,2, -1,1,
			   -1,1,  0,2,  1,1, 1,1,
			   0,2,   1,1,  0,2, 1,1,

			   0,2,   1,0,  1,0, 0,2,	// L形1
			   -1,1,  0,1,  1,1, 1,1,
			   -1,2,  0,2,  0,2, -1,2,
			   -1,1,  0,1,  1,2, 1,2,

			   -1,0,  0,2,  0,2, -1,0,	// L形2
			   -1,2,  0,1,  1,1,  1,1,
			   0,2,   1,2,  1,2,  0,2,
			   -1,1,  0,1,  1,1,  1,1
                         };

  public String getAppletInfo()
  {
    return("Blocks - by Ali");
  }
  //初始化applet
  public void init()
  {
    short i;
    screendata=new short[xblocks][yblocks];
    blocks=new Color[maxcolors+1];
    blocks[0]=background;//設置背景色
    blocks[1]=new Color(255,0,0);//設置方塊顏色
    blocks[2]=new Color(0,255,0);
    blocks[3]=new Color(0,0,255);
    blocks[4]=new Color(255,255,0);
    blocks[5]=new Color(255,0,255);
    blocks[6]=new Color(0,255,255);
    Graphics g;
    resize(width+2*barwidth,height+30);
    d = size();
    setBackground(background);
    g=getGraphics();
    g.setFont(smallfont);
    fmsmall = g.getFontMetrics();
    g.setFont(largefont);
    fmlarge = g.getFontMetrics();
    gameInit();
  }
  //初始化游戲
  public void gameInit()
  {
    short i,j;
    for (i=0; i<xblocks; i++)
    {
      for (j=0; j<yblocks; j++)
      {
        screendata[i][j]=0;
      }
    }
    score=0;
    emptyline=-1;
    newObject();
    fast=false;
    curcount=maxcount;
  }
  
  public void newObject()
  {
    short i;
    int   y;
    objectx=xblocks/2-1;
    objectdx=0;
    objecty=0;
    objecttype=(short)(Math.random()*itemcount);
    if (objecttype>=itemcount)
      objecttype=itemcount-1;
    objectptr=(short)(objecttype*itemlen);
    checkptr=(short)(objecttype*itemlen);
    objectcolor=(short)(Math.random()*maxcolors+1);
    if (objectcolor>maxcolors)
      objectcolor=maxcolors;
    objectrotation=0;
    count=maxcount;
    // 判斷游戲是否結束
    for (i=0; i<4; i++)
    {
      y=items[objectptr+i*2+1];
      if (y>=0 && screendata[objectx+items[objectptr+i*2]][y]!=0)
      {
        ingame=false;
        showtitle=true;
      }
    }
  }
  //判斷鍵盤是否被按下,并且處理事件
  public boolean keyDown(Event e, int key)
  {
    if (ingame)
    {
      if (key == Event.LEFT)
      {
        objectdx=-1;
      }
      else if (key == Event.RIGHT)
      {
        objectdx=1;
      }
      else if (key == Event.UP)
      {
        objectrotationd=1;
      }
      else if (key == Event.DOWN)
      {
        fast=true;
      }
      else if (key == Event.ESCAPE)
      {
        ingame=false;
      }
    }
    else
    {
      if (key == 's' || key == 'S')
      {
        ingame=true;
        gameInit();
      }
    }
    return true;
  }
  //處理鍵盤抬起事件
  public boolean keyUp(Event e, int key)
  {
    if (key == Event.DOWN)
    {
      fast=false;
    }
    return true;
  }
  //paint()方法
  public void paint(Graphics g)
  {
    Graphics gg;
    if (goff==null && d.width>0 && d.height>0)
    {
      ii = createImage(d.width, d.height);
      goff = ii.getGraphics();
    }
    if (goff==null || ii==null)
      return;
    goff.setColor(background);//設置背景色
    goff.fillRect(0, 0, d.width, d.height);
    if (ingame)//如果游戲已經開始
      playGame();//調用playGame()方法
    else//否則,顯示其他信息
      showIntro();//顯示初始信息
      showScore();//顯示得分
    g.drawImage(ii, 0, 0, this);
  }
  //實現游戲
  public void playGame()
  {
    boolean bottomreached=false;
    boolean stillscrolling=false;
    if (emptyline<0)
    {
      bottomreached=drawObject();
    }
    else
    {
      scrollDown();
      stillscrolling=true;
    }
    drawBars();
    drawBlocks();
    if (stillscrolling || bottomreached)
    {
      checkFull();
    }
  }
  //顯示初始信息
  public void showIntro()
  {
    String s;
    drawBars();
    drawBlocks();
    if (showtitle)
    {
      goff.setFont(largefont);
      s="俄羅斯方塊";
      goff.setColor(textcolor1);
      goff.drawString(s,barwidth+(width-fmlarge.stringWidth(s)) / 2 -2, height/2 - 22);
      goff.setColor(Color.white);
      goff.drawString(s,barwidth+(width-fmlarge.stringWidth(s)) / 2, height/2 - 20);

    }
    else
    {
      goff.setFont(smallfont);
      s="請按下'S'鍵開始游戲";
      goff.setColor(textcolor1);
      goff.drawString(s,barwidth+(width-fmsmall.stringWidth(s))/2 -1,height/2 - 31);
      goff.setColor(Color.white);
      goff.drawString(s,barwidth+(width-fmsmall.stringWidth(s))/2,height/2 - 30);
      s="使用左右方向鍵控制運動";
      goff.setColor(textcolor2);
      goff.drawString(s,barwidth+(width-fmsmall.stringWidth(s))/2 -1,height/2 - 11);
      goff.setColor(Color.white);
      goff.drawString(s,barwidth+(width-fmsmall.stringWidth(s))/2,height/2 - 10);
      s="使用向上的方向鍵實現旋轉";
      goff.setColor(textcolor2);
      goff.drawString(s,barwidth+(width-fmsmall.stringWidth(s))/2 -1,height/2 + 9);
      goff.setColor(Color.white);
      goff.drawString(s,barwidth+(width-fmsmall.stringWidth(s))/2,height/2 + 10);
      s="使用向下的方向鍵實現下降";
      goff.setColor(textcolor2);
      goff.drawString(s,barwidth+(width-fmsmall.stringWidth(s))/2 -1,height/2 + 29);
      goff.setColor(Color.white);
      goff.drawString(s,barwidth+(width-fmsmall.stringWidth(s))/2,height/2 + 30);
    }
    screencount--;
    if (screencount<=0)
    { screencount=screendelay; showtitle=!showtitle; }
  }

  public void drawBars()
  {
    goff.setColor(barcolor);
    goff.fillRect(0,0,barwidth,blocksize*yblocks);
    goff.fillRect(barwidth+blocksize*xblocks,0,barwidth,blocksize*yblocks);
    goff.fillRect(0,blocksize*yblocks,xblocks*blocksize+2*barwidth,barwidth);
  }

  public boolean drawObject()
  {
    short	i;
    boolean	bottomreached=false;
    int		x,y,checkx,checky;
    // 清除舊圖形
    for (i=0; i<4; i++)
    {
      x=objectx+items[objectptr+i*2+objectrotation*itemrotlen];
      y=objecty+items[objectptr+i*2+objectrotation*itemrotlen+1];
      checkx=objectx+checks[objectptr+i*2+objectrotation*itemrotlen];
      checky=objecty+checks[objectptr+i*2+objectrotation*itemrotlen+1];
      if (y>=0)
        screendata[x][y]=0;
      if (screendata[checkx][checky]!=0)
        bottomreached=true;
    }
    if (!bottomreached)
    {
      count--;
      if (count<=0 || fast)
      {
        objecty++;
        count=curcount;
      }
      checkRotation();
      objectdx=0;
      objectrotationd=0;
    }
    // 繪制新圖形
    for (i=0; i<4; i++)
    {
      x=objectx+items[objectptr+i*2+objectrotation*itemrotlen];
      y=objecty+items[objectptr+i*2+objectrotation*itemrotlen+1];
      if (y>=0)
        screendata[x][y]=objectcolor;
      if (y>=(yblocks-1))
        bottomreached=true;
    }
    if (bottomreached)
    {
      score++;
      newObject();
    }
    return bottomreached;
  }

  public void checkRotation()
  {
    int		dummyx;
    int		dummyrot;
    int		x,y;
    short	i;
    boolean	cando=true;

    dummyrot=(objectrotation+objectrotationd)%4;
    dummyx=objectx+objectdx;
    // 確認該部分不會使屏幕旋轉
    for (i=0; i<4; i++)
    {
      x=dummyx+items[objectptr+i*2+dummyrot*itemrotlen];
      if (x>=xblocks)
        dummyx-=(x-xblocks+1);
      else if (x<0)
        dummyx-=x;
    }

    for (i=0; (i<4 && cando); i++)
    {
      x=dummyx+items[objectptr+i*2+dummyrot*itemrotlen];
      y=objecty+items[objectptr+i*2+dummyrot*itemrotlen+1];
      if (y>=0)
        cando=cando&&(screendata[x][y]==0);
      if (y>=yblocks || x<0 || x>=xblocks)
        cando=false;
    }
    if (cando)
    {
      objectrotation=dummyrot;
      objectx=dummyx;
    }
  }

  public void drawBlocks()
  {
    short x,y;

    for (x=0; x<xblocks; x++)
    {
      for (y=0; y<yblocks; y++)
      {
        goff.setColor(blocks[screendata[x][y]]);
        goff.drawRect(x*blocksize+barwidth,y*blocksize,blocksize-1,blocksize-1);
        goff.fillRect(x*blocksize+barwidth+3,y*blocksize+3,blocksize-6,blocksize-6);
      }
    }
  }

  public void checkFull()
  {
    short	x,y;
    boolean	found=false;

    for (y=yblocks-1; ( y>=0 && !found); y--)
    {
      found=true;
      for (x=0; x<xblocks; x++)
      {
        if (screendata[x][y]==0)
          found=false;
      }
      if (found)
      {
        score+=10;
	// 當用戶的得分很多時,增加游戲速度
        if (score>800)
          curcount=1;
        else if (score>600)
          curcount=2;
        else if (score>400)
          curcount=3;
        else if (score>200)
          curcount=4;

        for (x=0; x<xblocks; x++)
        {
          screendata[x][y]=0;
        }
        emptyline=y;
      }
    }
  }

  public void scrollDown()
  {
    short x,y;

    for (y=emptyline; y>0; y--)
    {
      for (x=0; x<xblocks; x++)
      {
        screendata[x][y]=screendata[x][y-1];
      }
    }
    for (x=0; x<xblocks; x++)
    {
      screendata[x][0]=0;
    }
    emptyline=-1;
  }

  public void showScore()
  {
    String s;
    goff.setFont(smallfont);
    goff.setColor(Color.white);
    s="得分: "+score;
    goff.drawString(s,width/2-40,(yblocks+1)*blocksize+10);
  }

  public void run()
  {
    long  starttime;
    Graphics g;

    Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
    g=getGraphics();
    while(true)
    {
      starttime=System.currentTimeMillis();
      try
      {
        paint(g);
        starttime += 60;
        Thread.sleep(Math.max(0, starttime-System.currentTimeMillis()));
      }
      catch (InterruptedException e)
      {
        break;
      }
    }
  }

  public void start()
  {
    if (thethread == null) {
      thethread = new Thread(this);
      thethread.start();
    }
  }

  public void stop()
  {
    if (thethread != null) {
      thethread.stop();
      thethread = null;
    }
  }
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲va在线va天堂| 久久久久久久久久久久久女国产乱| 国产一区不卡视频| 奇米影视在线99精品| 蜜臀av性久久久久av蜜臀妖精| 曰韩精品一区二区| 视频一区中文字幕国产| 蜜桃av噜噜一区二区三区小说| 石原莉奈在线亚洲二区| 蜜臀av一区二区| 国产在线视频不卡二| 99热99精品| 337p亚洲精品色噜噜狠狠| 日韩午夜电影av| 欧美韩日一区二区三区四区| 日韩免费视频线观看| 欧美一级二级在线观看| 久久亚洲私人国产精品va媚药| 国产偷v国产偷v亚洲高清| 中文字幕一区二区三区不卡在线| 亚洲一区二区三区在线看| 麻豆中文一区二区| 91亚洲精品一区二区乱码| 在线播放国产精品二区一二区四区| 日韩精品一区二区三区视频播放| 国产精品美女久久久久久久久久久| 亚洲一区二区在线视频| 粉嫩aⅴ一区二区三区四区五区| 日本高清视频一区二区| 久久青草国产手机看片福利盒子 | 日韩三级.com| 亚洲影视资源网| 色欧美片视频在线观看在线视频| 日韩欧美中文一区二区| 一区二区三区在线播放| 成人午夜激情片| 久久精品免视看| 激情综合色综合久久综合| 欧美精品高清视频| 99久久婷婷国产综合精品| 国产精品一区二区在线观看不卡 | 久久你懂得1024| 日本亚洲一区二区| 日韩一级高清毛片| 亚洲电影激情视频网站| 欧美影院午夜播放| 亚瑟在线精品视频| 欧美一区在线视频| 精品一区二区在线播放| 亚洲精品一区二区三区蜜桃下载| 国产乱人伦精品一区二区在线观看| 欧美大度的电影原声| 国产大片一区二区| 中文字幕一区二区三区在线播放 | 亚洲天堂精品在线观看| 9i看片成人免费高清| 亚洲网友自拍偷拍| 日韩精品一区二区三区中文不卡 | 精品伦理精品一区| 国产成人午夜视频| 图片区小说区国产精品视频| 欧美乱妇一区二区三区不卡视频| 午夜精品久久久久久久久| 精品国产一区二区在线观看| 成人免费高清视频| 精品在线你懂的| 亚洲免费电影在线| 精品久久久久久久久久久久久久久久久 | 亚洲愉拍自拍另类高清精品| 日韩一级二级三级| 欧美系列亚洲系列| 99re6这里只有精品视频在线观看| 一区二区三区四区国产精品| 国产亚洲综合av| 精品日韩一区二区三区 | 亚洲午夜影视影院在线观看| 久久免费电影网| 欧美电影免费观看高清完整版在线观看| www.色精品| 99久精品国产| av在线不卡观看免费观看| 国产成人一区二区精品非洲| 免费观看在线综合| 日韩电影免费一区| 日韩国产欧美在线视频| 亚洲国产日韩av| 五月激情综合婷婷| 国产做a爰片久久毛片| 日精品一区二区| 美女视频网站黄色亚洲| 美女视频黄免费的久久 | 久久久噜噜噜久久中文字幕色伊伊 | 欧美性猛交xxxx乱大交退制版| 99在线精品观看| 青青草成人在线观看| 中文字幕一区在线| 国产精品蜜臀在线观看| 国产精品天干天干在观线| 中文字幕一区二区三区四区不卡| 亚洲精品网站在线观看| 亚洲妇女屁股眼交7| 麻豆成人久久精品二区三区小说| 精品一区二区三区免费| 国产98色在线|日韩| 色综合婷婷久久| 日韩三级视频在线观看| 欧美激情一区三区| 亚洲一区二区三区自拍| 国产高清久久久久| 欧美日产在线观看| 中文字幕在线视频一区| 五月天精品一区二区三区| 成人美女视频在线看| 欧美一区二区在线免费观看| 一区在线观看视频| 国产精品自拍在线| 3751色影院一区二区三区| 亚洲精品成人精品456| 国产激情视频一区二区三区欧美| 欧美午夜精品久久久| √…a在线天堂一区| 国产成人av一区二区| 日韩欧美亚洲国产精品字幕久久久| 亚洲欧美另类久久久精品2019| 久久精品免费观看| 欧美日本在线看| 视频一区中文字幕国产| 在线观看亚洲精品| 亚洲va韩国va欧美va精品| 97精品国产97久久久久久久久久久久| 久久久久久久性| 国产精品乡下勾搭老头1| 欧美一区二区精品久久911| 亚洲成av人片一区二区三区| 欧洲中文字幕精品| 亚洲一区二区三区美女| 欧美中文字幕一二三区视频| 亚洲日本成人在线观看| 在线免费观看日本欧美| 亚洲成人av中文| 欧美一级二级在线观看| 国产在线观看一区二区| 日本一二三不卡| 色av成人天堂桃色av| 人人超碰91尤物精品国产| 精品sm在线观看| 99精品久久99久久久久| 亚洲成人精品影院| 亚洲国产电影在线观看| 欧美日韩亚洲高清一区二区| 麻豆视频一区二区| 亚洲欧美日韩国产综合在线| 欧美一区二区三区日韩| 国产a级毛片一区| 午夜一区二区三区视频| 国产欧美一区二区三区网站| 欧美婷婷六月丁香综合色| 国产一区二区免费在线| 亚洲国产欧美在线| 国产精品第五页| 精品国产一区久久| 8x福利精品第一导航| 色久综合一二码| 国产成a人无v码亚洲福利| 日韩激情一二三区| 亚洲人成网站影音先锋播放| 精品粉嫩aⅴ一区二区三区四区| 成人国产精品免费观看视频| 日本v片在线高清不卡在线观看| 国产精品短视频| 国产精品大尺度| 国产精品乱码一区二区三区软件| 日韩欧美专区在线| 日韩欧美国产午夜精品| 3751色影院一区二区三区| 欧美男人的天堂一二区| 欧美群妇大交群中文字幕| 一本久久a久久精品亚洲| 91免费视频网| 一本一本久久a久久精品综合麻豆| 亚洲自拍偷拍九九九| 国产校园另类小说区| 久久亚洲春色中文字幕久久久| 欧美xingq一区二区| 26uuu国产日韩综合| 久久精品一区二区三区不卡牛牛 | 亚洲午夜免费视频| 日本va欧美va瓶| 国产成人综合网| 99久久国产综合精品女不卡| 91国偷自产一区二区开放时间| 欧美日韩亚洲不卡| 欧美变态口味重另类| 中文字幕日韩av资源站| 亚洲一区二区三区视频在线播放| 丝袜美腿亚洲一区| 91在线精品一区二区三区| 91精品国模一区二区三区| 国产欧美日韩精品一区| 日韩制服丝袜av|