Done for the night.
This commit is contained in:
parent
c89f24a2a7
commit
3927b3963e
9
index.js
9
index.js
|
@ -1,13 +1,15 @@
|
||||||
const worldgen = require("./worldgen.js")
|
const worldgen = require("./worldgen.js")
|
||||||
const util = require("./util.js")
|
const util = require("./util.js")
|
||||||
const log = require("./log.js")
|
const log = require("./log.js")
|
||||||
|
const {performance} = require('perf_hooks');
|
||||||
const gridSize = [18, 18];
|
const gridSize = [18, 18];
|
||||||
const perlinScale = 3;
|
const perlinScale = 4;
|
||||||
|
const startTime = performance.now()
|
||||||
var express = require('express');
|
var express = require('express');
|
||||||
log.setMode(0);
|
log.setMode(0);
|
||||||
process.title = "Server"
|
process.title = "Server"
|
||||||
setInterval(function(){ updateInfo()},5000)
|
setInterval(function(){ updateInfo()},5000)
|
||||||
|
log.logRight(1, `Uptime: ${(performance.now() - startTime)/100}`);
|
||||||
function updateInfo() {
|
function updateInfo() {
|
||||||
log.setInfo(server.games)
|
log.setInfo(server.games)
|
||||||
}
|
}
|
||||||
|
@ -43,6 +45,7 @@ class Server {
|
||||||
removeGame(name) {
|
removeGame(name) {
|
||||||
this.games = this.games.filter(obj => obj.name != name);
|
this.games = this.games.filter(obj => obj.name != name);
|
||||||
log.log("removed game - " + name)
|
log.log("removed game - " + name)
|
||||||
|
// Broken?
|
||||||
}
|
}
|
||||||
|
|
||||||
getAllIDs() {
|
getAllIDs() {
|
||||||
|
@ -126,7 +129,7 @@ var app = express() //Static resources server
|
||||||
app.use(express.static(__dirname + '/www/'));
|
app.use(express.static(__dirname + '/www/'));
|
||||||
var webServer = app.listen(8082, function () {
|
var webServer = app.listen(8082, function () {
|
||||||
var port = webServer.address().port;
|
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 */
|
var io = require('socket.io')(webServer);/* Connection events */
|
||||||
|
|
11
log.js
11
log.js
|
@ -1,6 +1,7 @@
|
||||||
const os = require("os")
|
const os = require("os")
|
||||||
var mode = 0
|
var mode = 0
|
||||||
var logs = []
|
var logs = []
|
||||||
|
var rightView = [0,1,2,3,4,5,6]
|
||||||
var info = [[],[]]
|
var info = [[],[]]
|
||||||
|
|
||||||
function setMode(type) {
|
function setMode(type) {
|
||||||
|
@ -22,10 +23,11 @@ for (var i = 0; i < vertSplit; i++) {
|
||||||
process.stdout.write(`|`)
|
process.stdout.write(`|`)
|
||||||
}
|
}
|
||||||
for (var i = 0; i < columns; i++) {
|
for (var i = 0; i < columns; i++) {
|
||||||
process.stdout.cursorTo(i, vertSplit)
|
process.stdout.cursorTo(i+1, vertSplit)
|
||||||
process.stdout.write(`=`)
|
process.stdout.write(`=`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
process.stdout.cursorTo(0,0)
|
process.stdout.cursorTo(0,0)
|
||||||
process.stdout.write("Players:")
|
process.stdout.write("Players:")
|
||||||
const games = info[0]
|
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) {
|
function log(string, color) {
|
||||||
if (mode) return console.log(string)
|
if (mode) return console.log(string)
|
||||||
if (string == undefined) return;
|
if (string == undefined) return;
|
||||||
|
@ -120,4 +127,4 @@ if (players != undefined) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {log, updateLog, setInfo, setMode}
|
module.exports = {log, updateLog, setInfo, setMode, logRight}
|
||||||
|
|
|
@ -15,7 +15,7 @@ export function renderTiles() { // DRAW THE IMAGE TO THE CANVAS.
|
||||||
const tileSize = game.tileSize;
|
const tileSize = game.tileSize;
|
||||||
for(x = 0; x < gridSize[0]; x++){
|
for(x = 0; x < gridSize[0]; x++){
|
||||||
for(y = 0; y < gridSize[1]; y++){
|
for(y = 0; y < gridSize[1]; y++){
|
||||||
const xu = x*tileSize + animation.get();
|
const xu = x*tileSize;
|
||||||
const yu = y*tileSize;
|
const yu = y*tileSize;
|
||||||
const tempWorld = game.world;
|
const tempWorld = game.world;
|
||||||
// Draw buildings
|
// Draw buildings
|
||||||
|
|
|
@ -40,8 +40,6 @@ function getMousePosition(canvas, event) {
|
||||||
const rect = canvas.getBoundingClientRect();
|
const rect = canvas.getBoundingClientRect();
|
||||||
const x = event.clientX - rect.left;
|
const x = event.clientX - rect.left;
|
||||||
const y = event.clientY - rect.top;
|
const y = event.clientY - rect.top;
|
||||||
// const xu = Math.floor(x/tileSize)
|
|
||||||
// const yu = Math.floor(y/tileSize)
|
|
||||||
const xu = cursor.x
|
const xu = cursor.x
|
||||||
const yu = cursor.y
|
const yu = cursor.y
|
||||||
|
|
||||||
|
|
|
@ -56,8 +56,3 @@ socket.on('sync', function (sync){
|
||||||
game.world = sync.world;
|
game.world = sync.world;
|
||||||
render()
|
render()
|
||||||
})
|
})
|
||||||
|
|
||||||
window.onbeforeunload = function(){
|
|
||||||
|
|
||||||
game.world = []
|
|
||||||
}
|
|
||||||
|
|
|
@ -20,6 +20,7 @@ canvas {
|
||||||
width: 100px;
|
width: 100px;
|
||||||
height: 437px;
|
height: 437px;
|
||||||
background: darkolivegreen;
|
background: darkolivegreen;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.right{
|
.right{
|
||||||
|
@ -29,6 +30,7 @@ canvas {
|
||||||
width: 100px;
|
width: 100px;
|
||||||
height: 437px;
|
height: 437px;
|
||||||
background: darkolivegreen;
|
background: darkolivegreen;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.top {
|
.top {
|
||||||
|
@ -36,6 +38,7 @@ position: absolute;
|
||||||
background: salmon;
|
background: salmon;
|
||||||
width: 632px;
|
width: 632px;
|
||||||
height: 50px;
|
height: 50px;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.bottom{
|
.bottom{
|
||||||
|
@ -44,6 +47,7 @@ height: 50px;
|
||||||
width:632px;
|
width:632px;
|
||||||
height:100px;
|
height:100px;
|
||||||
transform: translate(0, 486px);
|
transform: translate(0, 486px);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue