|
6 | 6 |
|
7 | 7 | ---
|
8 | 8 |
|
9 |
| -<!-- # mini-shed --> |
10 | 9 |
|
11 |
| - |
12 |
| - |
13 |
| -<!-- 迷你屋是一个开放,高效的小游戏框架 --> |
14 |
| - |
15 |
| -<!-- ## Table of Contents |
16 |
| -
|
17 |
| -- [koa-jwt](#koa-jwt) |
18 |
| - - [Table of Contents](#table-of-contents) |
19 |
| - - [Introduction](#introduction) |
20 |
| - - [Install](#install) |
21 |
| - - [Usage](#usage) |
22 |
| - - [Retrieving the token](#retrieving-the-token) |
23 |
| - - [Passing the secret](#passing-the-secret) |
24 |
| - - [Checking if the token is revoked](#checking-if-the-token-is-revoked) |
25 |
| - - [Example](#example) |
26 |
| - - [Token Verification Exceptions](#token-verification-exceptions) |
27 |
| - - [Related Modules](#related-modules) |
28 |
| - - [Tests](#tests) |
29 |
| - - [Author](#author) |
30 |
| - - [Credits](#credits) |
31 |
| - - [Contributors](#contributors) |
32 |
| - - [License](#license) --> |
33 |
| - |
34 |
| -<!-- ## 简介 |
35 |
| -
|
36 |
| -`mini-shed` 是一枚高效,开放,易扩展的微信小游戏框架。 --> |
37 |
| - |
38 |
| -> mini-shed 正在独立开发中,有建议,想帮忙,想聊天的,都欢迎来骚扰我。[[联系方式]](https://nshen.net/about) |
| 10 | +> mini-shed 目前版本 v0.2,龟速独立开发中,有建议,想参与,想聊天的欢迎来[骚扰](https://nshen.net/about)。 |
39 | 11 |
|
40 | 12 | ## 特性
|
41 | 13 |
|
42 | 14 | - 基于前端流行技术 `TypeScript` 编写,`babel` + `rollup` 构建,用组合 `npm` 包的方式开发小游戏。
|
43 | 15 | - 在 `VSCode` 中开发,`Chrome`浏览器中实时刷新调试,秒编译到各个小游戏平台。
|
44 | 16 | - 可发布 Web版`H5小游戏`,`微信/QQ小游戏`, `头条/抖音小游戏`,`OPPO/VIVO小游戏` 等快游戏平台。
|
45 |
| -- 迷你的`Entity-Component-System` 架构,数据驱动,简单高效,独立`System`自由组合,易于扩展。 |
46 |
| -- 没用`Adapter库`,原生`WebGL`高速渲染,跨小游戏平台统一API,专注于`小且快`。 |
| 17 | +- `Entity-Component-System` 架构,数据驱动,简单高效,独立`System`自由组合,易于扩展。 |
| 18 | +- 专注于小且快,没用`Adapter库`,原生`WebGL`渲染,跨小游戏平台统一API。 |
47 | 19 |
|
48 |
| -# 快速开始 |
| 20 | +## 快速开始 |
49 | 21 |
|
50 |
| -## 获取最新脚手架 |
| 22 | +### 安装 `@shed/cli` 命令行工具 |
51 | 23 |
|
52 |
| -``` |
53 |
| -git clone https://github.com/nshen/shed.git myGame |
| 24 | +迷你屋使用 `@shed/cli` 来创建,编译小游戏。 |
54 | 25 |
|
55 |
| -``` |
| 26 | +- 用 npm 安装 |
56 | 27 |
|
57 |
| -## 然后进入目录 |
| 28 | +```bash |
| 29 | +npm install -g @shed/cli |
58 | 30 |
|
59 |
| -``` |
60 |
| -cd myGame |
| 31 | +# 网络环境不好可安装淘宝镜像 cnpm,之后所有 npm 命令都用 cnpm 代替 |
| 32 | +npm install -g cnpm --registry=https://registry.npm.taobao.org |
| 33 | +cnpm install -g @shed/cli |
61 | 34 | ```
|
62 | 35 |
|
63 |
| -## 安装 npm 依赖 |
| 36 | +- 或用 yarn 安装 |
64 | 37 |
|
65 |
| -``` |
66 |
| -npm install |
| 38 | +```bash |
| 39 | +yarn global add @shed/cli |
67 | 40 | ```
|
68 | 41 |
|
69 |
| -## 简单一条命令即可编译出小游戏 |
| 42 | +打开命令行输入 `shed` 回车,如果安装成功会有提示信息。 |
70 | 43 |
|
71 |
| -``` |
72 |
| -npm run build |
73 |
| -``` |
| 44 | +### 创建一个新的小游戏 |
74 | 45 |
|
75 |
| -## 打开微信小游戏开发工具,导入游戏,选择 `dist` 子目录即可 |
| 46 | +```bash |
| 47 | +> shed create myGame # 在当前目录下创建一个新游戏叫做 `myGame` |
| 48 | +``` |
| 49 | +进入 `myGame` 目录,安装依赖 |
76 | 50 |
|
77 |
| - |
| 51 | +```bash |
| 52 | +> cd myGame |
| 53 | +> npm install # 或者 yarn install |
| 54 | +``` |
78 | 55 |
|
79 |
| -# 迷你ECS架构 |
| 56 | +### 实时编译Web预览 |
80 | 57 |
|
81 |
| -Entity Component System 是一个经典架构,`Shed.js` 根据JS语言特性实现了这个迷你版本 |
| 58 | +在 `myGame` 目录中运行 |
82 | 59 |
|
83 |
| -## Component |
| 60 | +```bash |
| 61 | +> shed build h5 --watch |
| 62 | +``` |
84 | 63 |
|
85 |
| -`Component` **只有数据,没有方法。** 例如一个 `transform` 组件只是一个含 `type` 属性的 `Object` 。 |
| 64 | +其他命令见 [@shed/cli](./packages/cli) 文档页 |
86 | 65 |
|
87 |
| -```typescript |
88 |
| - { type: 'transform', x: 0, y: 0, rotation: 180 } |
89 |
| -``` |
| 66 | +## 项目结构 |
90 | 67 |
|
91 |
| -## Entity |
| 68 | +整个项目是在 [Lerna](https://lerna.js.org/) 管理下的 monorepo。 |
92 | 69 |
|
| 70 | +mini-shed 中的包是标准的 npm 包,可按需组合,并不局限在下边的包,可自行扩展。 |
93 | 71 |
|
94 |
| -`Entity` 仅是一个有唯一 `id` 的**容器**,并且保存了一个 `Components` 表。 |
| 72 | +#### 常用包 |
95 | 73 |
|
96 |
| -例如一个添加了 `transform 组件` 与 `render 组件` 的 `Entity` **可以想象成** : |
| 74 | +| Package | Status | Description | |
| 75 | +|---------|--------|-------------| |
| 76 | +| [@shed/cli] | [![shed-cli-status]][@shed/cli-package] | 命令行工具,主要用来创建,编译小游戏,还提供一些辅助功能 | |
| 77 | +| [@shed/ecs] | [![shed-ecs-status]][@shed/ecs-package] | 开放的 `Entity-Component-System` 系统实现 | |
| 78 | +| [@shed/math] | [![shed-math-status]][@shed/math-package] | 数学支持库 Matrix,Vector 等| |
| 79 | +| [@shed/gl] | [![shed-gl-status]][@shed/gl-package] | 使`WebGL API` 简化的面向对象包装 | |
| 80 | +| [@shed/platform] | [![shed-platform-status]][@shed/platform-package] | 以微信小游戏为基准,统一各小游戏平台提供的`API`,并 `Promise` 化 | |
| 81 | +| [@shed/utils] | [![shed-utils-status]][@shed/utils-package] | 一些实用类或函数 | |
97 | 82 |
|
98 |
| -```typescript |
99 |
| -let entity = { |
100 |
| - id: 'Entity121', |
101 |
| - components: { |
102 |
| - 'transform': { type: 'transform', x: 0, y: 0, rotation: 180 }, |
103 |
| - 'render': { image:'sprite.png' } |
104 |
| - } |
105 |
| -} |
106 |
| -``` |
| 83 | +#### 默认demo包 |
107 | 84 |
|
108 |
| -## System |
| 85 | +| Package | Status | Description | |
| 86 | +|---------|--------|-------------| |
| 87 | +| [@shed/starter] | [![shed-starter-status]][@shed/starter-package] | 使用`shed create` 命令创建的默认demo | |
109 | 88 |
|
110 |
| -System **只有方法,不存数据。** 以下是一个自定义 `System` 的写法 |
111 | 89 |
|
112 |
| -```typescript |
| 90 | +#### 新包模板 |
113 | 91 |
|
114 |
| -import { System } from "@shed/ecs"; |
| 92 | +创建一个新包可以基于此修改 |
115 | 93 |
|
116 |
| -export class EmptySystem extends System { |
| 94 | +| Package | Status | Description | |
| 95 | +|---------|--------|-------------| |
| 96 | +| [@shed/new-package] | [![shed-new-package-status]][@shed/new-package-package] | 一个配置好`typescript`, `babel`, `rollup` 的模板包 | |
117 | 97 |
|
118 |
| - update() { |
| 98 | +#### Systems |
119 | 99 |
|
120 |
| - // write you code here |
121 |
| - } |
122 |
| -} |
| 100 | +`Entity Component System` 中的 `System` 可以独立成一个 `npm` 包存在,使得非常容易扩展。 |
123 | 101 |
|
124 |
| -``` |
| 102 | +| Project | Status | Description | |
| 103 | +|---------|--------|-------------| |
| 104 | +| [@shed/render2d-system] | [![@shed/render2d-system-status]][@shed/render2d-system-package] | 2d渲染系统,它会尽量把所有 Entity 打包在一起一次渲染 | |
125 | 105 |
|
126 |
| -一个 `System` 通常关注和操作一组指定类型的 `Entities` |
127 | 106 |
|
128 |
| -例如一个 `RenderSystem` 就应该只关注同时含有 `render` 与 `transform` 组件的 `Entities`。 |
| 107 | +[@shed/render2d-system]: ./packages/render2d-system |
| 108 | +[@shed/render2d-system-status]: https://img.shields.io/npm/v/@shed/render2d-system.svg |
| 109 | +[@shed/render2d-system-package]: https://www.npmjs.com/package/@shed/render2d-system |
129 | 110 |
|
130 |
| -确实 [@shed/render-system](https://github.com/nshen/shed-render-system) 就是这么做的。 |
131 | 111 |
|
132 |
| -这里可以看到,一个 `System` 可以发布成一个独立的 `npm包`。开发游戏时可以像拼插乐高一样按需安装系统。 |
| 112 | +[@shed/cli]: ./packages/cli |
| 113 | +[@shed/ecs]: ./packages/ecs |
| 114 | +[@shed/math]: ./packages/math |
| 115 | +[@shed/gl]: ./packages/gl |
| 116 | +[@shed/platform]: ./packages/platform |
| 117 | +[@shed/utils]: ./packages/utils |
| 118 | +[@shed/starter]: ./packages/starter |
| 119 | +[@shed/new-package]: ./packages/new-package |
133 | 120 |
|
134 |
| -`npm install shed-xxx-system` |
| 121 | +[shed-cli-status]: https://img.shields.io/npm/v/@shed/cli.svg |
| 122 | +[shed-ecs-status]: https://img.shields.io/npm/v/@shed/ecs.svg |
| 123 | +[shed-math-status]: https://img.shields.io/npm/v/@shed/math.svg |
| 124 | +[shed-gl-status]: https://img.shields.io/npm/v/@shed/gl.svg |
| 125 | +[shed-platform-status]: https://img.shields.io/npm/v/@shed/platform.svg |
| 126 | +[shed-utils-status]: https://img.shields.io/npm/v/@shed/utils.svg |
| 127 | +[shed-starter-status]: https://img.shields.io/npm/v/@shed/starter.svg |
| 128 | +[shed-new-package-status]: https://img.shields.io/npm/v/@shed/new-package.svg |
135 | 129 |
|
136 |
| -这就是这个系统容易扩展的地方,更多信息请查看 [@shed/ecs](https://github.com/nshen/shed-ecs) 主页 |
| 130 | +[@shed/cli-package]: https://www.npmjs.com/package/@shed/cli |
| 131 | +[@shed/ecs-package]: https://www.npmjs.com/package/@shed/ecs |
| 132 | +[@shed/math-package]: https://www.npmjs.com/package/@shed/math |
| 133 | +[@shed/gl-package]: https://www.npmjs.com/package/@shed/gl |
| 134 | +[@shed/platform-package]: https://www.npmjs.com/package/@shed/platform |
| 135 | +[@shed/utils-package]: https://www.npmjs.com/package/@shed/utils |
| 136 | +[@shed/starter-package]: https://www.npmjs.com/package/@shed/starter |
| 137 | +[@shed/new-package-package]: https://www.npmjs.com/package/@shed/new-package |
137 | 138 |
|
138 | 139 |
|
139 | 140 |
|
| 141 | +## `.github` 文件夹 |
140 | 142 |
|
141 |
| -# 生态系统 |
| 143 | +.github 文件夹内是 github actions ,用于发布`@shed/starter` 到国内镜像 |
142 | 144 |
|
143 |
| -## 每个游戏都需要的核心库 |
| 145 | +### 触发 |
144 | 146 |
|
145 |
| -| Project | Status | Description | |
146 |
| -|---------|--------|-------------| |
147 |
| -| [@shed/ecs] | [![shed-ecs-status]][@shed/ecs-package] | 迷你 `Entity-Component-System` 系统 | |
148 |
| -| [@shed/math] | [![shed-math-status]][@shed/math-package] | Matrix,Vector 等数学支持库 | |
149 |
| -| [@shed/gl] | [![shed-gl-status]][@shed/gl-package] | 让 `Webgl API` 更简洁的帮助库 | |
| 147 | +每次`push`源代码到 `github` 时,会触发此流程 |
150 | 148 |
|
| 149 | +### 发布 starter |
151 | 150 |
|
| 151 | +`github actions`会自动把 `/packages/starter` 目录 ,强推到 `coding.net` 和 `gitee.com` 以下项目地址 |
152 | 152 |
|
153 |
| -[@shed/ecs]: https://github.com/nshen/shed-ecs |
154 |
| -[@shed/math]: https://github.com/nshen/shed-math |
155 |
| -[@shed/gl]: https://github.com/nshen/shed-gl |
| 153 | +- https://shed.coding.net/p/mini-shed-starter |
| 154 | +- https://gitee.com/nshen/mini-shed-starter |
156 | 155 |
|
157 |
| -[shed-ecs-status]: https://img.shields.io/npm/v/@shed/ecs.svg |
158 |
| -[shed-math-status]: https://img.shields.io/npm/v/@shed/math.svg |
159 |
| -[shed-gl-status]: https://img.shields.io/npm/v/@shed/gl.svg |
| 156 | +使用`@shed/cli`命令行创建游戏时,实际上是从上边的地址clone下来的 |
160 | 157 |
|
161 |
| -[@shed/ecs-package]: https://www.npmjs.com/package/@shed/ecs |
162 |
| -[@shed/math-package]: https://www.npmjs.com/package/@shed/math |
163 |
| -[@shed/gl-package]: https://www.npmjs.com/package/@shed/gl |
| 158 | +```bash |
| 159 | +shed create myGame |
| 160 | +# 实际相当于 |
| 161 | +# git clone https://e.coding.net/shed/mini-shed-starter.git myGame |
| 162 | +``` |
164 | 163 |
|
165 |
| -## Systems |
| 164 | +## Contributors |
166 | 165 |
|
167 |
| -| Project | Status | Description | |
168 |
| -|---------|--------|-------------| |
169 |
| -| [@shed/render-system] | [![@shed/render-system-status]][@shed/render-system-package] | 高效的 2D Batching 渲染系统 | |
| 166 | +* [nshen](https://github.com/nshen) |
170 | 167 |
|
171 |
| -[@shed/render-system]: https://github.com/nshen/shed-render-system |
172 |
| -[@shed/render-system-status]: https://img.shields.io/npm/v/@shed/render-system.svg |
173 |
| -[@shed/render-system-package]: https://www.npmjs.com/package/@shed/render-system |
| 168 | +## License |
174 | 169 |
|
175 |
| -目前 `System` 生态比较贫乏,期待你的加入。 |
| 170 | +[The MIT License](http://opensource.org/licenses/MIT) |
0 commit comments