mirror of
https://github.com/Kugelschieber/breach.git
synced 2026-01-18 03:50:24 +00:00
Added end screen and improved start screen.
This commit is contained in:
18
src/App.vue
18
src/App.vue
@@ -4,7 +4,8 @@
|
|||||||
<Timer />
|
<Timer />
|
||||||
<Buffer />
|
<Buffer />
|
||||||
<Matrix v-on:won="level++" v-on:lost="lost = true" />
|
<Matrix v-on:won="level++" v-on:lost="lost = true" />
|
||||||
<Start :level="level" v-on:start="nextLevel" />
|
<Start :level="level" :lost="lost" v-on:start="nextLevel" />
|
||||||
|
<End :level="level" v-on:restart="restart" v-if="lost" />
|
||||||
</main>
|
</main>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -15,6 +16,7 @@
|
|||||||
import Buffer from "./components/Buffer.vue";
|
import Buffer from "./components/Buffer.vue";
|
||||||
import Matrix from "./components/Matrix.vue";
|
import Matrix from "./components/Matrix.vue";
|
||||||
import Start from "./components/Start.vue";
|
import Start from "./components/Start.vue";
|
||||||
|
import End from "./components/End.vue";
|
||||||
import { Game } from "./game/Game";
|
import { Game } from "./game/Game";
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
@@ -23,7 +25,8 @@
|
|||||||
Timer,
|
Timer,
|
||||||
Buffer,
|
Buffer,
|
||||||
Matrix,
|
Matrix,
|
||||||
Start
|
Start,
|
||||||
|
End
|
||||||
},
|
},
|
||||||
setup() {
|
setup() {
|
||||||
const game = ref(new Game({
|
const game = ref(new Game({
|
||||||
@@ -39,7 +42,7 @@
|
|||||||
timeoutMilliseconds: 60_000,
|
timeoutMilliseconds: 60_000,
|
||||||
}));
|
}));
|
||||||
provide("game", game);
|
provide("game", game);
|
||||||
const level = ref(0);
|
const level = ref(1);
|
||||||
const lost = ref(false);
|
const lost = ref(false);
|
||||||
|
|
||||||
function nextLevel() {
|
function nextLevel() {
|
||||||
@@ -57,10 +60,17 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function restart() {
|
||||||
|
level.value = 1;
|
||||||
|
lost.value = false;
|
||||||
|
nextLevel();
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
level,
|
level,
|
||||||
lost,
|
lost,
|
||||||
nextLevel
|
nextLevel,
|
||||||
|
restart
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
19
src/components/End.vue
Normal file
19
src/components/End.vue
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
<template>
|
||||||
|
<div class="overlay">
|
||||||
|
<div>
|
||||||
|
<div>You lost!</div>
|
||||||
|
<div class="countdown">Level: {{level}}</div>
|
||||||
|
<button v-on:click="$emit('restart')">Play again</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts">
|
||||||
|
import {defineComponent} from "vue";
|
||||||
|
|
||||||
|
export default defineComponent({
|
||||||
|
props: {
|
||||||
|
level: {type: Number, required: true}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
@@ -1,7 +1,8 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="overlay" v-if="countdown > 0">
|
<div class="overlay" v-if="countdown > 0">
|
||||||
<div>
|
<div>
|
||||||
<div class="countdown">{{countdown}}</div>
|
<div>Level: {{level}}</div>
|
||||||
|
<div class="countdown" v-if="interval !== 0">{{countdown}}</div>
|
||||||
<button v-on:click="start" v-if="interval === 0">Start</button>
|
<button v-on:click="start" v-if="interval === 0">Start</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -12,13 +13,14 @@
|
|||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
props: {
|
props: {
|
||||||
level: {type: Number, required: true}
|
level: {type: Number, required: true},
|
||||||
|
lost: {type: Boolean, required: true}
|
||||||
},
|
},
|
||||||
setup(props, {emit}) {
|
setup(props, {emit}) {
|
||||||
const countdown = ref(3);
|
const countdown = ref(3);
|
||||||
const interval = ref(0);
|
const interval = ref(0);
|
||||||
|
|
||||||
watch(() => props.level, () => {
|
watch([() => props.level, () => props.lost], () => {
|
||||||
countdown.value = 3;
|
countdown.value = 3;
|
||||||
interval.value = 0;
|
interval.value = 0;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -146,6 +146,7 @@ main {
|
|||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
text-align: center;
|
||||||
|
|
||||||
.countdown {
|
.countdown {
|
||||||
font-size: 32px;
|
font-size: 32px;
|
||||||
|
|||||||
Reference in New Issue
Block a user