您现在的位置是:首页» 软件教程» assertvalid,assertvalid什么意思

assertvalid,assertvalid什么意思

2024-04-12 03:16:29
今天小编为大家分享Windows系统下载、Windows系统教程、windows相关应用程序的文章,希望能够帮助到大家! 上面这位仁兄的代码我调可很长时间才调好,做事情真不负责任,既然要贴出来就应该是拿来就能用的。哎!!我把改好的给你public class ERS_Block extends Frame

今天小编为大家分享Windows系统下载、Windows系统教程、windows相关应用程序的文章,希望能够帮助到大家!

上面这位仁兄的代码我调可很长时间才调好,做事情真不负责任,既然要贴出来就应该是拿来就能用的。哎!!我把改好的给你

public class ERS_Block extends Frame{

public static boolean isPlay=false;

public static int level=1,score=0;

public static TextField scoreField,levelField;

public static void main(String[] argus){

ERS_Block ers= new ERS_Block("俄罗斯方块游戏 V1.0 Author:Vincent");

WindowListener win_listener= new WinListener();

ers.addWindowListener(win_listener);

setLayout(new GridLayout(1,2));

gameScr.addKeyListener(gameScr);

rightScr.setLayout(new GridLayout(2,1,0,30));

MyPanel infoScr= new MyPanel();

infoScr.setLayout(new GridLayout(4,1,0,5));

Label scorep= new Label("分数:",Label.LEFT);

Label levelp= new Label("级数:",Label.LEFT);

scoreField.setEditable(false);

levelField.setEditable(false);

scorep.setSize(new Dimension(20,60));

scoreField.setSize(new Dimension(20,60));

levelp.setSize(new Dimension(20,60));

levelField.setSize(new Dimension(20,60));

MyPanel controlScr= new MyPanel();

controlScr.setLayout(new GridLayout(5,1,0,5));

Button play_b= new Button("开始游戏");

play_b.setSize(new Dimension(50,200));

play_b.addActionListener(new Command(Command.button_play,gameScr));

Button level_up_b= new Button("提高级数");

level_up_b.setSize(new Dimension(50,200));

level_up_b.addActionListener(new Command(Command.button_levelup,gameScr));

Button level_down_b=new Button("降低级数");

level_down_b.setSize(new Dimension(50,200));

level_down_b.addActionListener(new Command(Command.button_leveldown,gameScr));

Button pause_b=new Button("游戏暂停");

pause_b.setSize(new Dimension(50,200));

pause_b.addActionListener(new Command(Command.button_pause,gameScr));

Button quit_b= new Button("退出游戏");

quit_b.setSize(new Dimension(50,200));

quit_b.addActionListener(new Command(Command.button_quit,gameScr));

//重写MyPanel类,使Panel的四周留空间

return new Insets(30,50,30,50);

class GameCanvas extends Canvas implements KeyListener{

final int unitSize= 30;//小方块边长

int maxAllowRowNum;//允许有多少行未削

int blockInitRow;//新出现块的起始行坐标

int blockInitCol;//新出现块的起始列坐标

//初始化屏幕,并将屏幕数组清零的方法

for(int j=0; j<columnNum;j++)

public void paint(Graphics g){

for(int i= 0; i< rowNum; i++)

for(int j= 0; j< columnNum; j++)

public void drawUnit(int row,int col,int type){

switch(type){//表示画方快的方法

case 0: g.setColor(Color.black);break;//以背景为颜色画

case 1: g.setColor(Color.blue);break;//画正在下落的方块

case 2: g.setColor(Color.magenta);break;//画已经落下的方法

g.fill3DRect(col*unitSize,getSize().height-(row+1)*unitSize,unitSize,unitSize,true);

return b;//返回block实例的引用

//返回屏幕数组中(row,col)位置的属性值

public int getScrArrXY(int row,int col){

if(row< 0|| row>= rowNum|| col< 0|| col>= columnNum)

return(blockInitRow);//返回新块的初始行坐标

return(blockInitCol);//返回新块的初始列坐标

L1:for(int j=0;j<columnNum;j++)

for(int j= 0; j< columnNum; j++){

for(int i= k-1;i< rowNum; i++){

for(int j= 0; j< columnNum; j++){

ERS_Block.score+= full_line_num;

ERS_Block.scoreField.setText(""+ERS_Block.score);

for(int col= 0; col<columnNum; col++){

if(scrArr[maxAllowRowNum][col]!=0)

public void keyTyped(KeyEvent e){

public void keyReleased(KeyEvent e){

public void keyPressed(KeyEvent e){

case KeyEvent.VK_DOWN:b.fallDown();break;

case KeyEvent.VK_LEFT:b.leftMove();break;

case KeyEvent.VK_RIGHT:b.rightMove();break;

case KeyEvent.VK_SPACE:b.leftTurn();break;

class Command implements ActionListener{

static final int button_play= 1;//给按钮分配编号

static final int button_levelup= 2;

static final int button_leveldown= 3;

static final int button_quit= 4;

static final int button_pause= 5;

static boolean pause_resume= true;

Command(int button,GameCanvas scr){

public void actionPerformed(ActionEvent e){

case button_play:if(!ERS_Block.isPlay){

ERS_Block.scoreField.setText("0");

case button_levelup:if(ERS_Block.level< 10){

ERS_Block.levelField.setText(""+ERS_Block.level);

ERS_Block.scoreField.setText(""+ERS_Block.score);

case button_leveldown:if(ERS_Block.level> 1){

ERS_Block.levelField.setText(""+ERS_Block.level);

ERS_Block.scoreField.setText(""+ERS_Block.score);

case button_pause:if(pause_resume){

case button_quit:System.exit(0);

{0x0f00,0x4444,0x0f00,0x4444},//用十六进至表示,本行表示长条四种状态

{0x04e0,0x0464,0x00e4,0x04c4},

{0x4620,0x6c00,0x4620,0x6c00},

{0x2640,0xc600,0x2640,0xc600},

{0x6220,0x1700,0x2230,0x0740},

{0x6440,0x0e20,0x44c0,0x8e00},

int blockType;//块的模式号(0-6)

int turnState;//块的翻转状态(0-3)

int row,col;//块在画布上的坐标

blockType=(int)(Math.random()* 1000)%7;

turnState=(int)(Math.random()* 1000)%4;

blockType=(int)(Math.random()* 1000)%7;

turnState=(int)(Math.random()* 1000)%4;

if(assertValid(blockType,(turnState+ 1)%4,row,col)){

if(assertValid(blockType,turnState,row,col-1)){

if(assertValid(blockType,turnState,row,col+1)){

if(assertValid(blockType,turnState,row-1,col)){

boolean assertValid(int t,int s,int row,int col){

if((int)(pattern[t][s]&k)!= 0){

int temp= scr.getScrArrXY(row-i,col+j);

public synchronized void dispBlock(int s){

if(((int)pattern[blockType][turnState]&k)!= 0){

public MyTimer(GameCanvas scr){

sleep((10-ERS_Block.level+ 1)*100);

catch(InterruptedException e){}

if(!scr.getBlock().fallDown()){

class WinListener extends WindowAdapter{

public void windowClosing(WindowEvent l){

public class ERS_Block extends Frame{

public static boolean isPlay=false;

public static int level=1,score=0;

public static TextField scoreField,levelField;

public static void main(String[] argus){

ERS_Block ers= new ERS_Block("俄罗斯方块游戏 V1.0 Author:Vincent");

WindowListener win_listener= new WinListener();

ers.addWindowListener(win_listener);

setLayout(new GridLayout(1,2));

gameScr.addKeyListener(gameScr);

rightScr.setLayout(new GridLayout(2,1,0,30));

MyPanel infoScr= new MyPanel();

infoScr.setLayout(new GridLayout(4,1,0,5));

Label scorep= new Label("分数:",Label.LEFT);

Label levelp= new Label("级数:",Label.LEFT);

Label namep= new Label("姓名:张三",Label.LEFT);

Label nump= new Label("学号:110821332",Label.LEFT);

scoreField= new TextField(8);

levelField= new TextField(8);

scoreField.setEditable(false);

levelField.setEditable(false);

scorep.setSize(new Dimension(20,60));

scoreField.setSize(new Dimension(20,60));

levelp.setSize(new Dimension(20,60));

levelField.setSize(new Dimension(20,60));

MyPanel controlScr= new MyPanel();

controlScr.setLayout(new GridLayout(5,1,0,5));

Button play_b= new Button("开始游戏");

play_b.setSize(new Dimension(50,200));

play_b.addActionListener(new Command(Command.button_play,gameScr));

Button level_up_b= new Button("提高级数");

level_up_b.setSize(new Dimension(50,200));

level_up_b.addActionListener(new Command(Command.button_levelup,gameScr));

Button level_down_b=new Button("降低级数");

level_down_b.setSize(new Dimension(50,200));

level_down_b.addActionListener(new Command(Command.button_leveldown,gameScr));

Button pause_b=new Button("游戏暂停");

pause_b.setSize(new Dimension(50,200));

pause_b.addActionListener(new Command(Command.button_pause,gameScr));

Button quit_b= new Button("退出游戏");

quit_b.setSize(new Dimension(50,200));

quit_b.addActionListener(new Command(Command.button_quit,gameScr));

controlScr.add(level_down_b);

//重写MyPanel类,使Panel的四周留空间

return new Insets(30,50,30,50);

class GameCanvas extends Canvas implements KeyListener{

final int unitSize= 30;//小方块边长

int maxAllowRowNum;//允许有多少行未削

int blockInitRow;//新出现块的起始行坐标

int blockInitCol;//新出现块的起始列坐标

blockInitCol= columnNum/2- 2;

//初始化屏幕,并将屏幕数组清零的方法

for(int j=0; j<columnNum;j++)

public void paint(Graphics g){

for(int i= 0; i< rowNum; i++)

for(int j= 0; j< columnNum; j++)

public void drawUnit(int row,int col,int type){

switch(type){//表示画方快的方法

case 0: g.setColor(Color.black);break;//以背景为颜色画

case 1: g.setColor(Color.blue);break;//画正在下落的方块

case 2: g.setColor(Color.magenta);break;//画已经落下的方法

g.fill3DRect(col*unitSize,getSize().height-(row+1)*unitSize,unitSize,unitSize,true);

return b;//返回block实例的引用

//返回屏幕数组中(row,col)位置的属性值

public int getScrArrXY(int row,int col){

if(row< 0|| row>= rowNum|| col< 0|| col>= columnNum)

return(blockInitRow);//返回新块的初始行坐标

return(blockInitCol);//返回新块的初始列坐标

for(int i=0;i<rowNum;i++){

L1:for(int j=0;j<columnNum;j++)

for(int j= 0; j< columnNum; j++){

scrArr[k-1][j]= scrArr[i][j];

for(int i= k-1;i< rowNum; i++){

for(int j= 0; j< columnNum; j++){

ERS_Block.score+= full_line_num;

ERS_Block.scoreField.setText(""+ERS_Block.score);

for(int col= 0; col<columnNum; col++){

if(scrArr[maxAllowRowNum][col]!=0)

public void keyTyped(KeyEvent e){

public void keyReleased(KeyEvent e){

public void keyPressed(KeyEvent e){

case KeyEvent.VK_DOWN:b.fallDown();break;

case KeyEvent.VK_LEFT:b.leftMove();break;

case KeyEvent.VK_RIGHT:b.rightMove();break;

case KeyEvent.VK_SPACE:b.leftTurn();break;

class Command implements ActionListener{

static final int button_play= 1;//给按钮分配编号

static final int button_levelup= 2;

static final int button_leveldown= 3;

static final int button_quit= 4;

static final int button_pause= 5;

static boolean pause_resume= true;

Command(int button,GameCanvas scr){

public void actionPerformed(ActionEvent e){

case button_play:if(!ERS_Block.isPlay){

ERS_Block.scoreField.setText("0");

case button_levelup:if(ERS_Block.level< 10){

ERS_Block.levelField.setText(""+ERS_Block.level);

ERS_Block.scoreField.setText(""+ERS_Block.score);

case button_leveldown:if(ERS_Block.level> 1){

ERS_Block.levelField.setText(""+ERS_Block.level);

ERS_Block.scoreField.setText(""+ERS_Block.score);

case button_pause:if(pause_resume){

case button_quit:System.exit(0);

{0x0f00,0x4444,0x0f00,0x4444},//用十六进至表示,本行表示长条四种状态

{0x04e0,0x0464,0x00e4,0x04c4},

{0x4620,0x6c00,0x4620,0x6c00},

{0x2640,0xc600,0x2640,0xc600},

{0x6220,0x1700,0x2230,0x0740},

{0x6440,0x0e20,0x44c0,0x8e00},

int blockType;//块的模式号(0-6)

int turnState;//块的翻转状态(0-3)

int blockState;//快的下落状态

int row,col;//块在画布上的坐标

blockType=(int)(Math.random()* 1000)%7;

turnState=(int)(Math.random()* 1000)%4;

blockType=(int)(Math.random()* 1000)%7;

turnState=(int)(Math.random()* 1000)%4;

if(assertValid(blockType,(turnState+ 1)%4,row,col)){

if(assertValid(blockType,turnState,row,col-1)){

if(assertValid(blockType,turnState,row,col+1)){

if(assertValid(blockType,turnState,row-1,col)){

boolean assertValid(int t,int s,int row,int col){

if((int)(pattern[t][s]&k)!= 0){

int temp= scr.getScrArrXY(row-i,col+j);

public synchronized void dispBlock(int s){

if(((int)pattern[blockType][turnState]&k)!= 0){

public MyTimer(GameCanvas scr){

sleep((10-ERS_Block.level+ 1)*100);

catch(InterruptedException e){}

if(!scr.getBlock().fallDown()){

class WinListener extends WindowAdapter{

public void windowClosing(WindowEvent l){

wwW.Xtw.Com.cN系统网专业的PC、手机系统开发下载平台,HarmonyOS系统、安卓、OS、windows电脑重装系统在线下载安装,操作系统平台技术学习,攻略教程,技术交流。

免责声明:本文中引用的各种信息及资料(包括但不限于文字、数据、图表及超链接等)均来源于该信息及资料的相关主体(包括但不限于公司、媒体、协会等机构)的官方网站或公开发表的信息。内容仅供参考使用,不准确地方联系删除处理!

联系邮箱:773537036@qq.com