1+ import { AssetManagerLibrary } from "@nanoforge-dev/asset-manager/src" ;
12import { type IRunOptions } from "@nanoforge-dev/common" ;
23import { NanoforgeFactory } from "@nanoforge-dev/core" ;
34import { ECSLibrary } from "@nanoforge-dev/ecs" ;
4- import { Graphics , Graphics2DLibrary } from "@nanoforge-dev/graphics-2d" ;
5+ import { Circle , Graphics2DLibrary , Layer , Rect } from "@nanoforge-dev/graphics-2d" ;
56import { InputEnum } from "@nanoforge-dev/input" ;
7+ import { InputLibrary } from "@nanoforge-dev/input/src" ;
68import { SoundLibrary } from "@nanoforge-dev/sound" ;
79
810import {
@@ -18,15 +20,19 @@ import { bounce, controlPlayer, drawCircle, move, moveRectangle } from "./system
1820
1921export const app = NanoforgeFactory . createClient ( ) ;
2022
21- export const layer = new Graphics . Layer ( ) ;
23+ export const layer = new Layer ( ) ;
2224
2325export const main = async ( options : IRunOptions ) => {
26+ const assetManager = new AssetManagerLibrary ( ) ;
2427 const graphics = new Graphics2DLibrary ( ) ;
2528 const ecsLibrary = new ECSLibrary ( ) ;
29+ const inputLibrary = new InputLibrary ( ) ;
2630 const sounds = new SoundLibrary ( ) ;
2731
32+ app . useAssetManager ( assetManager ) ;
2833 app . useGraphics ( graphics ) ;
2934 app . useComponentSystem ( ecsLibrary ) ;
35+ app . useInput ( inputLibrary ) ;
3036 app . useSound ( sounds ) ;
3137
3238 await app . init ( options ) ;
@@ -47,7 +53,7 @@ export const main = async (options: IRunOptions) => {
4753 registry . addComponent (
4854 ball ,
4955 new CircleComponent (
50- new Graphics . Circle ( {
56+ new Circle ( {
5157 radius : 70 ,
5258 fill : "red" ,
5359 } ) ,
@@ -61,7 +67,7 @@ export const main = async (options: IRunOptions) => {
6167 registry . addComponent ( player1 , new Controller ( InputEnum . KeyW , InputEnum . KeyS ) ) ;
6268 registry . addComponent (
6369 player1 ,
64- new RectangleComponent ( new Graphics . Rect ( { fill : "blue" , width : 50 , height : 500 } ) ) ,
70+ new RectangleComponent ( new Rect ( { fill : "blue" , width : 50 , height : 500 } ) ) ,
6571 ) ;
6672
6773 const player2 = registry . spawnEntity ( ) ;
@@ -71,7 +77,7 @@ export const main = async (options: IRunOptions) => {
7177 registry . addComponent ( player2 , new Controller ( InputEnum . ArrowUp , InputEnum . ArrowDown ) ) ;
7278 registry . addComponent (
7379 player2 ,
74- new RectangleComponent ( new Graphics . Rect ( { fill : "blue" , width : 50 , height : 500 } ) ) ,
80+ new RectangleComponent ( new Rect ( { fill : "blue" , width : 50 , height : 500 } ) ) ,
7581 ) ;
7682
7783 registry . addSystem ( move ) ;
0 commit comments