diff --git a/doc/俄罗斯方块项介绍.pptx b/doc/俄罗斯方块项介绍.pptx new file mode 100644 index 0000000..77f40c3 Binary files /dev/null and b/doc/俄罗斯方块项介绍.pptx differ diff --git a/doc/文档模板-开源软件维护报告文档77.docx b/doc/文档模板-开源软件维护报告文档77.docx new file mode 100644 index 0000000..76cb29e Binary files /dev/null and b/doc/文档模板-开源软件维护报告文档77.docx differ diff --git a/src/Tetris-master/.idea/.gitignore b/src/Tetris-master/.idea/.gitignore new file mode 100644 index 0000000..35410ca --- /dev/null +++ b/src/Tetris-master/.idea/.gitignore @@ -0,0 +1,8 @@ +# 默认忽略的文件 +/shelf/ +/workspace.xml +# 基于编辑器的 HTTP 客户端请求 +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/src/Tetris-master/.idea/misc.xml b/src/Tetris-master/.idea/misc.xml new file mode 100644 index 0000000..a346fd7 --- /dev/null +++ b/src/Tetris-master/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/Tetris-master/.idea/modules.xml b/src/Tetris-master/.idea/modules.xml new file mode 100644 index 0000000..7345000 --- /dev/null +++ b/src/Tetris-master/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/src/Tetris-master/Tetris-master.iml b/src/Tetris-master/Tetris-master.iml new file mode 100644 index 0000000..d3e4a3a --- /dev/null +++ b/src/Tetris-master/Tetris-master.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/src/Tetris-master/Tetris-master/README.md b/src/Tetris-master/Tetris-master/README.md new file mode 100644 index 0000000..f2321c3 --- /dev/null +++ b/src/Tetris-master/Tetris-master/README.md @@ -0,0 +1,37 @@ +# Tetris + +#### 介绍 +使用Java实现俄罗斯方块, 开发工具idea + +#### 软件架构 +软件架构说明 + + +#### 安装教程 + +1. xxxx +2. xxxx +3. xxxx + +#### 使用说明 + +1. xxxx +2. xxxx +3. xxxx + +#### 参与贡献 + +1. Fork 本仓库 +2. 新建 Feat_xxx 分支 +3. 提交代码 +4. 新建 Pull Request + + +#### 特技 + +1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md +2. Gitee 官方博客 [blog.gitee.com](https://blog.gitee.com) +3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解 Gitee 上的优秀开源项目 +4. [GVP](https://gitee.com/gvp) 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目 +5. Gitee 官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help) +6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/) diff --git a/src/Tetris-master/Tetris-master/src/com/zbj/demo/App/Tetris.java b/src/Tetris-master/Tetris-master/src/com/zbj/demo/App/Tetris.java new file mode 100644 index 0000000..b9db82c --- /dev/null +++ b/src/Tetris-master/Tetris-master/src/com/zbj/demo/App/Tetris.java @@ -0,0 +1,466 @@ +package com.zbj.demo.App; + +import com.zbj.demo.block.Cell; +import com.zbj.demo.block.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.IOException; + +/** + * @author 张博吉 + * @date 2025/5/14 + * @describe 俄罗斯方块游戏主类 + */ +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; + + + // 新增:表示游戏是否暂停的变量 + private boolean isPaused = false; + + + //游戏分数池 + 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 { + ClassLoader classLoader = Tetris.class.getClassLoader(); + I = ImageIO.read(classLoader.getResourceAsStream("images/I.png")); + J = ImageIO.read(classLoader.getResourceAsStream("images/J.png")); + L = ImageIO.read(classLoader.getResourceAsStream("images/L.png")); + O = ImageIO.read(classLoader.getResourceAsStream("images/O.png")); + S = ImageIO.read(classLoader.getResourceAsStream("images/S.png")); + T = ImageIO.read(classLoader.getResourceAsStream("images/T.png")); + Z = ImageIO.read(classLoader.getResourceAsStream("images/Z.png")); + background = ImageIO.read(classLoader.getResourceAsStream("images/background.png")); + } catch (IOException e) { + e.printStackTrace(); + } + } + + @Override + public 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() { +// @Override +// public 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; +// } +// } +// }; +public void start() { + // 新增:添加暂停按键监听 + KeyListener l = new KeyAdapter() { + @Override + public 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: + // 新增:切换暂停状态 + isPaused = !isPaused; + break; + } + } + }; + this.addKeyListener(l); + this.requestFocus(); + + while (true) { + // 新增:检查是否暂停 + if (!isPaused) { + if (camDrop()) { + try { + Thread.sleep(500); + } catch (InterruptedException e) { + e.printStackTrace(); + } + currentOne.moveDrop(); + } else { + landToWall(); + destroyLine(); + if (isGameOver()) { + // 游戏结束处理 + break; + } else { + currentOne = nextOne; + nextOne = Tetromino.randomOne(); + } + } + } + repaint(); + } + + //将窗口设置为焦点 + 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 (isPaused) { + g.setColor(Color.RED); + g.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 60)); + g.drawString("PAUSED", 200, 400); + } + } +// 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(); + } +} diff --git a/src/Tetris-master/Tetris-master/src/com/zbj/demo/block/Cell.java b/src/Tetris-master/Tetris-master/src/com/zbj/demo/block/Cell.java new file mode 100644 index 0000000..e2f3c49 --- /dev/null +++ b/src/Tetris-master/Tetris-master/src/com/zbj/demo/block/Cell.java @@ -0,0 +1,96 @@ +package com.zbj.demo.block; + +import java.awt.image.BufferedImage; +import java.util.Objects; + +/** + * @author 张博吉 + * @date 2025/5/14 + * @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; + } + + @Override + public String toString() { + return "Cell{" + + "row=" + row + + ", col=" + col + + ", image=" + image + + '}'; + } + + @Override + public 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()); + } + + @Override + public int hashCode() { + return Objects.hash(getRow(), getCol(), getImage()); + } + + //左移动一格 + public void left(){ + col--; + } + + //右移动一格 + public void right(){ + col++; + } + + //下移动一格 + public void down(){ + row++; + } +} diff --git a/src/Tetris-master/Tetris-master/src/com/zbj/demo/block/Tetromino.java b/src/Tetris-master/Tetris-master/src/com/zbj/demo/block/Tetromino.java new file mode 100644 index 0000000..3691150 --- /dev/null +++ b/src/Tetris-master/Tetris-master/src/com/zbj/demo/block/Tetromino.java @@ -0,0 +1,209 @@ +package com.zbj.demo.block; + +import com.zbj.demo.shape.*; + +/** + * @author 张博吉 + * @date 2025/5/14 + * @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; + } + + //旋转次数+1 + count++; + 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; + } + + //旋转次数+1 + count--; + 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; + } + + @Override + public String toString() { + return "State{" + + "row0=" + row0 + + ", col0=" + col0 + + ", row1=" + row1 + + ", col1=" + col1 + + ", row2=" + row2 + + ", col2=" + col2 + + ", row3=" + row3 + + ", col3=" + col3 + + '}'; + } + } +} diff --git a/src/Tetris-master/Tetris-master/src/com/zbj/demo/shape/I.java b/src/Tetris-master/Tetris-master/src/com/zbj/demo/shape/I.java new file mode 100644 index 0000000..7356cab --- /dev/null +++ b/src/Tetris-master/Tetris-master/src/com/zbj/demo/shape/I.java @@ -0,0 +1,27 @@ +package com.zbj.demo.shape; + +import com.zbj.demo.App.Tetris; +import com.zbj.demo.block.Cell; +import com.zbj.demo.block.Tetromino; + +/** + * @author 张博吉 + * @date 2025/5/20 + * @describe + */ +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); + } + +} diff --git a/src/Tetris-master/Tetris-master/src/com/zbj/demo/shape/J.java b/src/Tetris-master/Tetris-master/src/com/zbj/demo/shape/J.java new file mode 100644 index 0000000..f033b16 --- /dev/null +++ b/src/Tetris-master/Tetris-master/src/com/zbj/demo/shape/J.java @@ -0,0 +1,25 @@ +package com.zbj.demo.shape; + +import com.zbj.demo.App.Tetris; +import com.zbj.demo.block.Cell; +import com.zbj.demo.block.Tetromino; + +/** + * @author 张博吉 + * @date 2025/5/20 + * @describe + */ +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); + } +} diff --git a/src/Tetris-master/Tetris-master/src/com/zbj/demo/shape/L.java b/src/Tetris-master/Tetris-master/src/com/zbj/demo/shape/L.java new file mode 100644 index 0000000..d32ec56 --- /dev/null +++ b/src/Tetris-master/Tetris-master/src/com/zbj/demo/shape/L.java @@ -0,0 +1,24 @@ +package com.zbj.demo.shape; + +import com.zbj.demo.App.Tetris; +import com.zbj.demo.block.Cell; +import com.zbj.demo.block.Tetromino; +/** + * @author 张博吉 + * @date 2025/5/20 + * @describe + */ +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); + } +} diff --git a/src/Tetris-master/Tetris-master/src/com/zbj/demo/shape/O.java b/src/Tetris-master/Tetris-master/src/com/zbj/demo/shape/O.java new file mode 100644 index 0000000..5c864b7 --- /dev/null +++ b/src/Tetris-master/Tetris-master/src/com/zbj/demo/shape/O.java @@ -0,0 +1,22 @@ +package com.zbj.demo.shape; + +import com.zbj.demo.App.Tetris; +import com.zbj.demo.block.Cell; +import com.zbj.demo.block.Tetromino; + +/** + * @author 张博吉 + * @date 2025/5/20 + * @describe + */ +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]; + } +} diff --git a/src/Tetris-master/Tetris-master/src/com/zbj/demo/shape/S.java b/src/Tetris-master/Tetris-master/src/com/zbj/demo/shape/S.java new file mode 100644 index 0000000..2df8333 --- /dev/null +++ b/src/Tetris-master/Tetris-master/src/com/zbj/demo/shape/S.java @@ -0,0 +1,25 @@ +package com.zbj.demo.shape; + +import com.zbj.demo.App.Tetris; +import com.zbj.demo.block.Cell; +import com.zbj.demo.block.Tetromino; + +/** + * @author 张博吉 + * @date 2025/5/20 + * @describe + */ +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); + } +} diff --git a/src/Tetris-master/Tetris-master/src/com/zbj/demo/shape/T.java b/src/Tetris-master/Tetris-master/src/com/zbj/demo/shape/T.java new file mode 100644 index 0000000..b76ea2a --- /dev/null +++ b/src/Tetris-master/Tetris-master/src/com/zbj/demo/shape/T.java @@ -0,0 +1,25 @@ +package com.zbj.demo.shape; + +import com.zbj.demo.App.Tetris; +import com.zbj.demo.block.Cell; +import com.zbj.demo.block.Tetromino; + +/** + * @author 张博吉 + * @date 2025/5/20 + * @describe + */ +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); + } +} diff --git a/src/Tetris-master/Tetris-master/src/com/zbj/demo/shape/Z.java b/src/Tetris-master/Tetris-master/src/com/zbj/demo/shape/Z.java new file mode 100644 index 0000000..009c03a --- /dev/null +++ b/src/Tetris-master/Tetris-master/src/com/zbj/demo/shape/Z.java @@ -0,0 +1,25 @@ +package com.zbj.demo.shape; + +import com.zbj.demo.App.Tetris; +import com.zbj.demo.block.Cell; +import com.zbj.demo.block.Tetromino; + +/** + * @author 张博吉 + * @date 2025/5/20 + * @describe + */ +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); + } +} diff --git a/src/Tetris-master/Tetris-master/src/images/I.png b/src/Tetris-master/Tetris-master/src/images/I.png new file mode 100644 index 0000000..13046d8 Binary files /dev/null and b/src/Tetris-master/Tetris-master/src/images/I.png differ diff --git a/src/Tetris-master/Tetris-master/src/images/J.png b/src/Tetris-master/Tetris-master/src/images/J.png new file mode 100644 index 0000000..b39bc5c Binary files /dev/null and b/src/Tetris-master/Tetris-master/src/images/J.png differ diff --git a/src/Tetris-master/Tetris-master/src/images/L.png b/src/Tetris-master/Tetris-master/src/images/L.png new file mode 100644 index 0000000..cdae41d Binary files /dev/null and b/src/Tetris-master/Tetris-master/src/images/L.png differ diff --git a/src/Tetris-master/Tetris-master/src/images/O.png b/src/Tetris-master/Tetris-master/src/images/O.png new file mode 100644 index 0000000..8c3cfb5 Binary files /dev/null and b/src/Tetris-master/Tetris-master/src/images/O.png differ diff --git a/src/Tetris-master/Tetris-master/src/images/S.png b/src/Tetris-master/Tetris-master/src/images/S.png new file mode 100644 index 0000000..0620eb3 Binary files /dev/null and b/src/Tetris-master/Tetris-master/src/images/S.png differ diff --git a/src/Tetris-master/Tetris-master/src/images/T.png b/src/Tetris-master/Tetris-master/src/images/T.png new file mode 100644 index 0000000..63189ed Binary files /dev/null and b/src/Tetris-master/Tetris-master/src/images/T.png differ diff --git a/src/Tetris-master/Tetris-master/src/images/Z.png b/src/Tetris-master/Tetris-master/src/images/Z.png new file mode 100644 index 0000000..539010c Binary files /dev/null and b/src/Tetris-master/Tetris-master/src/images/Z.png differ diff --git a/src/Tetris-master/Tetris-master/src/images/background.png b/src/Tetris-master/Tetris-master/src/images/background.png new file mode 100644 index 0000000..febcbc7 Binary files /dev/null and b/src/Tetris-master/Tetris-master/src/images/background.png differ diff --git a/src/Tetris-master/out/production/Tetris-master/com/zbj/demo/App/Tetris$1.class b/src/Tetris-master/out/production/Tetris-master/com/zbj/demo/App/Tetris$1.class new file mode 100644 index 0000000..e71d6fc Binary files /dev/null and b/src/Tetris-master/out/production/Tetris-master/com/zbj/demo/App/Tetris$1.class differ diff --git a/src/Tetris-master/out/production/Tetris-master/com/zbj/demo/App/Tetris.class b/src/Tetris-master/out/production/Tetris-master/com/zbj/demo/App/Tetris.class new file mode 100644 index 0000000..7ba8f6d Binary files /dev/null and b/src/Tetris-master/out/production/Tetris-master/com/zbj/demo/App/Tetris.class differ diff --git a/src/Tetris-master/out/production/Tetris-master/com/zbj/demo/block/Cell.class b/src/Tetris-master/out/production/Tetris-master/com/zbj/demo/block/Cell.class new file mode 100644 index 0000000..2de3289 Binary files /dev/null and b/src/Tetris-master/out/production/Tetris-master/com/zbj/demo/block/Cell.class differ diff --git a/src/Tetris-master/out/production/Tetris-master/com/zbj/demo/block/Tetromino$State.class b/src/Tetris-master/out/production/Tetris-master/com/zbj/demo/block/Tetromino$State.class new file mode 100644 index 0000000..0060840 Binary files /dev/null and b/src/Tetris-master/out/production/Tetris-master/com/zbj/demo/block/Tetromino$State.class differ diff --git a/src/Tetris-master/out/production/Tetris-master/com/zbj/demo/block/Tetromino.class b/src/Tetris-master/out/production/Tetris-master/com/zbj/demo/block/Tetromino.class new file mode 100644 index 0000000..6e54c85 Binary files /dev/null and b/src/Tetris-master/out/production/Tetris-master/com/zbj/demo/block/Tetromino.class differ diff --git a/src/Tetris-master/out/production/Tetris-master/com/zbj/demo/shape/I.class b/src/Tetris-master/out/production/Tetris-master/com/zbj/demo/shape/I.class new file mode 100644 index 0000000..d2a19bd Binary files /dev/null and b/src/Tetris-master/out/production/Tetris-master/com/zbj/demo/shape/I.class differ diff --git a/src/Tetris-master/out/production/Tetris-master/com/zbj/demo/shape/J.class b/src/Tetris-master/out/production/Tetris-master/com/zbj/demo/shape/J.class new file mode 100644 index 0000000..f6b8a01 Binary files /dev/null and b/src/Tetris-master/out/production/Tetris-master/com/zbj/demo/shape/J.class differ diff --git a/src/Tetris-master/out/production/Tetris-master/com/zbj/demo/shape/L.class b/src/Tetris-master/out/production/Tetris-master/com/zbj/demo/shape/L.class new file mode 100644 index 0000000..3c6b362 Binary files /dev/null and b/src/Tetris-master/out/production/Tetris-master/com/zbj/demo/shape/L.class differ diff --git a/src/Tetris-master/out/production/Tetris-master/com/zbj/demo/shape/O.class b/src/Tetris-master/out/production/Tetris-master/com/zbj/demo/shape/O.class new file mode 100644 index 0000000..8c705d7 Binary files /dev/null and b/src/Tetris-master/out/production/Tetris-master/com/zbj/demo/shape/O.class differ diff --git a/src/Tetris-master/out/production/Tetris-master/com/zbj/demo/shape/S.class b/src/Tetris-master/out/production/Tetris-master/com/zbj/demo/shape/S.class new file mode 100644 index 0000000..dcd0279 Binary files /dev/null and b/src/Tetris-master/out/production/Tetris-master/com/zbj/demo/shape/S.class differ diff --git a/src/Tetris-master/out/production/Tetris-master/com/zbj/demo/shape/T.class b/src/Tetris-master/out/production/Tetris-master/com/zbj/demo/shape/T.class new file mode 100644 index 0000000..a2606bd Binary files /dev/null and b/src/Tetris-master/out/production/Tetris-master/com/zbj/demo/shape/T.class differ diff --git a/src/Tetris-master/out/production/Tetris-master/com/zbj/demo/shape/Z.class b/src/Tetris-master/out/production/Tetris-master/com/zbj/demo/shape/Z.class new file mode 100644 index 0000000..5177c91 Binary files /dev/null and b/src/Tetris-master/out/production/Tetris-master/com/zbj/demo/shape/Z.class differ diff --git a/src/Tetris-master/out/production/Tetris-master/images/I.png b/src/Tetris-master/out/production/Tetris-master/images/I.png new file mode 100644 index 0000000..13046d8 Binary files /dev/null and b/src/Tetris-master/out/production/Tetris-master/images/I.png differ diff --git a/src/Tetris-master/out/production/Tetris-master/images/J.png b/src/Tetris-master/out/production/Tetris-master/images/J.png new file mode 100644 index 0000000..b39bc5c Binary files /dev/null and b/src/Tetris-master/out/production/Tetris-master/images/J.png differ diff --git a/src/Tetris-master/out/production/Tetris-master/images/L.png b/src/Tetris-master/out/production/Tetris-master/images/L.png new file mode 100644 index 0000000..cdae41d Binary files /dev/null and b/src/Tetris-master/out/production/Tetris-master/images/L.png differ diff --git a/src/Tetris-master/out/production/Tetris-master/images/O.png b/src/Tetris-master/out/production/Tetris-master/images/O.png new file mode 100644 index 0000000..8c3cfb5 Binary files /dev/null and b/src/Tetris-master/out/production/Tetris-master/images/O.png differ diff --git a/src/Tetris-master/out/production/Tetris-master/images/S.png b/src/Tetris-master/out/production/Tetris-master/images/S.png new file mode 100644 index 0000000..0620eb3 Binary files /dev/null and b/src/Tetris-master/out/production/Tetris-master/images/S.png differ diff --git a/src/Tetris-master/out/production/Tetris-master/images/T.png b/src/Tetris-master/out/production/Tetris-master/images/T.png new file mode 100644 index 0000000..63189ed Binary files /dev/null and b/src/Tetris-master/out/production/Tetris-master/images/T.png differ diff --git a/src/Tetris-master/out/production/Tetris-master/images/Z.png b/src/Tetris-master/out/production/Tetris-master/images/Z.png new file mode 100644 index 0000000..539010c Binary files /dev/null and b/src/Tetris-master/out/production/Tetris-master/images/Z.png differ diff --git a/src/Tetris-master/out/production/Tetris-master/images/background.png b/src/Tetris-master/out/production/Tetris-master/images/background.png new file mode 100644 index 0000000..febcbc7 Binary files /dev/null and b/src/Tetris-master/out/production/Tetris-master/images/background.png differ