Got a working version of character animations, finished HUD styling, cleaned SCSS, npm update
12
package-lock.json
generated
@ -3408,9 +3408,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/electron-to-chromium": {
|
||||
"version": "1.4.792",
|
||||
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.792.tgz",
|
||||
"integrity": "sha512-rkg5/N3L+Y844JyfgPUyuKK0Hk0efo3JNxUDKvz3HgP6EmN4rNGhr2D8boLsfTV/hGo7ZGAL8djw+jlg99zQyA==",
|
||||
"version": "1.4.795",
|
||||
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.795.tgz",
|
||||
"integrity": "sha512-hHo4lK/8wb4NUa+NJYSFyJ0xedNHiR6ylilDtb8NUW9d4dmBFmGiecYEKCEbti1wTNzbKXLfl4hPWEkAFbHYlw==",
|
||||
"dev": true,
|
||||
"license": "ISC"
|
||||
},
|
||||
@ -6591,9 +6591,9 @@
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/vite": {
|
||||
"version": "5.2.12",
|
||||
"resolved": "https://registry.npmjs.org/vite/-/vite-5.2.12.tgz",
|
||||
"integrity": "sha512-/gC8GxzxMK5ntBwb48pR32GGhENnjtY30G4A0jemunsBkiEZFw60s8InGpN8gkhHEkjnRK1aSAxeQgwvFhUHAA==",
|
||||
"version": "5.2.13",
|
||||
"resolved": "https://registry.npmjs.org/vite/-/vite-5.2.13.tgz",
|
||||
"integrity": "sha512-SSq1noJfY9pR3I1TUENL3rQYDQCFqgD+lM6fTRAM8Nv6Lsg5hDLaXkjETVeBt+7vZBCMoibD+6IWnT2mJ+Zb/A==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
|
Before Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 9.6 KiB |
BIN
public/assets/avatar/default/walk.png
Normal file
After Width: | Height: | Size: 9.8 KiB |
Before Width: | Height: | Size: 10 KiB |
@ -2,8 +2,8 @@
|
||||
<div class="game-container">
|
||||
<div class="top-ui"><Hud /></div>
|
||||
|
||||
<Game :config="gameConfig" class="game" @create="bootGame">
|
||||
<Scene name="main" @preload="preloadScene" @create="bootScene">
|
||||
<Game :config="gameConfig" class="game" @create="createGame">
|
||||
<Scene name="main" @preload="preloadScene" @create="createScene" @play="playScene">
|
||||
<World />
|
||||
</Scene>
|
||||
</Game>
|
||||
@ -40,7 +40,7 @@ const gameConfig = {
|
||||
pixelArt: true
|
||||
}
|
||||
|
||||
const bootGame = (game: Phaser.Game) => {
|
||||
const createGame = (game: Phaser.Game) => {
|
||||
window.addEventListener('resize', () => {
|
||||
game.scale.resize(window.innerWidth, window.innerHeight)
|
||||
})
|
||||
@ -58,9 +58,13 @@ const preloadScene = (scene: Phaser.Scene) => {
|
||||
'character',
|
||||
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAABeCAYAAAAwnXTzAAAHWUlEQVR4nLVaQUhcRxj+DCuILruHXdbnYkBimkdFdouwFBdWKCWHHkoChragmAo9pKG3ltQGWrGHkEpzS0t7Mgn2EiIYcvQiLurBIF0RYYtbFiK6Lhqyiy4BBXt4+8/OzHvz3ryN/eCx782bN9/8//z/P//MbMvHP/wJXXTMTJ45lR+PT7XothHwQzQ8OIBUpt/2fmLaeq9D7EnYMTN5Njw4ALM3iFC8B0Y6ifZYWKjzKJ1EaSWHienJMy/SCzpkqUy/QNZqJISrPRaGkU7i/p0xpdq1CAHA7A0CAIx0UlnHD6mSkKQLxXu8+iTArWOuhCrUyhWclDZc67hJqWWlTqTt2LCV6aApQj8EMjxVWt0tAgBOD8tNEcjwlDBfOAIKm/jE7NJq8Mvr374b4affjwAAXvzyF7uXG300/4Ddz++8wkj3RRwr2vNUaWklBwBIZfqZWud3XmF+5xU66vd+oCQ8Hp9qmVtdx1p2k5Ee5PdweljGm5dPWb2R7ovCd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G68Xl7H203cNQn7mdsqYebLLly8DALq7u21kOzs7trLXi8vo/OJrtG1kgdklu5W6SetGRuVUh7DwIoeT0gbCiQwAzi0oVMnz17uALPXv35+w9m0ShhMZtuOkgqy6xcVFdr+8vGwjvTe7hM/SX+F4fKolAFj+E4jEEDaA2ZFbglsAliF0dnZie3ubqYxIt7e3Gen+/j4WFhYQ3NrC8YciKd0HAMuHDFgBViYLbm2BjFx2D75D5Ao3w22Yc9FOALB85dJhWbnTezPcBoDzP0UdszfoGfgDx+NTLXMzk2epTD9C77+nrGj2BvEw3jizoJyVUslGYrzquBAlMKORM2uZLBTvQdTsYhd/YEI5rQ4uAA3zdUsZqMFAJIZAJCYQ+Nn5F9xClSoQKOMOJzIIRGKOK1xtwuPxqRbV5g4vQauRUBqXnIi5EhKpfl/9k9kIdeB1SHLuhEDzZxZNEXqReTm+L0J5g6EZ+D4KciNqj4VtsViGloRyiuhkkfyK2A2+JSTnr0Ecr3/nl2CkvY3JFyG/tpe3wKq7RVSfFT3b8GU0tL1FC1GnTQfPTvshBKzEFnA2f6fNPBm+/VCWxG8A9yWhMOdJO06+5kMv0OTLuwMvmfzODdoS8u4ANLdsA5oM3u+CcyM8l/PD/wPnRqi7R+CL0K1R3Uzg3CTUzQLOhZCOGXR2ObT+wENwU5vuloq2hHTI7JVa3B0dQsfM5JlqQav9jyEi9UIo3oO7o0PKVbRWaNMJzHydqNmFUHwPZm8Q96QzRF+zhXz0I4PPCAKRrLXInRXnx6anJ1re5QtHMFGsvwdqANph7VrQ3oxvQuv/F43zishHwzBvAak/HmJi+kl9Aeo807seyTqBl8BIW3PeSWlDiDrn9ldBWo4PYwAmrKyskWIsue4Eq+B6jk9w2yTyu8T7D0vv92u9uVoPAAAAAElFTkSuQmCC'
|
||||
)
|
||||
scene.load.spritesheet('characterW', '/assets/avatar/default/walk.png', { frameWidth: 36, frameHeight: 94 })
|
||||
}
|
||||
|
||||
const bootScene = (scene: Phaser.Scene) => {
|
||||
const playScene = (scene: Phaser.Scene) => {
|
||||
}
|
||||
|
||||
const createScene = (scene: Phaser.Scene) => {
|
||||
// Camera drag system
|
||||
let cam = scene.cameras.main
|
||||
scene.input.on('pointermove', function (pointer: Pointer) {
|
||||
@ -69,6 +73,14 @@ const bootScene = (scene: Phaser.Scene) => {
|
||||
cam.scrollY -= (pointer.y - pointer.prevPosition.y) / cam.zoom
|
||||
})
|
||||
|
||||
scene.anims.create({
|
||||
key: "walk",
|
||||
frameRate: 7,
|
||||
frames: scene.anims.generateFrameNumbers("characterW", { start: 0, end: 3 }),
|
||||
repeat: -1,
|
||||
});
|
||||
|
||||
|
||||
// const grid = scene.add.grid(0, 0, window.innerWidth, window.innerHeight, 64, 32, 0, 0, 0xff0000, 0.5).setOrigin(0, 0);
|
||||
//
|
||||
// window.addEventListener('resize', () => {
|
||||
|
@ -14,7 +14,7 @@ import { Container, TilemapLayer as TilemapLayerC, useScene } from 'phavuer'
|
||||
import Character from '@/components/sprites/Character.vue'
|
||||
import { type Character as CharacterType } from '@/types'
|
||||
import { onBeforeMount, ref, type Ref, watch } from 'vue'
|
||||
import Controls from '@/components/Controls.vue'
|
||||
import Controls from '@/components/utilities/Controls.vue'
|
||||
import { useSocketStore } from '@/stores/socket'
|
||||
import { useZoneStore } from '@/stores/zone'
|
||||
|
||||
|
@ -4,12 +4,29 @@
|
||||
<img draggable="false" src="/assets/avatar/default/head.png" />
|
||||
</div>
|
||||
<div class="hud">
|
||||
<div class="stats"></div>
|
||||
<div class="stats">
|
||||
<div class="player-details">
|
||||
<span class="player-name">{{ socket.getCharacter.name }}</span>
|
||||
<span class="player-lvl">lvl. {{ socket.getCharacter.level }}</span>
|
||||
</div>
|
||||
<div class="bar">
|
||||
<label for="hp">HP</label>
|
||||
<progress id="hp" value="21" max="100">21%</progress>
|
||||
</div>
|
||||
<div class="bar">
|
||||
<label for="mp">MP</label>
|
||||
<progress id="mp" value="69" max="100">69%</progress>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts"></script>
|
||||
<script setup lang="ts">
|
||||
import { useSocketStore } from '@/stores/socket'
|
||||
|
||||
const socket = useSocketStore();
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
@import '@/assets/scss/main';
|
||||
@ -18,7 +35,7 @@
|
||||
position: relative;
|
||||
left: -32px;
|
||||
|
||||
.profile, .hud, &::before {
|
||||
.hud, &::before {
|
||||
position: absolute;
|
||||
top: 32px;
|
||||
left: 32px;
|
||||
@ -29,6 +46,7 @@
|
||||
}
|
||||
|
||||
.profile {
|
||||
position: absolute;
|
||||
width: 64px;
|
||||
height: 64px;
|
||||
background-color: rgba($white, 0.8);
|
||||
@ -48,6 +66,55 @@
|
||||
|
||||
.hud {
|
||||
background: url('/assets/shapes/hud-shape.svg') center/cover no-repeat;
|
||||
.stats {
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: end;
|
||||
justify-content: center;
|
||||
padding: 0 20px 0 50px;
|
||||
|
||||
.player-details, .bar {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
span, label {
|
||||
font-size: 14px;
|
||||
}
|
||||
}
|
||||
|
||||
.player-details {
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
.bar {
|
||||
progress {
|
||||
-webkit-appearance: none;
|
||||
appearance: none;
|
||||
height: 8px;
|
||||
border-radius: 8px;
|
||||
max-width: 140px;
|
||||
|
||||
&#hp {
|
||||
accent-color: $red;
|
||||
// Chrome, Safari, Edge, Opera
|
||||
&::-webkit-progress-value { background: $red; border-radius: 8px; }
|
||||
&::-webkit-progress-bar { background: $white; border-radius: 8px; border: 2px solid $white; }
|
||||
// Firefox
|
||||
&::-moz-progress-bar { background: $red; border-radius: 8px; border: 2px solid $white;}
|
||||
}
|
||||
&#mp {
|
||||
accent-color: $light-blue;
|
||||
// Chrome, Safari, Edge, Opera
|
||||
&::-webkit-progress-value { background: $light-blue; border-radius: 8px; }
|
||||
&::-webkit-progress-bar { background: $white; border-radius: 8px; border: 2px solid $white;}
|
||||
// Firefox
|
||||
&::-moz-progress-bar { background: $light-blue; border-radius: 8px; border: 2px solid $white;}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&::before {
|
||||
|
@ -14,13 +14,13 @@
|
||||
stroke: '#213547'
|
||||
}"
|
||||
/>
|
||||
<Sprite ref="sprite" texture="character" :x="props.character.position_x" :y="props.character.position_y" />
|
||||
<Sprite ref="sprite" :x="props.character.position_x" :y="props.character.position_y" play="walk" />
|
||||
</Container>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { Container, Sprite, Text, useScene } from 'phavuer'
|
||||
import { onMounted, reactive, type Ref, ref, watch } from 'vue'
|
||||
import { onBeforeMount, onMounted, reactive, type Ref, ref, watch } from 'vue'
|
||||
import config from '@/config'
|
||||
import { useSocketStore } from '@/stores/socket'
|
||||
import { type Character as CharacterT } from '@/types'
|
||||
@ -79,14 +79,6 @@ function getTile(x: number, y: number, layer: Phaser.Tilemaps.TilemapLayer): Pha
|
||||
return tile
|
||||
}
|
||||
|
||||
scene.anims.create({
|
||||
key: 'walk',
|
||||
frames: scene.anims.generateFrameNumbers('walk', {
|
||||
start: 0,
|
||||
end: 4
|
||||
}),
|
||||
});
|
||||
|
||||
/**
|
||||
* Resources:
|
||||
* https://www.youtube.com/watch?v=9sWrGohw9qo
|
||||
|