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 { Mover } from '../components';
/**
* Moves every entity by its direction and speed, once per frame.
*
* @compiled
* A promise, not a hint: anything the subset cannot lower is a build error here
* rather than a silent fall back to the interpreter.
*/
export const moveSystem = defineSystem(
[Query(Mut(Transform), Mover), Res(Time)],
(query, time) => {
for (const [_entity, transform, mover] of query) {
transform.position.x += mover.directionX * mover.speed * time.delta;
transform.position.y += mover.directionY * mover.speed * time.delta;
}
},
{ name: 'MoveSystem' }
);