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

@@ -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
})