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(cookieParser());
|
||||
|
||||
const TILE_SIZE = 32;
|
||||
|
||||
const WORLD = {
|
||||
width: 400000,
|
||||
height: 300000,
|
||||
@@ -107,13 +109,24 @@ let nodes = [];
|
||||
function spawnNodes() {
|
||||
nodes = [];
|
||||
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 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({
|
||||
id: i,
|
||||
type,
|
||||
x: Math.floor(Math.random() * WORLD.width),
|
||||
y: Math.floor(Math.random() * WORLD.height),
|
||||
x,
|
||||
y,
|
||||
alive: true,
|
||||
respawnAt: 0
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user