diff --git a/index.js b/index.js index 1d9d90d..182a280 100644 --- a/index.js +++ b/index.js @@ -1,13 +1,15 @@ const worldgen = require("./worldgen.js") const util = require("./util.js") const log = require("./log.js") +const {performance} = require('perf_hooks'); const gridSize = [18, 18]; -const perlinScale = 3; +const perlinScale = 4; +const startTime = performance.now() var express = require('express'); log.setMode(0); process.title = "Server" setInterval(function(){ updateInfo()},5000) - +log.logRight(1, `Uptime: ${(performance.now() - startTime)/100}`); function updateInfo() { log.setInfo(server.games) } @@ -43,6 +45,7 @@ class Server { removeGame(name) { this.games = this.games.filter(obj => obj.name != name); log.log("removed game - " + name) + // Broken? } getAllIDs() { @@ -126,7 +129,7 @@ var app = express() //Static resources server app.use(express.static(__dirname + '/www/')); var webServer = app.listen(8082, function () { var port = webServer.address().port; - log.log(`Server running at port ${port}`, "bright"); + log.logRight(0, `Server running at port ${port}`, "bright"); }); var io = require('socket.io')(webServer);/* Connection events */ diff --git a/log.js b/log.js index 87c536b..6a61510 100644 --- a/log.js +++ b/log.js @@ -1,6 +1,7 @@ const os = require("os") var mode = 0 var logs = [] +var rightView = [0,1,2,3,4,5,6] var info = [[],[]] function setMode(type) { @@ -22,10 +23,11 @@ for (var i = 0; i < vertSplit; i++) { process.stdout.write(`|`) } for (var i = 0; i < columns; i++) { - process.stdout.cursorTo(i, vertSplit) + process.stdout.cursorTo(i+1, vertSplit) process.stdout.write(`=`) } + process.stdout.cursorTo(0,0) process.stdout.write("Players:") const games = info[0] @@ -51,6 +53,11 @@ for (var i = 0; i < templogs.length; i++ ) { } } +function logRight(line, text) { + rightView[line] = text; + updateLog(); +} + function log(string, color) { if (mode) return console.log(string) if (string == undefined) return; @@ -120,4 +127,4 @@ if (players != undefined) { } -module.exports = {log, updateLog, setInfo, setMode} +module.exports = {log, updateLog, setInfo, setMode, logRight} diff --git a/www/scripts/display/draw.js b/www/scripts/display/draw.js index d6f97aa..8afb237 100644 --- a/www/scripts/display/draw.js +++ b/www/scripts/display/draw.js @@ -15,7 +15,7 @@ export function renderTiles() { // DRAW THE IMAGE TO THE CANVAS. const tileSize = game.tileSize; for(x = 0; x < gridSize[0]; x++){ for(y = 0; y < gridSize[1]; y++){ - const xu = x*tileSize + animation.get(); + const xu = x*tileSize; const yu = y*tileSize; const tempWorld = game.world; // Draw buildings diff --git a/www/scripts/interface/game/mouse.js b/www/scripts/interface/game/mouse.js index d90c08c..657a22a 100644 --- a/www/scripts/interface/game/mouse.js +++ b/www/scripts/interface/game/mouse.js @@ -40,8 +40,6 @@ function getMousePosition(canvas, event) { const rect = canvas.getBoundingClientRect(); const x = event.clientX - rect.left; const y = event.clientY - rect.top; - // const xu = Math.floor(x/tileSize) - // const yu = Math.floor(y/tileSize) const xu = cursor.x const yu = cursor.y diff --git a/www/scripts/net/netcode.js b/www/scripts/net/netcode.js index c47f76a..fda8b4e 100644 --- a/www/scripts/net/netcode.js +++ b/www/scripts/net/netcode.js @@ -56,8 +56,3 @@ socket.on('sync', function (sync){ game.world = sync.world; render() }) - -window.onbeforeunload = function(){ - - game.world = [] -} diff --git a/www/style.css b/www/style.css index 6b58476..76fb3d8 100644 --- a/www/style.css +++ b/www/style.css @@ -20,6 +20,7 @@ canvas { width: 100px; height: 437px; background: darkolivegreen; + } .right{ @@ -29,6 +30,7 @@ canvas { width: 100px; height: 437px; background: darkolivegreen; + } .top { @@ -36,6 +38,7 @@ position: absolute; background: salmon; width: 632px; height: 50px; + } .bottom{ @@ -44,6 +47,7 @@ height: 50px; width:632px; height:100px; transform: translate(0, 486px); + }