Game settings change

This commit is contained in:
Thomas
2020-11-02 15:31:11 +01:00
parent 41676a09bc
commit 6abf1aa267
6 changed files with 7 additions and 25 deletions

View File

@@ -11,7 +11,7 @@
Original
</b-radio-button>
<b-radio-button v-model="music" native-value="2">
Ambiance
None
</b-radio-button>
</b-field>
</div>
@@ -31,7 +31,7 @@ export default {
},
data () {
return {
music: 0
music: '2'
}
},
computed: {
@@ -47,7 +47,6 @@ export default {
},
watch: {
music: function (music) {
console.log('MUSIC ' + music)
sound.stopBackgroundMusic()
sound.startBackgroundMusic(music)
}

Binary file not shown.

View File

@@ -1,6 +1,4 @@
const music1 = new Audio(require('@/assets/sound/revengeOfCats.mp3'))
const music2 = new Audio(require('@/assets/sound/1992.mp3'))
// const motor = new Audio(require('@/assets/sound/motor.mp3'))
const explosion = new Audio(require('@/assets/sound/explosion.mp3'))
const taunt = new Audio(require('@/assets/sound/tmauvais.mp3'))
@@ -9,31 +7,18 @@ explosion.volume = 0.2
music1.loop = true
music1.volume = 0.2
music2.loop = true
music2.volume = 0.2
export const sound = {
startBackgroundMusic (n) {
switch (n) {
case '1': music1.play(); break
case '2': music2.play(); break
}
},
stopBackgroundMusic () {
music1.pause()
music2.pause()
},
explosion () {
if (Math.floor(Math.random() * Math.floor(10)) === 0) taunt.play()
explosion.play()
}
/*
startMotor () {
motor.loop = true
motor.play()
},
stopMotor () {
motor.pause()
}
*/
}

View File

@@ -17,7 +17,6 @@ export default function createSocketPlugin () {
connection.onerror = function (error) {
console.log('[WS] error ' + error.message)
// store.dispatch('game/error', 'Connection problem')
Toast.open('Connection problem. Retrying in 10s...')
setTimeout(function () {
location.reload()

View File

@@ -26,7 +26,7 @@ function login (connection, name) {
gameSettings: gameSettings
}))
if (updateInterval === -1) updateInterval = setInterval(() => step(), 1000)
if (updateInterval === -1) updateInterval = setInterval(() => step(), 1000 / 60)
}
function logout (connection) {
@@ -63,7 +63,7 @@ function kill (player) {
function step () {
const currentTime = Date.now()
const durationSinceLastUpdate = (currentTime - lastUpdateTime) / 1000
const tickToSimulate = (durationSinceLastUpdate * 120) / 1000
const tickToSimulate = (durationSinceLastUpdate * 60) / 1000
lastUpdateTime = currentTime
// console.log('UPDATE ' + currentTime + ' doUpdate ' + doUpdate)
@@ -102,12 +102,11 @@ function step () {
function broadcastUpdate () {
const update = {
type: 'update',
type: 'gameUpdate',
players: Object.values(players),
time: lastUpdateTime
}
console.log('Broadcast ' + JSON.stringify(update))
Object.values(sockets).forEach((connection) => {
connection.send(JSON.stringify(update))
})

View File

@@ -1,8 +1,8 @@
module.exports = Object.freeze({
playerSize: 10,
playerSpeed: 2.3,
playerSpeed: 5,
playerTurnSpeed: 10,
wallSize: 8,
wallUpdate: 20,
wallUpdate: 5,
arenaSize: 1000
})