A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.
TypeScript 2d-game-engine3d3d-game-engineandroidcppecsgame-editorgame-enginegamedeviostypescriptwebassemblywebglwebgpuwechat-minigame
import { defineSystem, Query, Mut, Res, Time, Transform } from 'esengine';
import { Sweep } from '../components';
// Ping-pong a sweeping entity along x, so a local volume drifts through the
// fixed camera and its effect blends in and out by distance.
export const sweepSystem = defineSystem(
[Query(Mut(Transform), Mut(Sweep)), Res(Time)],
(query, time) => {
for (const [, transform, sweep] of query) {
sweep.t += time.delta;
transform.position.x = Math.sin(sweep.t * sweep.speed) * sweep.range;
}
},
{ name: 'SweepSystem' },
);