This file contains 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 createEntity = (nid, x, y, name) => { | |
return { | |
nid, | |
x, | |
y, | |
hp: 100, | |
name | |
} | |
} |
This file contains 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
use std::time::Instant; | |
#[derive(Debug)] | |
struct Entity { | |
nid: u32, | |
x: f64, | |
y: f64, | |
hp: u8, | |
name: String | |
} |
This file contains 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 glue = require('./glue') | |
const nengi = glue.nengi.default | |
const nengiConfig = glue.nengiConfig.default | |
const PlayerInput = glue.PlayerInput.default | |
// bots need to all share the same protocols | |
const protocolMap = new nengi.ProtocolMap(nengiConfig, nengi.metaConfig) | |
//var address = 'ws://localhost:8001' | |
const address = null // put some url here |
This file contains 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
body { | |
background-color:#423b41; | |
} | |
.wrap { | |
display: flex; | |
} | |
.solo { | |
border: solid 4px #ebfff9; |
This file contains 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
map $http_upgrade $connection_upgrade { | |
default upgrade; | |
'' close; | |
} | |
server { | |
listen 443 ssl; | |
ssl_certificate /srv/certs/fullchain.pem; | |
ssl_certificate_key /srv/certs/privkey.pem; |
This file contains 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
// pseudocode for transfers if game has a practically infinite number of instances. | |
// From one of the game servers | |
transfer(client, toInstance) { | |
toInstance.someWebApi.request( | |
{ transfer: { token: 'abc123', data }}, | |
(res) => { | |
if (res.transferAccepted) { | |
instance.message(new TransferMessage(address, token)), client) | |
client.disconnect() | |
} |
This file contains 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
import nengi from 'nengi' | |
import * as BABYLON from 'babylonjs' | |
class PlayerCharacter { | |
constructor(scene) { | |
this.name = 'anon' | |
this.mesh = new BABYLON.Mesh('dummy', scene) | |
this.mesh.entity = this // for collisions within babylon | |
this.hitpoints = 100 | |
// velocity from own impulses |
This file contains 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
let basePath = 'http://localhost:8086' | |
if (typeof window === 'undefined') { | |
basePath = 'http://localhost:8086/' | |
} | |
if (process && process.env && process.env.NODE_ENV === 'production') { | |
basePath = `https://somedomain.io/` | |
} | |
const sounds = new Map() |
This file contains 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
import nengi from '../../nengi'; | |
class Score { | |
constructor(score) { | |
this.entityId = score.entityId | |
this.kills = score.kills | |
this.assists = score.assists | |
this.damage = score.damage | |
this.deaths = score.deaths | |
} |
This file contains 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
// from the game instance | |
const master = new TLSClient({ | |
options: { | |
ca: fs.readFileSync(config.API_CERT), | |
}, | |
reconnectInterval: 2000, | |
host: config.MASTER_API_HOST, | |
port: config.MASTER_API_PORT, | |
password: config.API_PASSWORD |
NewerOlder