Skip to main content

Space Shooter

A

Left

D

Right

Shoot

game.ts
const renderLayers = {
background: 1 << 0,
foreground: 1 << 1,
};

export const createSpaceShooterGame = async (): Promise<Game> => {
const { game, world, renderContext, time } = createGame('demo-game');
addCamera(world);
const { moveInput, shootInput } = createInputs(world, time, game);

await createBackground(world, renderContext, renderLayers.background);
await createPlayer(renderContext, world, renderLayers.foreground);
createMusic(world);

world.addSystem(createCameraEcsSystem(time));
world.addSystem(createRenderEcsSystem(renderContext));
world.addSystem(createMovementEcsSystem(moveInput, time));
world.addSystem(createBackgroundEcsSystem(time));
world.addSystem(createAudioEcsSystem());
world.addSystem(createLifetimeTrackingEcsSystem(time));
world.addSystem(createRemoveFromWorldEcsSystem());
world.addSystem(createGunEcsSystem(time, world, shootInput));
world.addSystem(createBulletEcsSystem(time));

return game;
};

This demo showcases a complete space shooter game built using the Forge Game Engine. It features player-controlled movement, shooting mechanics, enemy spawning, and collision detection. The game demonstrates how to leverage the engine's capabilities to create an engaging and interactive experience. Players can navigate their spaceship, avoid obstacles, and shoot down enemies while enjoying smooth rendering and responsive controls.