From 200b2a47d07a70773bb8de57b4fa13700bdd6617 Mon Sep 17 00:00:00 2001 From: yupi <592789970@qq.com> Date: Fri, 16 Sep 2022 22:41:26 +0800 Subject: [PATCH] =?UTF-8?q?add=20=E6=B7=BB=E5=8A=A0=E6=B8=B8=E6=88=8F?= =?UTF-8?q?=E8=83=9C=E5=88=A9=E6=A0=87=E8=AF=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 6 +- package.json | 1 + src/assets/kunkun.png | Bin 0 -> 4430 bytes src/components/MyAd.vue | 8 + src/core/game.ts | 17 +- src/pages/GamePage.vue | 5 + src/pages/IndexPage.vue | 9 +- yarn.lock | 536 ++++++++++++++++++++-------------------- 8 files changed, 307 insertions(+), 275 deletions(-) create mode 100644 src/assets/kunkun.png create mode 100644 src/components/MyAd.vue diff --git a/README.md b/README.md index 903dc1f..e031b6e 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ 玩法: -1. 支持选关 -2. 支持自定义难度(待更新) -3. 无限道具(待更新) +1. 支持选择难度(4 种) +2. 支持自定义难度 +3. 支持道具 diff --git a/package.json b/package.json index 094852d..d702980 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ "preview": "vite preview" }, "dependencies": { + "@ant-design/icons-vue": "^6.1.0", "ant-design-vue": "^3.2.11", "lodash": "^4.17.21", "pinia": "^2.0.19", diff --git a/src/assets/kunkun.png b/src/assets/kunkun.png new file mode 100644 index 0000000000000000000000000000000000000000..a76188661348b2be841374ee463332c2d7cd9ad4 GIT binary patch literal 4430 zcmV-U5wY%4Nk&FS5dZ*JMM6+kP&gnu5dZ*CTmYQ`D&PR%06vjGn@J_3qai1;ywI=` z31b7uOqk_4>`EQw7;H60QTUhpuMzy(41KG8(Ghp2JZf-#3u!-c$?Cc5z{{Av`$4kU z#aE>JK%1I#N<`dY16JZNvtSMxHgA?2FM3Y5q+OC^&!!cHV&PbTkAiuKeCiZZ&5w6o zzDYM~M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g1&2&;QML~q5&7P z#uzTxPqb3pio*Z}7J6x%+X*ihpGl8ynjk-q4m$BQYqVN1Z_T(=+PT#4?>?BQT$cO$4G#`sa}BNB1>g4b?bJb&*j=qO*iYMH;UPonnv*MeTJMgd`PJ-L z!zBo=Xi$;r4;wOrd0fAn#?fx+!6Lk zK!L_KAsO%kQ>VzKa#2L8K zB%3dl;?Z8qEMyta6(cVT=ykla+KlSoT$1K!17pBE)D+SH)~VuBh4O8-_5*8G9{q1< z@U4Vt@Hg;P7H7yA+Mv}NsyJsuV$BbgiZN*uIV1e=F_^qi2{Dq}CU2tGRMp9npIw7N UW`L2pi%m45xfyv+?-`bW0P`H5X#fBK literal 0 HcmV?d00001 diff --git a/src/components/MyAd.vue b/src/components/MyAd.vue new file mode 100644 index 0000000..6b82a4f --- /dev/null +++ b/src/components/MyAd.vue @@ -0,0 +1,8 @@ + + + diff --git a/src/core/game.ts b/src/core/game.ts index c6a4dd8..e3f904c 100644 --- a/src/core/game.ts +++ b/src/core/game.ts @@ -6,12 +6,12 @@ import { useGlobalStore } from "./globalStore"; // @ts-ignore import _ from "lodash"; -import { nextTick, ref } from "vue"; +import { ref } from "vue"; const useGame = () => { const { gameConfig } = useGlobalStore(); - // 游戏状态:0 - 初始化, 1 - 进行中, 2 - 结束 + // 游戏状态:0 - 初始化, 1 - 进行中, 2 - 失败结束, 3 - 胜利 const gameStatus = ref(0); // 各层块 @@ -26,6 +26,12 @@ const useGame = () => { // 保存所有块(包括随机块) const blockData: Record = {}; + // 总块数 + let totalBlockNum = 0; + + // 已消除块数 + let clearBlockNum = 0; + // 总共划分 24 x 24 的格子,每个块占 3 x 3 的格子,生成的起始 x 和 y 坐标范围均为 0 ~ 21 const boxWidthNum = 24; const boxHeightNum = 24; @@ -86,7 +92,7 @@ const useGame = () => { // 补齐到 blockNumUnit 的倍数 // e.g. minBlockNum = 14, blockNumUnit = 6, 补到 18 - let totalBlockNum = minBlockNum; + totalBlockNum = minBlockNum; if (totalBlockNum % blockNumUnit !== 0) { totalBlockNum = (Math.floor(minBlockNum / blockNumUnit) + 1) * blockNumUnit; @@ -325,6 +331,8 @@ const useGame = () => { if (map[slotBlock.type] >= gameConfig.composeNum) { // 块状态改为已消除 slotBlock.status = 2; + // 已消除块数 +1 + clearBlockNum++; return; } newSlotAreaVal[tempSlotNum++] = slotBlock; @@ -338,6 +346,9 @@ const useGame = () => { alert("你输了"); }, 2000); } + if (clearBlockNum >= totalBlockNum) { + gameStatus.value = 3; + } }; /** diff --git a/src/pages/GamePage.vue b/src/pages/GamePage.vue index 25e3adf..f969494 100644 --- a/src/pages/GamePage.vue +++ b/src/pages/GamePage.vue @@ -2,6 +2,11 @@
返回 + +
+

恭喜,你赢啦!🎉

+ +
- 地域模式 + 地狱模式 自定义 + +
+ + 代码完全开源,欢迎 star +
+