俄罗斯方块游戏制作

创建包和文件夹

1.创建小方块类

package eluosifangkuai;
import java.awt.image.BufferedImage;
import java.util.Objects;/*** @author xiaoZhao* @date 2022/5/7* @describe*  小方块类*   方法: 左移、右移、下落*/
public class Cell {// 行private int row;// 列private int col;private BufferedImage image;public Cell() {}public Cell(int row, int col, BufferedImage image) {this.row = row;this.col = col;this.image = image;}public int getRow() {return row;}public void setRow(int row) {this.row = row;}public int getCol() {return col;}public void setCol(int col) {this.col = col;}public BufferedImage getImage() {return image;}public void setImage(BufferedImage image) {this.image = image;}@Overridepublic String toString() {return "Cell{" +"row=" + row +", col=" + col +", image=" + image +'}';}@Overridepublic boolean equals(Object o) {if (this == o) {return true;}if (!(o instanceof Cell)) {return false;}Cell cell = (Cell) o;return getRow() == cell.getRow() &&getCol() == cell.getCol() &&Objects.equals(getImage(), cell.getImage());}@Overridepublic int hashCode() {return Objects.hash(getRow(), getCol(), getImage());}//左移动一格public void left(){col--;}//右移动一格public void right(){col++;}//下移动一格public void down(){row++;}
}

2.编写四方格父类

package eluosifangkuai;import xingzhuang.*;/*** @author xiaoZhao* @date 2022/5/11* @describe 编写四方格父类*/
public class Tetromino {public Cell[] cells = new Cell[4];//旋转的状态protected State[] states;//声明旋转次数protected int count = 10000;//左移方法public void moveLeft() {for (Cell cell : cells) {cell.left();}}//右移方法public void moveRight() {for (Cell cell : cells) {cell.right();}}//单元格下落public void moveDrop() {for (Cell cell : cells) {cell.down();}}//编写随机生成四方格public static Tetromino randomOne() {int num = (int) (Math.random() * 7);Tetromino tetromino = null;switch (num) {case 0:tetromino = new I();break;case 1:tetromino = new J();break;case 2:tetromino = new L();break;case 3:tetromino = new O();break;case 4:tetromino = new S();break;case 5:tetromino = new T();break;case 6:tetromino = new Z();break;}return tetromino;}//顺时针旋转的方法public void rotateRight() {if (states.length == 0) {return;}//旋转次数+1count++;State s = states[count % states.length];Cell cell = cells[0];int row = cell.getRow();int col = cell.getCol();cells[1].setRow(row + s.row1);cells[1].setCol(col + s.col1);cells[2].setRow(row + s.row2);cells[2].setCol(col + s.col2);cells[3].setRow(row + s.row3);cells[3].setCol(col + s.col3);}//逆时针旋转的方法public void rotateLeft() {if (states.length == 0) {return;}//旋转次数+1count--;State s = states[count % states.length];Cell cell = cells[0];int row = cell.getRow();int col = cell.getCol();cells[1].setRow(row + s.row1);cells[1].setCol(col + s.col1);cells[2].setRow(row + s.row2);cells[2].setCol(col + s.col2);cells[3].setRow(row + s.row3);cells[3].setCol(col + s.col3);}//四方格旋转状态的内部类protected class State {//存储四方格各元素的位置int row0, col0, row1, col1, row2, col2, row3, col3;public State() {}public State(int row0, int col0, int row1, int col1, int row2, int col2, int row3, int col3) {this.row0 = row0;this.col0 = col0;this.row1 = row1;this.col1 = col1;this.row2 = row2;this.col2 = col2;this.row3 = row3;this.col3 = col3;}public int getRow0() {return row0;}public void setRow0(int row0) {this.row0 = row0;}public int getCol0() {return col0;}public void setCol0(int col0) {this.col0 = col0;}public int getRow1() {return row1;}public void setRow1(int row1) {this.row1 = row1;}public int getCol1() {return col1;}public void setCol1(int col1) {this.col1 = col1;}public int getRow2() {return row2;}public void setRow2(int row2) {this.row2 = row2;}public int getCol2() {return col2;}public void setCol2(int col2) {this.col2 = col2;}public int getRow3() {return row3;}public void setRow3(int row3) {this.row3 = row3;}public int getCol3() {return col3;}public void setCol3(int col3) {this.col3 = col3;}@Overridepublic String toString() {return "State{" +"row0=" + row0 +", col0=" + col0 +", row1=" + row1 +", col1=" + col1 +", row2=" + row2 +", col2=" + col2 +", row3=" + row3 +", col3=" + col3 +'}';}}
}

3.编写字母

package xingzhuang;import sifang.Tetris;
import eluosifangkuai.Cell;
import eluosifangkuai.Tetromino;public class I extends Tetromino {public I() {cells[0] = new Cell(0,4, Tetris.I);cells[1] = new Cell(0,3, Tetris.I);cells[2] = new Cell(0,5, Tetris.I);cells[3] = new Cell(0,6, Tetris.I);//共有两种旋转状态states =new State[2];//初始化两种状态的相对坐标states[0]=new State(0,0,0,-1,0,1,0,2);states[1]=new State(0,0,-1,0,1,0,2,0);}}
package xingzhuang;import sifang.Tetris;
import eluosifangkuai.Cell;
import eluosifangkuai.Tetromino;public class J extends Tetromino {public J() {cells[0] = new Cell(0,4, Tetris.J);cells[1] = new Cell(0,3, Tetris.J);cells[2] = new Cell(0,5, Tetris.J);cells[3] = new Cell(1,5, Tetris.J);states=new State[4];states[0]=new State(0,0,0,-1,0,1,1,1);states[1]=new State(0,0,-1,0,1,0,1,-1);states[2]=new State(0,0,0,1,0,-1,-1,-1);states[3]=new State(0,0,1,0,-1,0,-1,1);}
}
package xingzhuang;import sifang.Tetris;
import eluosifangkuai.Cell;
import eluosifangkuai.Tetromino;public class L extends Tetromino {public L() {cells[0] = new Cell(0,4, Tetris.L);cells[1] = new Cell(0,3, Tetris.L);cells[2] = new Cell(0,5, Tetris.L);cells[3] = new Cell(1,3, Tetris.L);states=new State[4];states[0]=new State(0,0,0,-1,0,1,1,-1);states[1]=new State(0,0,-1,0,1,0,-1,-1);states[2]=new State(0,0,0,1,0,-1,-1,1);states[3]=new State(0,0,1,0,-1,0,1,1);}
}
package xingzhuang;import sifang.Tetris;
import eluosifangkuai.Cell;
import eluosifangkuai.Tetromino;public class O extends Tetromino {public O() {cells[0] = new Cell(0, 4, Tetris.O);cells[1] = new Cell(0, 5, Tetris.O);cells[2] = new Cell(1, 4, Tetris.O);cells[3] = new Cell(1, 5, Tetris.O);//无旋转状态states = new State[0];}
}
package xingzhuang;import sifang.Tetris;
import eluosifangkuai.Cell;
import eluosifangkuai.Tetromino;public class S extends Tetromino {public S() {cells[0] = new Cell(0,4, Tetris.S);cells[1] = new Cell(0,5, Tetris.S);cells[2] = new Cell(1,3, Tetris.S);cells[3] = new Cell(1,4, Tetris.S);//共有两种旋转状态states =new State[2];//初始化两种状态的相对坐标states[0]=new State(0,0,0,1,1,-1,1,0);states[1]=new State(0,0,1,0,-1,-1,0,-1);}
}
package xingzhuang;import sifang.Tetris;
import eluosifangkuai.Cell;
import eluosifangkuai.Tetromino;public class T extends Tetromino {public T() {cells[0] = new Cell(0,4, Tetris.T);cells[1] = new Cell(0,3, Tetris.T);cells[2] = new Cell(0,5, Tetris.T);cells[3] = new Cell(1,4, Tetris.T);states=new State[4];states[0]=new State(0,0,0,-1,0,1,1,0);states[1]=new State(0,0,-1,0,1,0,0,-1);states[2]=new State(0,0,0,1,0,-1,-1,0);states[3]=new State(0,0,1,0,-1,0,0,1);}
}
package xingzhuang;
import sifang.Tetris;
import eluosifangkuai.Cell;
import eluosifangkuai.Tetromino;public class Z extends Tetromino {public Z() {cells[0] = new Cell(1,4, Tetris.Z);cells[1] = new Cell(0,3, Tetris.Z);cells[2] = new Cell(0,4, Tetris.Z);cells[3] = new Cell(1,5, Tetris.Z);//共有两种旋转状态states =new State[2];//初始化两种状态的相对坐标states[0]=new State(0,0,-1,-1,-1,0,0,1);states[1]=new State(0,0,-1,1,0,1,1,0);}
}

4.游戏运行主类

package sifang;
import eluosifangkuai.Cell;
import eluosifangkuai.Tetromino;import javax.imageio.ImageIO;
import javax.swing.*;
import java.awt.*;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.security.cert.Certificate;public class Tetris extends JPanel {//正在下落的方块private Tetromino currentOne = Tetromino.randomOne();//将要下落的方块private Tetromino nextOne = Tetromino.randomOne();//游戏主区域private Cell[][] wall = new Cell[18][9];//声明单元格的值private static final int CELL_SIZE = 48;//游戏分数池int[] scores_pool = {0, 1, 2, 5, 10};//当前游戏的分数private int totalScore = 0;//当前消除的行数private int totalLine = 0;//游戏三种状态 游戏中、暂停、结束public static final int PLING = 0;public static final int STOP = 1;public static final int OVER = 2;//当前游戏状态值private int game_state;//显示游戏状态String[] show_state = {"P[pause]", "C[continue]", "S[replay]"};//载入方块图片public static BufferedImage I;public static BufferedImage J;public static BufferedImage L;public static BufferedImage O;public static BufferedImage S;public static BufferedImage T;public static BufferedImage Z;public static BufferedImage background;static {try {I = ImageIO.read(new File("images/I.png"));J = ImageIO.read(new File("images/J.png"));L = ImageIO.read(new File("images/L.png"));O = ImageIO.read(new File("images/O.png"));S = ImageIO.read(new File("images/S.png"));T = ImageIO.read(new File("images/T.png"));Z = ImageIO.read(new File("images/Z.png"));background = ImageIO.read(new File("images/background.png"));} catch (IOException e) {e.printStackTrace();}}@Overridepublic void paint(Graphics g) {g.drawImage(background, 0, 0, null);//平移坐标轴g.translate(22, 15);//绘制游戏主区域paintWall(g);//绘制正在下落的四方格paintCurrentOne(g);//绘制下一个将要下落的四方格paintNextOne(g);//绘制游戏得分paintSource(g);//绘制当前游戏状态paintState(g);}public void start() {game_state = PLING;KeyListener l = new KeyAdapter() {@Overridepublic void keyPressed(KeyEvent e) {int code = e.getKeyCode();switch (code) {case KeyEvent.VK_DOWN:sortDropActive();break;case KeyEvent.VK_LEFT:moveleftActive();break;case KeyEvent.VK_RIGHT:moveRightActive();break;case KeyEvent.VK_UP:rotateRightActive();break;case KeyEvent.VK_SPACE:hadnDropActive();break;case KeyEvent.VK_P://判断当前游戏状态if (game_state == PLING) {game_state = STOP;}break;case KeyEvent.VK_C:if (game_state == STOP) {game_state = PLING;}break;case KeyEvent.VK_S://重新开始game_state = PLING;wall = new Cell[18][9];currentOne = Tetromino.randomOne();nextOne = Tetromino.randomOne();totalScore = 0;totalLine = 0;break;}}};//将窗口设置为焦点this.addKeyListener(l);this.requestFocus();while (true) {if (game_state == PLING) {try {Thread.sleep(500);} catch (InterruptedException e) {e.printStackTrace();}if (camDrop()) {currentOne.moveDrop();} else {landToWall();destroyLine();if (isGameOver()) {game_state = OVER;} else {//游戏没有结束currentOne = nextOne;nextOne = Tetromino.randomOne();}}}repaint();}}//创建顺时针旋转public void rotateRightActive() {currentOne.rotateRight();if (outOFBounds() || coincide()) {currentOne.rotateLeft();}}//瞬间下落public void hadnDropActive() {while (true) {//判断能否下落if (camDrop()) {currentOne.moveDrop();} else {break;}}//嵌入到墙中landToWall();destroyLine();if (isGameOver()) {game_state = OVER;} else {//游戏没有结束currentOne = nextOne;nextOne = Tetromino.randomOne();}}//按键一次,下落一格public void sortDropActive() {if (camDrop()) {//当前四方格下落一格currentOne.moveDrop();} else {landToWall();destroyLine();if (isGameOver()) {game_state = OVER;} else {//游戏没有结束currentOne = nextOne;nextOne = Tetromino.randomOne();}}}//单元格嵌入墙中private void landToWall() {Cell[] cells = currentOne.cells;for (Cell cell : cells) {int row = cell.getRow();int col = cell.getCol();wall[row][col] = cell;}}//判断四方格能否下落public boolean camDrop() {Cell[] cells = currentOne.cells;for (Cell cell : cells) {int row = cell.getRow();int col = cell.getCol();//判断是否到达底部if (row == wall.length - 1) {return false;} else if (wall[row + 1][col] != null) {return false;}}return true;}//消除行public void destroyLine() {int line = 0;Cell[] cells = currentOne.cells;for (Cell cell : cells) {int row = cell.getRow();if (isFullLine(row)) {line++;for (int i = row; i > 0; i--) {System.arraycopy(wall[i - 1], 0, wall[i], 0, wall[0].length);}wall[0] = new Cell[9];}}//分数池获取分数,累加到总分totalScore += scores_pool[line];//总行数totalLine += line;}//判断当前行是否已经满了public boolean isFullLine(int row) {Cell[] cells = wall[row];for (Cell cell : cells) {if (cell == null) {return false;}}return true;}//判断游戏是否结束public boolean isGameOver() {Cell[] cells = nextOne.cells;for (Cell cell : cells) {int row = cell.getRow();int col = cell.getCol();if (wall[row][col] != null) {return true;}}return false;}private void paintState(Graphics g) {if (game_state == PLING) {g.drawString(show_state[PLING], 500, 660);} else if (game_state == STOP) {g.drawString(show_state[STOP], 500, 660);} else {g.drawString(show_state[OVER], 500, 660);g.setColor(Color.RED);g.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 60));g.drawString("GAME OVER!", 30, 400);}}private void paintSource(Graphics g) {g.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 30));g.drawString("分数: " + totalScore, 500, 250);g.drawString("行数: " + totalLine, 500, 430);}private void paintNextOne(Graphics g) {Cell[] cells = nextOne.cells;for (Cell cell : cells) {int x = cell.getCol() * CELL_SIZE + 370;int y = cell.getRow() * CELL_SIZE + 25;g.drawImage(cell.getImage(), x, y, null);}}private void paintCurrentOne(Graphics g) {Cell[] cells = currentOne.cells;for (Cell cell : cells) {int x = cell.getCol() * CELL_SIZE;int y = cell.getRow() * CELL_SIZE;g.drawImage(cell.getImage(), x, y, null);}}private void paintWall(Graphics g) {for (int i = 0; i < wall.length; i++) {for (int j = 0; j < wall[i].length; j++) {int x = j * CELL_SIZE;int y = i * CELL_SIZE;Cell cell = wall[i][j];//判断是否有小方块if (cell == null) {g.drawRect(x, y, CELL_SIZE, CELL_SIZE);} else {g.drawImage(cell.getImage(), x, y, null);}}}}//判断是否出界public boolean outOFBounds() {Cell[] cells = currentOne.cells;for (Cell cell : cells) {int col = cell.getCol();int row = cell.getRow();if (row < 0 || row > wall.length - 1 || col < 0 || col > wall[0].length-1) {return true;}}return false;}//按键一次,左移一次public void moveleftActive() {currentOne.moveLeft();//判断是否越界或重合if (outOFBounds() || coincide()) {currentOne.moveRight();}}//按键一次,右移一次public void moveRightActive() {currentOne.moveRight();//判断是否越界或重合if (outOFBounds() || coincide()) {currentOne.moveLeft();}}//判断是否重合public boolean coincide() {Cell[] cells = currentOne.cells;for (Cell cell : cells) {int row = cell.getRow();int col = cell.getCol();if (wall[row][col] != null) {return true;}}return false;}public static void main(String[] args) {JFrame jFrame = new JFrame("俄罗斯方块");//创建游戏界面Tetris panel = new Tetris();jFrame.add(panel);//设置可见jFrame.setVisible(true);//设置窗口大小jFrame.setSize(810, 940);//设置剧中jFrame.setLocationRelativeTo(null);//设置窗口关闭时停止jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//游戏主要开始逻辑panel.start();}
}

运行结果

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/152607.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

猫12分类:使用多线程爬取图片的Python程序

本文目标 对于猫12目标检测部分的数据集&#xff0c;采用网络爬虫来制作数据集。 在网络爬虫中&#xff0c;经常需要下载大量的图片。为了提高下载效率&#xff0c;可以使用多线程来并发地下载图片。本文将介绍如何使用Python编写一个多线程爬虫程序&#xff0c;用于爬取图片…

小黑子的SSM整合

SSM整合 一、基于restful页面数据交互1.1 后台接口开发1.2 页面访问处理 二、ssm整合2.1 流程分析2.2 整合配置2.3 功能模块开发2.4 接口测试2.5 表现层与前端数据传输协议定义2.5.1 协议实现 2.6 异常处理器2.6.1 RestControllerAdvice2.6.2 ExceptionHandler2.6.3 项目异常处…

.Net6 Api Swagger配置

1、定义个Swagger版本&#xff08;组&#xff09;的枚举 namespace WebApp.Enums {/// <summary>/// api版本枚举/// </summary>public enum ApiVersion{/// <summary>/// v1版本/// </summary>v1 1,/// <summary>/// v2版本/// </summary&…

内存学习(4):内存分类与常用概念3(ROM)

1 ROM介绍 ROM即为只读存储器&#xff0c;全拼是Read Only Memory。 1.1 “只读”的由来 ROM叫只读存储器是因为最早的ROM&#xff08;MROM&#xff09;确实是只能读取不能写入&#xff0c;一旦出厂不能再写&#xff0c;需要在出厂之前预设好它的数据&#xff0c;并且它是掉…

十四、Docker的基本操作

目录 &#xff08;一&#xff09;镜像命令 一、拉取Nginx 二、查看镜像 三、导出文件 四、删除镜像 五、加载镜像 &#xff08;二&#xff09;容器命令 一、例子&#xff1a;运行一个nginx容器 1、输入运行命令 2、使用命令查看宿主机ip 3、在外部浏览器访问 4、查看…

【机器学习】037_暂退法

一、实现原理 具有输入噪音的训练&#xff0c;等价于Tikhonov正则化 核心方法&#xff1a;在前向传播的过程中&#xff0c;计算每一内部层的同时注入噪声 从作用上来看&#xff0c;表面上来说是在训练过程中丢弃一些神经元 假设x是某一层神经网络层的输出&#xff0c;是下一…

【机器学习】036_权重衰退

一、范数 定义&#xff1a;向量的范数表示一个向量有多大&#xff08;分量的大小&#xff09; L1范数&#xff1a; 即向量元素绝对值之和&#xff0c;用符号 ‖ v ‖ 1 表示。 公式&#xff1a; L2范数&#xff1a; 即向量的模&#xff0c;向量各元素绝对值的平方之和再…

适合您的智能手机的 7 款优秀手机数据恢复软件分享

如今&#xff0c;我们做什么都用手机&#xff1b;从拍照到录音&#xff0c;甚至作为 MP3 播放器&#xff0c;我们已经对手机变得非常依恋。这导致我们在手机上留下了很多珍贵的回忆。 不幸的是&#xff0c;我们有可能会丢失手机上的部分甚至全部数据。幸运的是&#xff0c;这不…

1. hadoop环境准备

环境准备 准备三台虚拟机&#xff0c;配置最好是 2C 4G 以上 本文准备三台机器的内网ip分别为 172.17.0.10 172.17.0.11 172.17.0.12本机配置/etc/hosts cat >> /etc/hosts<<EOF 172.17.0.10 hadoop01 172.17.0.11 hadoop02 172.17.0.12 hadoop03 EOF本机设置与…

队列的实现和OJ练习

目录 概念 队列的实现 利用结构体存放队列结构 为什么单链表不使用这种方法&#xff1f; 初始化队列 小提示&#xff1a; 队尾入队列 队头出队列 获取队头元素 获取队尾元素 获取队列中有效元素个数 检测队列是否为空 销毁队列 最终代码 循环队列 队列的OJ题 …

MobaXterm如何连接CentOS7的Linux虚拟机?Redis可视化客户端工具如何连接Linux版Redis?

一、打开Lunix虚拟机,进入虚拟机中,在终端中输入ifconfig,得到以下信息&#xff0c;红框中为ip地址 二、打开MobaXterm&#xff0c;点击session 选择SSH&#xff0c;在Remote host中输入linux得到的IP地址&#xff0c;Specify username中可起一个任意的连接名称。 输入密码 四、…

【洛谷 P3743】kotori的设备 题解(二分答案+递归)

kotori的设备 题目背景 kotori 有 n n n 个可同时使用的设备。 题目描述 第 i i i 个设备每秒消耗 a i a_i ai​ 个单位能量。能量的使用是连续的&#xff0c;也就是说能量不是某时刻突然消耗的&#xff0c;而是匀速消耗。也就是说&#xff0c;对于任意实数&#xff0c;…

60 权限提升-MYMSORA等SQL数据库提权

目录 数据库应用提权在权限提升中的意义WEB或本地环境如何探针数据库应用数据库提权权限用户密码收集等方法目前数据库提权对应的技术及方法等 演示案例Mysql数据库提权演示-脚本&MSF1.UDF提权知识点: (基于MYSQL调用命令执行函数&#xff09;读取数据库存储或备份文件 (了…

GaussDB新特性Ustore存储引擎介绍

1、 Ustore和Astore存储引擎介绍 Ustore存储引擎&#xff0c;又名In-place Update存储引擎&#xff08;原地更新&#xff09;&#xff0c;是openGauss 内核新增的一种存储模式。此前的版本使用的行存储引擎是Append Update&#xff08;追加更新&#xff09;模式。相比于Append…

在网络攻击之前、期间和之后应采取的步骤

在当今复杂的威胁形势下&#xff0c;网络攻击是不可避免的。 恶意行为者变得越来越复杂&#xff0c;出于经济动机的攻击变得越来越普遍&#xff0c;并且每天都会发现新的恶意软件系列。 这使得对于各种规模和跨行业的组织来说&#xff0c;制定适当的攻击计划变得更加重要。 …

【Linux】进程间通信 -- 管道

对于进程间通信的理解 首先&#xff0c;进程间通信的本质是&#xff0c;让不同的进程看到同一份资源&#xff08;这份资源不能隶属于任何一个进程&#xff0c;即应该是共享的&#xff09;。而进程间通信的目的是为了实现多进程之间的协同。 但由于进程运行具有独立性&#xff…

密码加密解密之路

1.背景 做数据采集&#xff0c;客户需要把他们那边的数据库连接信息存到我们系统里&#xff0c;那我们系统就要尽可能的保证这部分数据安全&#xff0c;不被盗。 2.我的思路 1.需要加密的地方有两处&#xff0c;一个是新增的时候前端传给后端的时候&#xff0c;一个是存到数…

异步爬取+多线程+redis构建一个运转丝滑且免费http-ip代理池 (三)

内容提要: 如果说,爬取网页数据的时候,我们使用了异步,那么将数据放入redis里面,其实也需要进行异步;当然,如果使用多线程或者redis线程池技术也是可以的,但那会造成冗余; 因此,在测试完多线程redis搭配异步爬虫的时候,我发现效率直接在redis这里被无限拉低下来! 因此: 最终的r…

从0开始学习JavaScript--JavaScript中的集合类

JavaScript中的集合类是处理数据的关键&#xff0c;涵盖了数组、Set、Map等多种数据结构。本文将深入研究这些集合类的创建、操作&#xff0c;以及实际应用场景&#xff0c;并通过丰富的示例代码&#xff0c;帮助大家更全面地了解和应用这些概念。 数组&#xff08;Array&…

SystemVerilog学习 (11)——覆盖率

目录 一、概述 二、覆盖率的种类 1、概述 2、分类 三、代码覆盖率 四、功能覆盖率 五、从功能描述到覆盖率 一、概述 “验证如果没有量化&#xff0c;那么就意味着没有尽头。” 伴随着复杂SoC系统的验证难度系数成倍增加&#xff0c;无论是定向测试还是随机测试&#xff…