-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: wagon can ride on client side (#281)
- Loading branch information
1 parent
e8f71e0
commit 3a6e96b
Showing
64 changed files
with
524 additions
and
212 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<template> | ||
<div class="w-full h-full flex flex-col items-center justify-center"> | ||
<img src="/units/banana/128.png" alt="coming-soon" class="w-24"> | ||
|
||
<h2 class="mt-5 tg-section-header-text text-2xl"> | ||
Скоро будет готово | ||
</h2> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,34 @@ | ||
<template> | ||
<div class="game-block absolute top-0 left-0 right-0 bottom-0 font-serif" :class="{ hidden: !isOpened }"> | ||
<div id="game-canvas" ref="stage" /> | ||
<div class="absolute top-0 left-0 right-0 bottom-0 font-serif overflow-hidden select-none bg-orange-200" :class="{ hidden: !isOpened }"> | ||
<div ref="canvas" class="w-full h-full" /> | ||
|
||
<div class="font-serif touch-pan-x absolute top-0 left-0 right-0 w-full h-16 pt-25"> | ||
<div class="tg-content-safe-area-top font-serif touch-pan-x absolute top-0 left-0 right-0 w-full h-16"> | ||
<div class="max-w-[28rem] mx-auto px-5"> | ||
<div>Монеты: 53</div> | ||
<div>Энергия: 41</div> | ||
|
||
<div v-if="connectedToRoom"> | ||
Room {{ connectedToRoom }} | ||
<div class="opacity-15"> | ||
{{ gameClient.websocketService.socket.status.value }} {{ roomConnected }} {{ gameClient.websocketService.socket.data }} | ||
</div> | ||
<button v-else class="z-50 p-4 bg-amber-800 text-white" @click="() => { connectFunc('12345'); connectedToRoom = '12345' }"> | ||
Подключиться | ||
</button> | ||
</div> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { BaseGameAddon } from '@chat-game/game' | ||
import { gameClient, roomConnected } from '../utils/gameClient' | ||
const router = useRouter() | ||
const stage = ref<HTMLElement>() | ||
const canvas = ref<HTMLElement>() | ||
const isOpened = ref(false) | ||
const connectFunc = ref<(roomId: string) => void>(() => {}) | ||
const connectedToRoom = ref<string | null>(null) | ||
const addon = new BaseGameAddon({ websocketUrl: getEnv('VITE_WEBSOCKET_URL'), client: 'TELEGRAM_CLIENT' }) | ||
onMounted(async () => { | ||
await addon.init() | ||
connectFunc.value = addon.websocketService.connect.bind(addon.websocketService) | ||
stage.value?.appendChild(addon.app.canvas) | ||
await gameClient.init() | ||
canvas.value?.appendChild(gameClient.app.canvas) | ||
return () => addon.destroy() | ||
return () => gameClient.destroy() | ||
}) | ||
watch(router.currentRoute, (value) => { | ||
isOpened.value = value.path === '/' | ||
}) | ||
</script> | ||
|
||
<style scoped> | ||
.game-block { | ||
overflow: hidden; | ||
-webkit-user-select: none; /* Safari */ | ||
-ms-user-select: none; /* IE 10 and IE 11 */ | ||
user-select: none; /* Standard syntax */ | ||
background-color: #ffedd5; | ||
padding-top: var(--tg-content-safe-area-inset-top); | ||
} | ||
#game-canvas { | ||
width: 100%; | ||
height: 100%; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { BaseGameAddon } from '@chat-game/game' | ||
|
||
const gameClient = new BaseGameAddon({ websocketUrl: getEnv('VITE_WEBSOCKET_URL'), client: 'TELEGRAM_CLIENT' }) | ||
|
||
const roomConnected = ref<string>() | ||
|
||
export { gameClient, roomConnected } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<template> | ||
<PageContainer> | ||
<h2 class="mb-2 tg-section-header-text text-2xl"> | ||
Активные комнаты | ||
</h2> | ||
|
||
<div class="flex flex-col gap-2"> | ||
<div v-for="room in rooms" :key="room.id" class="tg-section-bg mb-4 px-3 py-3 flex flex-col gap-2 items-center rounded-md"> | ||
<div> | ||
<div class="text-xl"> | ||
{{ room.name }} | ||
</div> | ||
<div class="tg-hint text-sm"> | ||
{{ room.description }} | ||
</div> | ||
|
||
<button class="mt-4 p-3 tg-button w-full rounded-2xl" @click="connectToToom(room.roomId)"> | ||
Подключиться | ||
</button> | ||
</div> | ||
</div> | ||
</div> | ||
</PageContainer> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { gameClient, roomConnected } from '../utils/gameClient' | ||
function connectToToom(roomId: string) { | ||
gameClient.websocketService.connect(roomId) | ||
roomConnected.value = roomId | ||
} | ||
const rooms = [ | ||
{ | ||
id: 1, | ||
name: 'The Wagon', | ||
description: 'Только на активном стриме hmbanan666! Группа смельчаков ведет Машину, избавляясь от всех препятствий на пути.', | ||
roomId: '12345', | ||
}, | ||
] | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,9 @@ | ||
<template> | ||
<PageContainer> | ||
<div class="tg-section-bg tg-text mb-4 h-16 flex flex-row gap-2 items-center"> | ||
<img :src="data?.photoUrl" alt="avatar" class="w-14 h-14 rounded-full"> | ||
<div> | ||
<div class="text-xl"> | ||
{{ data?.username }} | ||
</div> | ||
<div class="tg-hint text-sm"> | ||
{{ data?.id }} | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<div class="grid grid-cols-4 gap-2"> | ||
<div class="tg-section-bg aspect-square p-2 inventory-item"> | ||
<div>Вещь</div> | ||
</div> | ||
</div> | ||
<ComingSoon /> | ||
</PageContainer> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { initData } from '@telegram-apps/sdk-vue' | ||
const data = initData.user() | ||
import ComingSoon from '@/components/ComingSoon.vue' | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
declare module '*.png' { | ||
const value: string | ||
export default value | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.