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 { Bobber } from '../components';
// Registered through SceneConfig.systems, not main.ts: SceneManager installs it
// when a level loads, gates it to that scene's 'running' status, and removes it
// again on unload.
export const bobSystem = defineSystem(
[Query(Mut(Transform), Bobber), Res(Time)],
(query, time) => {
for (const [_entity, transform, bob] of query) {
transform.position.y =
bob.baseY + Math.sin(time.elapsed * bob.speed + bob.phase) * bob.amplitude;
}
},
{ name: 'BobSystem' },
);