This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const fs = require('fs') | |
| const express = require('express') | |
| const config = require('config') | |
| const TLSServer = require('tls-json').Server | |
| const Router = require('express-promise-router') | |
| const servers = require('../servers') | |
| const app = express() | |
| app.use(express.json()) | |
| app.use(express.urlencoded({ extended: true })) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function length(x,y) { | |
| return Math.sqrt((x * x) + (y * y)) | |
| } | |
| function norm(x ,y) { | |
| var len = length(x, y) | |
| if (len > 0) { | |
| return { x: x/len, y: y/len } | |
| } else { | |
| return { x: 0, y: 0 } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var Floor = require('../map/Floor') | |
| var Wall = require('../map/Wall') | |
| function createKey(x, y) { | |
| return x + y * 10000000 | |
| } | |
| function keyInBounds(key, gx, gy, halfWidth, halfHeight) { | |
| var keyX = key % 10000000 | |
| var keyY = Math.floor(key / 10000000) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var TileEnum = { | |
| EMPTY: 0, | |
| GRASS: 1, | |
| DIRT: 2, | |
| STONEWALL: 3 | |
| } | |
| class TileMap { | |
| constructor(width, height) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function hypot(a, b) { | |
| a = Math.abs(a) | |
| b = Math.abs(b) | |
| var lo = Math.min(a, b) | |
| var hi = Math.max(a, b) | |
| return hi + 3 * lo / 32 + Math.max(0, 2 * lo - hi) / 8 + Math.max(0, 4 * lo - hi) / 16 | |
| } | |
| function BoidSys(opts) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var http = require('http') | |
| var httpProxy = require('http-proxy') | |
| var servers = { | |
| '/0': 'ws://127.0.0.1:8000', | |
| '/1': 'ws://127.0.0.1:8001', | |
| '/2': 'ws://127.0.0.1:8002', | |
| '/3': 'ws://127.0.0.1:8003', | |
| '/4': 'ws://127.0.0.1:8004', | |
| '/5': 'ws://127.0.0.1:8005', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var nengi = require('../../nengi') | |
| var EDictionary = require('../../nengi/external/EDictionary') | |
| var protocols = require('../protocols') | |
| // Graphics code | |
| var Squid = require('./entity/Squid') | |
| var Fish = require('./entity/Fish') | |
| var Shark = require('./entity/Shark') | |
| var Ink = require('./effect/Ink') | |
| var Blood = require('./effect/Blood') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var Client = require('../Client') | |
| function GameScene() { | |
| this.client = new Client() | |
| } | |
| GameScene.prototype.enterScene = function() { | |
| console.log('GameScene entered') | |
| this.client.connect() | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var nengi = require('../../../nengi/nengi') | |
| var common = require('../../common') | |
| var Renderer = require('../renderer/Renderer') | |
| var InputSystem = require('../input/InputSystem') | |
| function GameScene(ip, port) { | |
| this.ip = ip | |
| this.port = port |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| MapVisual.prototype.recenter = function(me) { | |
| var gridCoord = this.map.worldCoordsToGridCoords(me.x, me.y) | |
| if (this.previousX !== gridCoord.x || this.previousY !== gridCoord.y) { | |
| var dx = gridCoord.x - this.previousX | |
| var dy = gridCoord.y - this.previousY | |
| // start |