import { generateRandomNumber } from "../../utils/numbers.js"; import { fetchTime } from…
- User
import { generateRandomNumber } from "../../utils/numbers.js"; import { fetchTime } from "../../utils/customConsole.js"; import Config from "./Config.js"; import { HealthComponent, MovementComponent } from "./components/Components.js"; import { EventEmitter } from 'events'; const eventEmitter = new EventEmitter();
class Entity { constructor(type, uid, x, y) { this.type = type; this.uid = Number(uid); this.x = Number(x); this.y = Number(y); this.entityValues = { isDead: false } this.components = {}; }
codeaddComponent(componentName, component) { this.components[componentName] = component; } removeComponent(componentName) { delete this.components[componentName]; }}
class PlayerEntity extends Entity { constructor(uid, x, y) { super('player', uid, x, y);
codethis.addComponent('health', new HealthComponent(100, this)); this.addComponent('movement', new MovementComponent(this)); }}
class ZombieEntity extends Entity { constructor(uid, x, y, health) { super('zombie', uid, x, y);
codethis.addComponent('health', new HealthComponent(health)); }}
class World { constructor() { this.worldX = 100; this.worldY = 100; this.entities = []; this.randomMove = null;
code - Assistant
- User
- Assistant
- User
Create a game server using NodeJS and ws.
Here's what the game should contain
- A grid-tile world with xy value coordinates, Tile size is 32
- An entity management system for the world.
- Entities with a base class model, along with an already coded zombie and player model.
- Assistant
- User
Create a tower defense game server using NodeJS and ws.
Here’s what the game should contain
- A grid-tile world with xy value coordinates, Tile size is 32
- An entity management system for the world.
- Entities with a base class model, along with an already coded zombie and player model.
- A day / night cycle that lasts 2 minutes and cycles. During the night, zombies will spawn and attempt to pathfind to the gold stash if it exists.
- A motion system that calculates velocity
- A movement system utilizing this motion system.
- Basic building system, including two buildings, arrow tower and a gold stash. The gold stash is the basis of the tower defense game, and arrow tears attempt to shoot the zomibes.
The code should be modern, utilizing the latest ES features, and should be as optimized with little code footprint as possible. The code must also include zero comments
The server should be event based, aka whenever an event occurs it will update. It does not use a tick based system. All calculations should be done server-side not client side, in order to prevent packet exploits.
- Assistant