Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
200b2a47d0 | ||
|
7d73c64d62 |
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
玩法:
|
玩法:
|
||||||
|
|
||||||
1. 支持选关
|
1. 支持选择难度(4 种)
|
||||||
2. 支持自定义难度(待更新)
|
2. 支持自定义难度
|
||||||
3. 无限道具(待更新)
|
3. 支持道具
|
||||||
|
|
||||||
|
@@ -8,6 +8,7 @@
|
|||||||
"preview": "vite preview"
|
"preview": "vite preview"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@ant-design/icons-vue": "^6.1.0",
|
||||||
"ant-design-vue": "^3.2.11",
|
"ant-design-vue": "^3.2.11",
|
||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21",
|
||||||
"pinia": "^2.0.19",
|
"pinia": "^2.0.19",
|
||||||
|
@@ -24,7 +24,7 @@
|
|||||||
#app {
|
#app {
|
||||||
padding: 16px 16px 50px;
|
padding: 16px 16px 50px;
|
||||||
background: url("assets/bg.jpeg");
|
background: url("assets/bg.jpeg");
|
||||||
height: 100vh;
|
min-height: 100vh;
|
||||||
background-size: 100% 100%;
|
background-size: 100% 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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>
|
@@ -1,6 +1,7 @@
|
|||||||
import { RouteRecordRaw } from "vue-router";
|
import { RouteRecordRaw } from "vue-router";
|
||||||
import IndexPage from "../pages/IndexPage.vue";
|
import IndexPage from "../pages/IndexPage.vue";
|
||||||
import GamePage from "../pages/GamePage.vue";
|
import GamePage from "../pages/GamePage.vue";
|
||||||
|
import ConfigPage from "../pages/ConfigPage.vue";
|
||||||
|
|
||||||
export default [
|
export default [
|
||||||
{
|
{
|
||||||
@@ -11,4 +12,8 @@ export default [
|
|||||||
path: "/game",
|
path: "/game",
|
||||||
component: GamePage,
|
component: GamePage,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: "/config",
|
||||||
|
component: ConfigPage,
|
||||||
|
},
|
||||||
] as RouteRecordRaw[];
|
] as RouteRecordRaw[];
|
||||||
|
@@ -6,12 +6,12 @@
|
|||||||
import { useGlobalStore } from "./globalStore";
|
import { useGlobalStore } from "./globalStore";
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
import { nextTick, ref } from "vue";
|
import { ref } from "vue";
|
||||||
|
|
||||||
const useGame = () => {
|
const useGame = () => {
|
||||||
const { gameConfig } = useGlobalStore();
|
const { gameConfig } = useGlobalStore();
|
||||||
|
|
||||||
// 游戏状态:0 - 初始化, 1 - 进行中, 2 - 结束
|
// 游戏状态:0 - 初始化, 1 - 进行中, 2 - 失败结束, 3 - 胜利
|
||||||
const gameStatus = ref(0);
|
const gameStatus = ref(0);
|
||||||
|
|
||||||
// 各层块
|
// 各层块
|
||||||
@@ -26,6 +26,12 @@ const useGame = () => {
|
|||||||
// 保存所有块(包括随机块)
|
// 保存所有块(包括随机块)
|
||||||
const blockData: Record<number, BlockType> = {};
|
const blockData: Record<number, BlockType> = {};
|
||||||
|
|
||||||
|
// 总块数
|
||||||
|
let totalBlockNum = 0;
|
||||||
|
|
||||||
|
// 已消除块数
|
||||||
|
let clearBlockNum = 0;
|
||||||
|
|
||||||
// 总共划分 24 x 24 的格子,每个块占 3 x 3 的格子,生成的起始 x 和 y 坐标范围均为 0 ~ 21
|
// 总共划分 24 x 24 的格子,每个块占 3 x 3 的格子,生成的起始 x 和 y 坐标范围均为 0 ~ 21
|
||||||
const boxWidthNum = 24;
|
const boxWidthNum = 24;
|
||||||
const boxHeightNum = 24;
|
const boxHeightNum = 24;
|
||||||
@@ -86,7 +92,7 @@ const useGame = () => {
|
|||||||
|
|
||||||
// 补齐到 blockNumUnit 的倍数
|
// 补齐到 blockNumUnit 的倍数
|
||||||
// e.g. minBlockNum = 14, blockNumUnit = 6, 补到 18
|
// e.g. minBlockNum = 14, blockNumUnit = 6, 补到 18
|
||||||
let totalBlockNum = minBlockNum;
|
totalBlockNum = minBlockNum;
|
||||||
if (totalBlockNum % blockNumUnit !== 0) {
|
if (totalBlockNum % blockNumUnit !== 0) {
|
||||||
totalBlockNum =
|
totalBlockNum =
|
||||||
(Math.floor(minBlockNum / blockNumUnit) + 1) * blockNumUnit;
|
(Math.floor(minBlockNum / blockNumUnit) + 1) * blockNumUnit;
|
||||||
@@ -325,6 +331,8 @@ const useGame = () => {
|
|||||||
if (map[slotBlock.type] >= gameConfig.composeNum) {
|
if (map[slotBlock.type] >= gameConfig.composeNum) {
|
||||||
// 块状态改为已消除
|
// 块状态改为已消除
|
||||||
slotBlock.status = 2;
|
slotBlock.status = 2;
|
||||||
|
// 已消除块数 +1
|
||||||
|
clearBlockNum++;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
newSlotAreaVal[tempSlotNum++] = slotBlock;
|
newSlotAreaVal[tempSlotNum++] = slotBlock;
|
||||||
@@ -338,6 +346,9 @@ const useGame = () => {
|
|||||||
alert("你输了");
|
alert("你输了");
|
||||||
}, 2000);
|
}, 2000);
|
||||||
}
|
}
|
||||||
|
if (clearBlockNum >= totalBlockNum) {
|
||||||
|
gameStatus.value = 3;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
75
src/pages/ConfigPage.vue
Normal file
75
src/pages/ConfigPage.vue
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
<template>
|
||||||
|
<div id="customConfigPage">
|
||||||
|
<h2>
|
||||||
|
自定义难度
|
||||||
|
<a-button style="float: right" @click="doBack">返回</a-button>
|
||||||
|
</h2>
|
||||||
|
<a-form
|
||||||
|
ref="formRef"
|
||||||
|
label-align="left"
|
||||||
|
:label-col="{ style: { width: '120px' } }"
|
||||||
|
:model="config"
|
||||||
|
@finish="handleFinish"
|
||||||
|
>
|
||||||
|
<a-form-item label="槽容量" name="slotNum">
|
||||||
|
<a-input-number v-model:value="config.slotNum" />
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item label="合成数" name="composeNum">
|
||||||
|
<a-input-number v-model:value="config.composeNum" />
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item label="动物数" name="typeNum">
|
||||||
|
<a-input-number v-model:value="config.typeNum" />
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item label="总层数" name="levelNum">
|
||||||
|
<a-input-number v-model:value="config.levelNum" />
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item label="每层块数" name="levelBlockNum">
|
||||||
|
<a-input-number v-model:value="config.levelBlockNum" />
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item label="边界收缩" name="borderStep">
|
||||||
|
<a-input-number v-model:value="config.borderStep" />
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item>
|
||||||
|
<a-button
|
||||||
|
type="primary"
|
||||||
|
html-type="submit"
|
||||||
|
style="margin-bottom: 12px"
|
||||||
|
block
|
||||||
|
>
|
||||||
|
开始
|
||||||
|
</a-button>
|
||||||
|
<a-button block @click="resetForm">重置</a-button>
|
||||||
|
</a-form-item>
|
||||||
|
</a-form>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { reactive, ref } from "vue";
|
||||||
|
import { FormInstance } from "ant-design-vue";
|
||||||
|
import { useRouter } from "vue-router";
|
||||||
|
import { useGlobalStore } from "../core/globalStore";
|
||||||
|
import { defaultGameConfig } from "../core/gameConfig";
|
||||||
|
|
||||||
|
const formRef = ref<FormInstance>();
|
||||||
|
const router = useRouter();
|
||||||
|
const { setGameConfig, setCustomConfig } = useGlobalStore();
|
||||||
|
const config = reactive<GameConfig>({ ...defaultGameConfig });
|
||||||
|
|
||||||
|
const handleFinish = (values: GameConfig) => {
|
||||||
|
setGameConfig(config);
|
||||||
|
setCustomConfig(config);
|
||||||
|
router.push("/game");
|
||||||
|
};
|
||||||
|
|
||||||
|
const resetForm = () => {
|
||||||
|
formRef?.value?.resetFields();
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 回上一页
|
||||||
|
*/
|
||||||
|
const doBack = () => {
|
||||||
|
router.back();
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
<style></style>
|
@@ -1,7 +1,12 @@
|
|||||||
<template>
|
<template>
|
||||||
<div id="gamePage">
|
<div id="gamePage">
|
||||||
<a-button @click="doBack"> ⬅️ 返回</a-button>
|
<a-button style="margin-bottom: 8px" @click="doBack"> 返回</a-button>
|
||||||
<a-row align="center">
|
<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 class="level-board">
|
||||||
<div
|
<div
|
||||||
|
@@ -28,16 +28,23 @@
|
|||||||
style="margin-bottom: 16px"
|
style="margin-bottom: 16px"
|
||||||
@click="toGamePage(lunaticGameConfig)"
|
@click="toGamePage(lunaticGameConfig)"
|
||||||
>
|
>
|
||||||
地域模式
|
地狱模式
|
||||||
</a-button>
|
</a-button>
|
||||||
<a-button block style="margin-bottom: 16px" disabled @click="toGamePage">
|
<a-button block style="margin-bottom: 16px" @click="toGamePage(null)">
|
||||||
自定义(暂未开放)
|
自定义
|
||||||
</a-button>
|
</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>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { useRouter } from "vue-router";
|
import { useRouter } from "vue-router";
|
||||||
|
import { GithubOutlined } from "@ant-design/icons-vue";
|
||||||
import {
|
import {
|
||||||
easyGameConfig,
|
easyGameConfig,
|
||||||
middleGameConfig,
|
middleGameConfig,
|
||||||
@@ -53,8 +60,10 @@ const { setGameConfig } = useGlobalStore();
|
|||||||
const toGamePage = (config?: GameConfig) => {
|
const toGamePage = (config?: GameConfig) => {
|
||||||
if (config) {
|
if (config) {
|
||||||
setGameConfig(config);
|
setGameConfig(config);
|
||||||
|
router.push("/game");
|
||||||
|
} else {
|
||||||
|
router.push("/config");
|
||||||
}
|
}
|
||||||
router.push("/game");
|
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user