mirror of
https://github.com/kokonect-link/cherrypick
synced 2024-12-02 08:48:32 +09:00
🍪 cps
This commit is contained in:
parent
5d13e2744f
commit
7ed905f76b
@ -1,6 +1,7 @@
|
||||
<template>
|
||||
<div>
|
||||
<div v-if="game.ready" :class="$style.game">
|
||||
<div :class="$style.cps" class="">{{ number(cps) }}cps</div>
|
||||
<div :class="$style.count" class=""><i class="ti ti-cookie" style="font-size: 70%;"></i> {{ number(cookies) }}</div>
|
||||
<button v-click-anime class="_button" :class="$style.button" @click="onClick">
|
||||
<img src="/client-assets/cookie.png" :class="$style.img">
|
||||
@ -25,6 +26,8 @@ defineProps<{
|
||||
|
||||
const saveData = game.saveData;
|
||||
const cookies = computed(() => saveData.value?.cookies);
|
||||
let cps = $ref(0);
|
||||
let prevCookies = $ref(0);
|
||||
|
||||
function onClick(ev: MouseEvent) {
|
||||
saveData.value!.cookies++;
|
||||
@ -35,6 +38,15 @@ function onClick(ev: MouseEvent) {
|
||||
os.popup(MkPlusOneEffect, { x, y }, {}, 'end');
|
||||
}
|
||||
|
||||
useInterval(() => {
|
||||
const diff = saveData.value!.cookies - prevCookies;
|
||||
cps = diff;
|
||||
prevCookies = saveData.value!.cookies;
|
||||
}, 1000, {
|
||||
immediate: false,
|
||||
afterMounted: true,
|
||||
});
|
||||
|
||||
useInterval(game.save, 1000 * 5, {
|
||||
immediate: false,
|
||||
afterMounted: true,
|
||||
@ -42,6 +54,7 @@ useInterval(game.save, 1000 * 5, {
|
||||
|
||||
onMounted(async () => {
|
||||
await game.load();
|
||||
prevCookies = saveData.value!.cookies;
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
@ -55,6 +68,13 @@ onUnmounted(() => {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.cps {
|
||||
position: absolute;
|
||||
top: 12px;
|
||||
left: 12px;
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
.count {
|
||||
font-size: 1.3em;
|
||||
margin-bottom: 6px;
|
||||
|
Loading…
Reference in New Issue
Block a user