small fixes, score counter
This commit is contained in:
parent
9fb044eac9
commit
f0f10e4bed
@ -12,6 +12,7 @@
|
|||||||
<Bubble v-if="traversing" :bubble="traversing" :radius="radius" />
|
<Bubble v-if="traversing" :bubble="traversing" :radius="radius" />
|
||||||
|
|
||||||
<Shooter v-if="next" :center="next" :radius="radius" :angle="angle" />
|
<Shooter v-if="next" :center="next" :radius="radius" :angle="angle" />
|
||||||
|
<ScoreDisplay :score="score" />
|
||||||
<GameOver v-if="gameOver" :score="score">{{
|
<GameOver v-if="gameOver" :score="score">{{
|
||||||
victory ? 'You won!' : 'Game over.'
|
victory ? 'You won!' : 'Game over.'
|
||||||
}}</GameOver>
|
}}</GameOver>
|
||||||
@ -19,13 +20,14 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { nextTick, onMounted, ref } from 'vue';
|
import { onMounted, ref } from 'vue';
|
||||||
import { BubbleType } from '../lib/types';
|
import { BubbleType } from '../lib/types';
|
||||||
import GameObjects from './GameObjects.vue';
|
import GameObjects from './GameObjects.vue';
|
||||||
import Bubble from './Bubble.vue';
|
import Bubble from './Bubble.vue';
|
||||||
import { computed } from '@vue/reactivity';
|
import { computed } from '@vue/reactivity';
|
||||||
import Shooter from './Shooter.vue';
|
import Shooter from './Shooter.vue';
|
||||||
import GameOver from './GameOver.vue';
|
import GameOver from './GameOver.vue';
|
||||||
|
import ScoreDisplay from './ScoreDisplay.vue';
|
||||||
|
|
||||||
const width = 612;
|
const width = 612;
|
||||||
const height = 864;
|
const height = 864;
|
||||||
@ -95,6 +97,7 @@ function reset() {
|
|||||||
field.value = [];
|
field.value = [];
|
||||||
offset.value = 0;
|
offset.value = 0;
|
||||||
generate();
|
generate();
|
||||||
|
score.value = 0;
|
||||||
gameOver.value = false;
|
gameOver.value = false;
|
||||||
victory.value = false;
|
victory.value = false;
|
||||||
}
|
}
|
||||||
@ -312,8 +315,6 @@ function stopDead() {
|
|||||||
field.value.push(item);
|
field.value.push(item);
|
||||||
traversing.value = null;
|
traversing.value = null;
|
||||||
|
|
||||||
determineNext();
|
|
||||||
|
|
||||||
const chain = checkForPops(item);
|
const chain = checkForPops(item);
|
||||||
if (chain.length >= 3) {
|
if (chain.length >= 3) {
|
||||||
score.value += chain.length;
|
score.value += chain.length;
|
||||||
@ -328,7 +329,9 @@ function stopDead() {
|
|||||||
shotsLeft.value = 4;
|
shotsLeft.value = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!field.value.length) {
|
determineNext();
|
||||||
|
|
||||||
|
if (!field.value.filter((x) => !x.exiting).length) {
|
||||||
victory.value = true;
|
victory.value = true;
|
||||||
gameOver.value = true;
|
gameOver.value = true;
|
||||||
}
|
}
|
||||||
|
7
src/components/ScoreDisplay.vue
Normal file
7
src/components/ScoreDisplay.vue
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<template>
|
||||||
|
<div class="game-score">Score: {{ score }}</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
defineProps<{ score: number }>();
|
||||||
|
</script>
|
@ -39,9 +39,17 @@ body {
|
|||||||
.game {
|
.game {
|
||||||
background-color: #ddd;
|
background-color: #ddd;
|
||||||
position: relative;
|
position: relative;
|
||||||
overflow: hidden;
|
|
||||||
margin: auto;
|
margin: auto;
|
||||||
|
|
||||||
|
&-field {
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
&-score {
|
||||||
|
position: absolute;
|
||||||
|
bottom: -1.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
&-pointer {
|
&-pointer {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
width: 100px;
|
width: 100px;
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
import { defineConfig } from 'vite'
|
import { defineConfig } from 'vite';
|
||||||
import vue from '@vitejs/plugin-vue'
|
import vue from '@vitejs/plugin-vue';
|
||||||
|
|
||||||
// https://vitejs.dev/config/
|
// https://vitejs.dev/config/
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
plugins: [vue()]
|
plugins: [vue()],
|
||||||
})
|
base: '',
|
||||||
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user