Updated tiles, improved folder & file structure, npm update, more progress on zone editor
This commit is contained in:
parent
44814907a0
commit
4dcc11706a
18
package-lock.json
generated
18
package-lock.json
generated
@ -3411,9 +3411,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/electron-to-chromium": {
|
"node_modules/electron-to-chromium": {
|
||||||
"version": "1.4.796",
|
"version": "1.4.798",
|
||||||
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.796.tgz",
|
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.798.tgz",
|
||||||
"integrity": "sha512-NglN/xprcM+SHD2XCli4oC6bWe6kHoytcyLKCWXmRL854F0qhPhaYgUswUsglnPxYaNQIg2uMY4BvaomIf3kLA==",
|
"integrity": "sha512-by9J2CiM9KPGj9qfp5U4FcPSbXJG7FNzqnYaY4WLzX+v2PHieVGmnsA4dxfpGE3QEC7JofpPZmn7Vn1B9NR2+Q==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "ISC"
|
"license": "ISC"
|
||||||
},
|
},
|
||||||
@ -5625,9 +5625,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/prettier": {
|
"node_modules/prettier": {
|
||||||
"version": "3.3.1",
|
"version": "3.3.2",
|
||||||
"resolved": "https://registry.npmjs.org/prettier/-/prettier-3.3.1.tgz",
|
"resolved": "https://registry.npmjs.org/prettier/-/prettier-3.3.2.tgz",
|
||||||
"integrity": "sha512-7CAwy5dRsxs8PHXT3twixW9/OEll8MLE0VRPCJyl7CkS6VHGPSlsVaWTiASPTyGyYRyApxlaWTzwUxVNrhcwDg==",
|
"integrity": "sha512-rAVeHYMcv8ATV5d508CFdn+8/pHPpXeIid1DdrPwXnaAdH7cqjVbpJaT5eq4yRAFU/lsbwYwSF/n5iNrdJHPQA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"bin": {
|
"bin": {
|
||||||
@ -5915,9 +5915,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/rrweb-cssom": {
|
"node_modules/rrweb-cssom": {
|
||||||
"version": "0.7.0",
|
"version": "0.7.1",
|
||||||
"resolved": "https://registry.npmjs.org/rrweb-cssom/-/rrweb-cssom-0.7.0.tgz",
|
"resolved": "https://registry.npmjs.org/rrweb-cssom/-/rrweb-cssom-0.7.1.tgz",
|
||||||
"integrity": "sha512-KlSv0pm9kgQSRxXEMgtivPJ4h826YHsuob8pSHcfSZsSXGtvpEAie8S0AnXuObEJ7nhikOb4ahwxDm0H2yW17g==",
|
"integrity": "sha512-TrEMa7JGdVm0UThDJSx7ddw5nVm3UJS9o9CCIZ72B1vSyEZoziDqBYP3XIoi/12lKrJR8rE3jeFHMok2F/Mnsg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 2.2 MiB After Width: | Height: | Size: 2.1 MiB |
@ -10,10 +10,10 @@
|
|||||||
import { type Ref, ref } from 'vue'
|
import { type Ref, ref } from 'vue'
|
||||||
import { useSocketStore } from '@/stores/socket'
|
import { useSocketStore } from '@/stores/socket'
|
||||||
import Notifications from '@/components/utilities/Notifications.vue'
|
import Notifications from '@/components/utilities/Notifications.vue'
|
||||||
import Login from '@/components/screens/Login.vue'
|
import Login from '@/screens/Login.vue'
|
||||||
import Register from '@/components/screens/Register.vue'
|
import Register from '@/screens/Register.vue'
|
||||||
import Characters from '@/components/screens/Characters.vue'
|
import Characters from '@/screens/Characters.vue'
|
||||||
import Game from '@/components/Game.vue'
|
import Game from '@/screens/Game.vue'
|
||||||
|
|
||||||
const screen: Ref<string> = ref('login')
|
const screen: Ref<string> = ref('login')
|
||||||
const socket = useSocketStore()
|
const socket = useSocketStore()
|
||||||
|
@ -4,10 +4,14 @@
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { Image, useScene } from 'phavuer'
|
import { Image, useScene } from 'phavuer'
|
||||||
import { onBeforeUnmount, ref } from 'vue'
|
import { onBeforeUnmount, ref, watch } from 'vue'
|
||||||
import config from '@/config'
|
import config from '@/config'
|
||||||
import { getTile, tileToWorldXY } from '@/services/zone'
|
import { getTile, tileToWorldXY } from '@/services/zone'
|
||||||
|
import { useZoneStore } from '@/stores/zone'
|
||||||
|
import { useZoneEditorStore } from '@/stores/zoneEditor'
|
||||||
|
|
||||||
|
const zoneStore = useZoneStore();
|
||||||
|
const zoneEditorStore = useZoneEditorStore();
|
||||||
const scene = useScene()
|
const scene = useScene()
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
layer: Phaser.Tilemaps.TilemapLayer
|
layer: Phaser.Tilemaps.TilemapLayer
|
||||||
@ -38,7 +42,29 @@ function onPointerMove(pointer: Phaser.Input.Pointer) {
|
|||||||
|
|
||||||
scene.input.on(Phaser.Input.Events.POINTER_MOVE, onPointerMove)
|
scene.input.on(Phaser.Input.Events.POINTER_MOVE, onPointerMove)
|
||||||
|
|
||||||
|
// Zone camera system
|
||||||
|
function dragZone (pointer: Phaser.Input.Pointer) {
|
||||||
|
if (!pointer.isDown) return
|
||||||
|
cam.scrollX -= (pointer.x - pointer.prevPosition.x) / cam.zoom
|
||||||
|
cam.scrollY -= (pointer.y - pointer.prevPosition.y) / cam.zoom
|
||||||
|
}
|
||||||
|
let cam = scene.cameras.main
|
||||||
|
scene.input.on(Phaser.Input.Events.POINTER_MOVE, dragZone)
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => zoneEditorStore.tool, () => {
|
||||||
|
// @TODO : change to tiles for when loading other maps
|
||||||
|
if (zoneEditorStore.tool === 'move') {
|
||||||
|
scene.input.on(Phaser.Input.Events.POINTER_MOVE, dragZone)
|
||||||
|
} else {
|
||||||
|
scene.input.off(Phaser.Input.Events.POINTER_MOVE, dragZone)
|
||||||
|
}
|
||||||
|
}, { deep: true }
|
||||||
|
)
|
||||||
|
|
||||||
|
// Unload funcs
|
||||||
onBeforeUnmount(() => {
|
onBeforeUnmount(() => {
|
||||||
scene.input.off(Phaser.Input.Events.POINTER_MOVE, onPointerMove)
|
scene.input.off(Phaser.Input.Events.POINTER_MOVE, onPointerMove)
|
||||||
|
scene.input.off(Phaser.Input.Events.POINTER_MOVE, dragZone)
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
<template #modalBody>
|
<template #modalBody>
|
||||||
<canvas ref="canvas" :width="tileWidth" :height="tileHeight" style="display: none"></canvas>
|
<canvas ref="canvas" :width="tileWidth" :height="tileHeight" style="display: none"></canvas>
|
||||||
<div class="tiles">
|
<div class="tiles">
|
||||||
<img v-for="(tile, index) in tiles" :key="index" :src="tile" alt="Tile" @click="selectTile(index)" :class="{ selected: selectedTile === index }" />
|
<img v-for="(tile, index) in tiles" :key="index" :src="tile" alt="Tile" @click="zoneEditorStore.setSelectedTile(index)" :class="{ selected: zoneEditorStore.selectedTile && zoneEditorStore.selectedTile === index }" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</Modal>
|
</Modal>
|
||||||
@ -18,6 +18,7 @@
|
|||||||
import { ref, onMounted, nextTick } from 'vue'
|
import { ref, onMounted, nextTick } from 'vue'
|
||||||
import config from '@/config'
|
import config from '@/config'
|
||||||
import Modal from '@/components/utilities/Modal.vue'
|
import Modal from '@/components/utilities/Modal.vue'
|
||||||
|
import { useZoneEditorStore } from '@/stores/zoneEditor'
|
||||||
|
|
||||||
const tileWidth = config.tile_size.x
|
const tileWidth = config.tile_size.x
|
||||||
const tileHeight = config.tile_size.y
|
const tileHeight = config.tile_size.y
|
||||||
@ -25,6 +26,7 @@ const tiles = ref<string[]>([])
|
|||||||
const selectedTile = ref<number | null>(null)
|
const selectedTile = ref<number | null>(null)
|
||||||
const canvas = ref<HTMLCanvasElement | null>(null)
|
const canvas = ref<HTMLCanvasElement | null>(null)
|
||||||
const isModalOpen = ref(false)
|
const isModalOpen = ref(false)
|
||||||
|
const zoneEditorStore = useZoneEditorStore()
|
||||||
|
|
||||||
// Hardcoded image path
|
// Hardcoded image path
|
||||||
const imagePath = '/assets/tiles/default.png'
|
const imagePath = '/assets/tiles/default.png'
|
||||||
|
@ -2,16 +2,16 @@
|
|||||||
<div class="wrapper">
|
<div class="wrapper">
|
||||||
<div class="toolbar">
|
<div class="toolbar">
|
||||||
<div class="tools">
|
<div class="tools">
|
||||||
<button :class="{ active: activeTool === 'move' }" @click="activeTool = 'move'">
|
<button :class="{ active: zoneEditorStore.tool === 'move' }" @click="zoneEditorStore.setTool('move')">
|
||||||
<img src="/assets/icons/zoneEditor/move.svg" alt="Eraser tool" />
|
<img src="/assets/icons/zoneEditor/move.svg" alt="Move camera" />
|
||||||
</button>
|
</button>
|
||||||
<div class="divider"></div>
|
<div class="divider"></div>
|
||||||
<button :class="{ active: activeTool === 'tiles' }" @click="activeTool = 'tiles'">
|
<button :class="{ active: zoneEditorStore.tool === 'tile' }" @click="zoneEditorStore.setTool('tile')">
|
||||||
<img src="/assets/icons/zoneEditor/tiles.svg" alt="Eraser tool" />
|
<img src="/assets/icons/zoneEditor/tiles.svg" alt="Draw tiles" />
|
||||||
</button>
|
</button>
|
||||||
<div class="divider"></div>
|
<div class="divider"></div>
|
||||||
<button :class="{ active: activeTool === 'eraser' }" @click="activeTool = 'eraser'">
|
<button :class="{ active: zoneEditorStore.tool === 'eraser' }" @click="zoneEditorStore.setTool('eraser')">
|
||||||
<img src="/assets/icons/zoneEditor/eraser.svg" alt="Eraser tool" />
|
<img src="/assets/icons/zoneEditor/eraser.svg" alt="Eraser" />
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="buttons">
|
<div class="buttons">
|
||||||
@ -38,10 +38,11 @@ const props = defineProps({
|
|||||||
layer: Phaser.Tilemaps.TilemapLayer
|
layer: Phaser.Tilemaps.TilemapLayer
|
||||||
})
|
})
|
||||||
const scene = useScene()
|
const scene = useScene()
|
||||||
const activeTool = ref('move')
|
|
||||||
const emit = defineEmits(['erase', 'move', 'tile'])
|
const emit = defineEmits(['erase', 'move', 'tile'])
|
||||||
|
|
||||||
function onPointerClick(pointer: Phaser.Input.Pointer) {
|
function drawTiles(pointer: Phaser.Input.Pointer) {
|
||||||
|
if (!pointer.isDown) return
|
||||||
|
|
||||||
const px = scene.cameras.main.worldView.x + pointer.x
|
const px = scene.cameras.main.worldView.x + pointer.x
|
||||||
const py = scene.cameras.main.worldView.y + pointer.y
|
const py = scene.cameras.main.worldView.y + pointer.y
|
||||||
|
|
||||||
@ -50,15 +51,19 @@ function onPointerClick(pointer: Phaser.Input.Pointer) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (activeTool.value === 'eraser') {
|
if (zoneEditorStore.tool === 'eraser') {
|
||||||
emit('erase', pointer_tile)
|
emit('erase', pointer_tile)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (zoneEditorStore.tool === 'tile') {
|
||||||
|
emit('tile', pointer_tile)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
scene.input.on(Phaser.Input.Events.POINTER_UP, onPointerClick)
|
scene.input.on(Phaser.Input.Events.POINTER_MOVE, drawTiles)
|
||||||
|
|
||||||
onBeforeUnmount(() => {
|
onBeforeUnmount(() => {
|
||||||
scene.input.off(Phaser.Input.Events.POINTER_UP, onPointerClick)
|
scene.input.off(Phaser.Input.Events.POINTER_MOVE, drawTiles)
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@ import { useSocketStore } from '@/stores/socket'
|
|||||||
import { useZoneStore } from '@/stores/zone'
|
import { useZoneStore } from '@/stores/zone'
|
||||||
import Toolbar from '@/components/utilities/zoneEditor/Toolbar.vue'
|
import Toolbar from '@/components/utilities/zoneEditor/Toolbar.vue'
|
||||||
import Tiles from '@/components/utilities/zoneEditor/Tiles.vue'
|
import Tiles from '@/components/utilities/zoneEditor/Tiles.vue'
|
||||||
|
import { useZoneEditorStore } from '@/stores/zoneEditor'
|
||||||
|
|
||||||
// Phavuer logic
|
// Phavuer logic
|
||||||
let scene = useScene()
|
let scene = useScene()
|
||||||
@ -39,6 +40,7 @@ scene.cameras.main.centerOn(centerX, centerY)
|
|||||||
|
|
||||||
// Multiplayer / server logics
|
// Multiplayer / server logics
|
||||||
const zoneStore = useZoneStore()
|
const zoneStore = useZoneStore()
|
||||||
|
const zoneEditorStore = useZoneEditorStore()
|
||||||
const socket = useSocketStore()
|
const socket = useSocketStore()
|
||||||
|
|
||||||
zoneStore.setTiles([
|
zoneStore.setTiles([
|
||||||
@ -66,8 +68,11 @@ watch(
|
|||||||
)
|
)
|
||||||
|
|
||||||
function erase(tile: Phaser.Tilemaps.Tile) {
|
function erase(tile: Phaser.Tilemaps.Tile) {
|
||||||
layer.removeTileAt(tile.x, tile.y)
|
layer.putTileAt(0, tile.x, tile.y)
|
||||||
}
|
}
|
||||||
|
|
||||||
function tile() {}
|
function tile(tile: Phaser.Tilemaps.Tile) {
|
||||||
|
if (zoneEditorStore.selectedTile === null) return
|
||||||
|
layer.putTileAt(zoneEditorStore.selectedTile, tile.x, tile.y)
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
<Game class="game" :config="gameConfig" @create="createGame">
|
<Game class="game" :config="gameConfig" @create="createGame">
|
||||||
<Scene name="main" @preload="preloadScene" @create="createScene">
|
<Scene name="main" @preload="preloadScene" @create="createScene">
|
||||||
<GmTools />
|
<GmTools />
|
||||||
<div v-if="!zoneEditorStore.isActive">
|
<div v-if="!zoneEditorStore.active">
|
||||||
<div class="top-ui"><Hud /></div>
|
<div class="top-ui"><Hud /></div>
|
||||||
<World />
|
<World />
|
||||||
<div class="bottom-ui"><Chat /> <Menubar /></div>
|
<div class="bottom-ui"><Chat /> <Menubar /></div>
|
||||||
@ -27,7 +27,6 @@ import { onUnmounted } from 'vue'
|
|||||||
import GmTools from '@/components/utilities/GmTools.vue'
|
import GmTools from '@/components/utilities/GmTools.vue'
|
||||||
import { useSocketStore } from '@/stores/socket'
|
import { useSocketStore } from '@/stores/socket'
|
||||||
import { useZoneEditorStore } from '@/stores/zoneEditor'
|
import { useZoneEditorStore } from '@/stores/zoneEditor'
|
||||||
import Toolbar from '@/components/utilities/zoneEditor/Toolbar.vue'
|
|
||||||
import ZoneEditor from '@/components/utilities/zoneEditor/ZoneEditor.vue'
|
import ZoneEditor from '@/components/utilities/zoneEditor/ZoneEditor.vue'
|
||||||
|
|
||||||
const socket = useSocketStore()
|
const socket = useSocketStore()
|
||||||
@ -74,14 +73,6 @@ const preloadScene = (scene: Phaser.Scene) => {
|
|||||||
const playScene = (scene: Phaser.Scene) => {}
|
const playScene = (scene: Phaser.Scene) => {}
|
||||||
|
|
||||||
const createScene = (scene: Phaser.Scene) => {
|
const createScene = (scene: Phaser.Scene) => {
|
||||||
// Camera drag system
|
|
||||||
let cam = scene.cameras.main
|
|
||||||
scene.input.on('pointermove', function (pointer: Phaser.Input.Pointer) {
|
|
||||||
if (!pointer.isDown) return
|
|
||||||
cam.scrollX -= (pointer.x - pointer.prevPosition.x) / cam.zoom
|
|
||||||
cam.scrollY -= (pointer.y - pointer.prevPosition.y) / cam.zoom
|
|
||||||
})
|
|
||||||
|
|
||||||
scene.anims.create({
|
scene.anims.create({
|
||||||
key: 'walk',
|
key: 'walk',
|
||||||
frameRate: 7,
|
frameRate: 7,
|
@ -27,7 +27,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref } from 'vue'
|
import { onMounted, ref } from 'vue'
|
||||||
import { login, register } from '@/services/authentication'
|
import { login, register } from '@/services/authentication'
|
||||||
import { useNotificationStore } from '@/stores/notifications'
|
import { useNotificationStore } from '@/stores/notifications'
|
||||||
import { useSocketStore } from '@/stores/socket'
|
import { useSocketStore } from '@/stores/socket'
|
||||||
@ -43,6 +43,18 @@ const notifications = useNotificationStore()
|
|||||||
const username = ref('')
|
const username = ref('')
|
||||||
const password = ref('')
|
const password = ref('')
|
||||||
|
|
||||||
|
// automatic login because of development
|
||||||
|
onMounted(async () => {
|
||||||
|
const response = await login('ethereal', 'kanker123')
|
||||||
|
|
||||||
|
if (response.success === undefined) {
|
||||||
|
notifications.addNotification({ message: response.error })
|
||||||
|
}
|
||||||
|
|
||||||
|
socket.setToken(response.token)
|
||||||
|
socket.initConnection()
|
||||||
|
})
|
||||||
|
|
||||||
async function loginFunc() {
|
async function loginFunc() {
|
||||||
// check if username and password are valid
|
// check if username and password are valid
|
||||||
if (username.value === '' || password.value === '') {
|
if (username.value === '' || password.value === '') {
|
@ -3,15 +3,20 @@ import config from '@/config'
|
|||||||
|
|
||||||
export const useZoneEditorStore = defineStore('zoneEditor', {
|
export const useZoneEditorStore = defineStore('zoneEditor', {
|
||||||
state: () => ({
|
state: () => ({
|
||||||
active: true
|
active: true,
|
||||||
|
tool: 'move',
|
||||||
|
selectedTile: null,
|
||||||
}),
|
}),
|
||||||
getters: {
|
|
||||||
isActive: (state) => state.active
|
|
||||||
},
|
|
||||||
actions: {
|
actions: {
|
||||||
toggleActive() {
|
toggleActive() {
|
||||||
this.active = !this.active
|
this.active = !this.active
|
||||||
}
|
},
|
||||||
|
setTool(tool: string) {
|
||||||
|
this.tool = tool
|
||||||
|
},
|
||||||
|
setSelectedTile(tile: any) {
|
||||||
|
this.selectedTile = tile
|
||||||
|
},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user