add 添加游戏胜利标识
This commit is contained in:
parent
7d73c64d62
commit
200b2a47d0
@ -6,7 +6,7 @@
|
||||
|
||||
玩法:
|
||||
|
||||
1. 支持选关
|
||||
2. 支持自定义难度(待更新)
|
||||
3. 无限道具(待更新)
|
||||
1. 支持选择难度(4 种)
|
||||
2. 支持自定义难度
|
||||
3. 支持道具
|
||||
|
||||
|
@ -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",
|
||||
|
BIN
src/assets/kunkun.png
Normal file
BIN
src/assets/kunkun.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.3 KiB |
8
src/components/MyAd.vue
Normal file
8
src/components/MyAd.vue
Normal file
@ -0,0 +1,8 @@
|
||||
<template>
|
||||
<div class="my-ad">
|
||||
<a href="https://space.bilibili.com/12890453/"> 欢迎关注程序员鱼皮 </a>
|
||||
<div>广告位招租(狗头)</div>
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts"></script>
|
||||
<style></style>
|
@ -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<number, BlockType> = {};
|
||||
|
||||
// 总块数
|
||||
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;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -2,6 +2,11 @@
|
||||
<div id="gamePage">
|
||||
<a-button style="margin-bottom: 8px" @click="doBack"> 返回</a-button>
|
||||
<a-row align="center">
|
||||
<!-- 胜利 -->
|
||||
<div v-if="gameStatus === 3" style="text-align: center">
|
||||
<h2>恭喜,你赢啦!🎉</h2>
|
||||
<img src="../assets/kunkun.png" />
|
||||
</div>
|
||||
<!-- 分层选块 -->
|
||||
<div class="level-board">
|
||||
<div
|
||||
|
@ -28,16 +28,23 @@
|
||||
style="margin-bottom: 16px"
|
||||
@click="toGamePage(lunaticGameConfig)"
|
||||
>
|
||||
地域模式
|
||||
地狱模式
|
||||
</a-button>
|
||||
<a-button block style="margin-bottom: 16px" @click="toGamePage(null)">
|
||||
自定义
|
||||
</a-button>
|
||||
<a href="https://github.com/liyupi/yulegeyu" target="_blank">
|
||||
<div style="background: rgba(0, 0, 0, 0.8); padding: 12px">
|
||||
<github-outlined />
|
||||
代码完全开源,欢迎 star
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { useRouter } from "vue-router";
|
||||
import { GithubOutlined } from "@ant-design/icons-vue";
|
||||
import {
|
||||
easyGameConfig,
|
||||
middleGameConfig,
|
||||
|
Loading…
Reference in New Issue
Block a user