Update server/src/index.js
This commit is contained in:
@@ -15,6 +15,8 @@ app.use(cors({ origin: true, credentials: true }));
|
|||||||
app.use(express.json());
|
app.use(express.json());
|
||||||
app.use(cookieParser());
|
app.use(cookieParser());
|
||||||
|
|
||||||
|
const TILE_SIZE = 32;
|
||||||
|
|
||||||
const WORLD = {
|
const WORLD = {
|
||||||
width: 400000,
|
width: 400000,
|
||||||
height: 300000,
|
height: 300000,
|
||||||
@@ -107,13 +109,24 @@ let nodes = [];
|
|||||||
function spawnNodes() {
|
function spawnNodes() {
|
||||||
nodes = [];
|
nodes = [];
|
||||||
const types = ['wood', 'stone', 'ore', 'fiber'];
|
const types = ['wood', 'stone', 'ore', 'fiber'];
|
||||||
for (let i = 0; i < 120; i++) {
|
|
||||||
|
const tilesX = Math.floor(WORLD.width / TILE_SIZE);
|
||||||
|
const tilesY = Math.floor(WORLD.height / TILE_SIZE);
|
||||||
|
|
||||||
|
for (let i = 0; i < 600; i++) {
|
||||||
const type = types[i % types.length];
|
const type = types[i % types.length];
|
||||||
|
|
||||||
|
const tx = Math.floor(Math.random() * tilesX);
|
||||||
|
const ty = Math.floor(Math.random() * tilesY);
|
||||||
|
|
||||||
|
const x = tx * TILE_SIZE + TILE_SIZE / 2;
|
||||||
|
const y = ty * TILE_SIZE + TILE_SIZE / 2;
|
||||||
|
|
||||||
nodes.push({
|
nodes.push({
|
||||||
id: i,
|
id: i,
|
||||||
type,
|
type,
|
||||||
x: Math.floor(Math.random() * WORLD.width),
|
x,
|
||||||
y: Math.floor(Math.random() * WORLD.height),
|
y,
|
||||||
alive: true,
|
alive: true,
|
||||||
respawnAt: 0
|
respawnAt: 0
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user