1 Star 0 Fork 10

williamszhan / Tetris

forked from zhoutk / Tetris 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

##项目背景 在折腾ES6,突然想起大学时用c语言写过俄罗斯方块,本项目中主要是利用ES6的Class特性进行面向对象编程。同一时间,我在看约翰.霍兰的《涌现》和KK的《失控》,产生了对人工智能的莫大兴趣,也对面向对象思想有了更深入的理解,终极目标是想写一个自动玩俄罗斯方块的小机器人。 ##设计思路

  • 全面应用面向对象的设计思想,让功能内聚性强。
  • 把七种方块想成独立的“生物”对象,让它能“看”到周围的世界。
  • 没有使用传统的大的二维数组来表示游戏场面状态,而是让tetris自己去“看”。
  • 使用html5的canvas来完成,比较象cgi编程。
  • 使用最少的canvas特性,只用了fillRect,strokeRect,getImageData,clearRect等几个函数。

##运行方法 项目采用node.js v6.2.0 + electron v1.1.0 进行桌面开发,因此请先安装相关系统:

npm install electron-prebuilt -g

注:本项目采用方案能跨所有平台运行,遇权限问题,请在命令行自行添加sudo 。

请下载源代码:

git clone https://git.oschina.net/zhoutk/Tetris.git

进入项目目录:

cd Tetris

运行程序:

electron .

##交流博客 我会把心得体会写在我的博客中,地址如下:

https://segmentfault.com/blog/zhoutk

##最新进度

  • 可以手动玩俄罗斯方块
  • 提供自动模式,简单评估算法,平均大概能消500行左右,现最高记录消除1398行。
The MIT License (MIT) Copyright (c) 2016 zhoutk Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

俄罗斯方块游戏,利用electron方式来写node.js桌面程序。 展开 收起
NodeJS
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
NodeJS
1
https://gitee.com/williamszhan/Tetris.git
git@gitee.com:williamszhan/Tetris.git
williamszhan
Tetris
Tetris
master

搜索帮助

14c37bed 8189591 565d56ea 8189591