╭∩╮( •̀_•́ )╭∩╮
This commit is contained in:
@ -26,17 +26,17 @@
|
||||
<script setup lang="ts">
|
||||
import config from '@/config'
|
||||
import 'phaser'
|
||||
import { onUnmounted, toRaw } from 'vue'
|
||||
import { Game, Scene } from 'phavuer'
|
||||
import { useSocketStore } from '@/stores/socket'
|
||||
import { useZoneEditorStore } from '@/stores/zoneEditor'
|
||||
import { useAssetStore } from '@/stores/assets'
|
||||
import World from '@/components/World.vue'
|
||||
import Hud from '@/components/gui/Hud.vue'
|
||||
import Chat from '@/components/gui/Chat.vue'
|
||||
import Menubar from '@/components/gui/Menu.vue'
|
||||
import { onUnmounted } from 'vue'
|
||||
import GmTools from '@/components/utilities/GmTools.vue'
|
||||
import { useSocketStore } from '@/stores/socket'
|
||||
import { useZoneEditorStore } from '@/stores/zoneEditor'
|
||||
import ZoneEditor from '@/components/utilities/zoneEditor/ZoneEditor.vue'
|
||||
import { useAssetStore } from '@/stores/assets'
|
||||
import type { Asset } from '@/types'
|
||||
|
||||
const socket = useSocketStore()
|
||||
@ -47,7 +47,7 @@ onUnmounted(() => {
|
||||
socket.disconnectSocket()
|
||||
})
|
||||
|
||||
// on page close
|
||||
// On page close
|
||||
addEventListener('beforeunload', () => {
|
||||
socket.disconnectSocket()
|
||||
})
|
||||
@ -61,31 +61,27 @@ const gameConfig = {
|
||||
}
|
||||
|
||||
const createGame = (game: Phaser.Game) => {
|
||||
/**
|
||||
* Resize the game when the window is resized
|
||||
*/
|
||||
addEventListener('resize', () => {
|
||||
game.scale.resize(window.innerWidth, window.innerHeight)
|
||||
})
|
||||
}
|
||||
|
||||
const preloadScene = (scene: Phaser.Scene) => {
|
||||
|
||||
|
||||
socket.connection.emit('assets:download', {}, (response: Asset[]) => {
|
||||
console.log(response);
|
||||
response.forEach((asset) => {
|
||||
assetStore.addAsset(asset)
|
||||
})
|
||||
})
|
||||
|
||||
assetStore.assets.forEach((asset) => {
|
||||
/**
|
||||
* Load the assets into the Phaser scene
|
||||
*/
|
||||
toRaw(assetStore.assets).forEach((asset) => {
|
||||
if (asset.type === 'link') {
|
||||
scene.load.image(asset.key, asset.value)
|
||||
scene.load.image(asset.key, config.server_endpoint + '/assets' + asset.value)
|
||||
}
|
||||
if (asset.type === 'base64') {
|
||||
scene.textures.addBase64(asset.key, asset.value)
|
||||
}
|
||||
})
|
||||
|
||||
scene.load.image('tiles', '/assets/zone/tiles.png')
|
||||
scene.load.image('walls', '/assets/zone/walls.png')
|
||||
scene.load.image('wall1', '/assets/zone/wall1.png')
|
||||
scene.load.image('wall2', '/assets/zone/wall2.png')
|
||||
|
Reference in New Issue
Block a user