one-yeheng
v1.0.3
Published
A simple Tetris game
Downloads
16
Readme
one-yeheng
一个简单的俄罗斯方块游戏
安装
你可以通过 npm 安装这个包:
npm install one-yeheng使用方法
const { startGame } = require('one-yeheng');
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>俄罗斯方块 - one-yeheng</title>
<link rel="stylesheet" href="./node_modules/one-yeheng/style.css">
</head>
<body>
<h1>俄罗斯方块</h1>
<div id="game-board">
<div id="score">得分: 0</div>
<canvas id="tetris" width="300" height="600"></canvas>
<button id="start-button">开始游戏</button>
</div>
<script src="./node_modules/one-yeheng/index.js"></script>
</body>
</html>
## 介绍
游戏控制
← 左箭头:向左移动方块。
→ 右箭头:向右移动方块。
↓ 下箭头:加速方块下落。
↑ 上箭头:旋转方块。
游戏界面
游戏区域:一个 10x20 的网格,方块会从顶部下落。
得分:显示在游戏区域上方。
游戏规则
方块会从顶部随机生成并下落。
使用键盘控制方块的移动和旋转。
当一行被填满时,该行会消失,并增加得分。
当方块堆叠到顶部时,游戏结束。
## 技术细节
技术栈
HTML:用于构建游戏界面。
CSS:用于美化游戏界面。
JavaScript:用于实现游戏逻辑。
Node.js:用于运行本地服务器。
## 主要功能
方块生成:随机生成 7 种不同形状的方块。
碰撞检测:检测方块是否触底或与其他方块碰撞。
消除行:当一行被填满时,消除该行并更新得分。
游戏结束:当方块堆叠到顶部时,游戏结束。
许可证
本项目基于 MIT 许可证 开源。详情请参阅 LICENSE 文件。