Skip to content

Commit 8f36cb6

Browse files
committed
fix(graphics): change unhandled Graphics import
1 parent 7992372 commit 8f36cb6

File tree

4 files changed

+18
-12
lines changed

4 files changed

+18
-12
lines changed

example/pong/src/components.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Graphics } from "@nanoforge-dev/graphics-2d";
1+
import { type Circle, type Rect } from "@nanoforge-dev/graphics-2d";
22
import type { InputEnum } from "@nanoforge-dev/input";
33

44
import { layer } from "./index";
@@ -38,19 +38,19 @@ export class Hitbox {
3838

3939
export class CircleComponent {
4040
name = "CircleComponent";
41-
component: Graphics.Circle;
41+
component: Circle;
4242

43-
constructor(component: Graphics.Circle) {
43+
constructor(component: Circle) {
4444
this.component = component;
4545
layer.add(this.component);
4646
}
4747
}
4848

4949
export class RectangleComponent {
5050
name = "RectangleComponent";
51-
component: Graphics.Rect;
51+
component: Rect;
5252

53-
constructor(component: Graphics.Rect) {
53+
constructor(component: Rect) {
5454
this.component = component;
5555
layer.add(this.component);
5656
}

example/pong/src/index.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
import { AssetManagerLibrary } from "@nanoforge-dev/asset-manager/src";
12
import { type IRunOptions } from "@nanoforge-dev/common";
23
import { NanoforgeFactory } from "@nanoforge-dev/core";
34
import { 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";
56
import { InputEnum } from "@nanoforge-dev/input";
7+
import { InputLibrary } from "@nanoforge-dev/input/src";
68
import { SoundLibrary } from "@nanoforge-dev/sound";
79

810
import {
@@ -18,15 +20,19 @@ import { bounce, controlPlayer, drawCircle, move, moveRectangle } from "./system
1820

1921
export const app = NanoforgeFactory.createClient();
2022

21-
export const layer = new Graphics.Layer();
23+
export const layer = new Layer();
2224

2325
export 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);

packages/graphics-2d/src/graphics-2d.library.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { BaseGraphicsLibrary, type InitContext } from "@nanoforge-dev/common";
22

3-
import { Graphics } from ".";
3+
import * as Graphics from "./exports/konva";
44

55
export class Graphics2DLibrary extends BaseGraphicsLibrary {
66
private _stage?: Graphics.Stage;

packages/graphics-2d/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
export { Graphics2DLibrary } from "./graphics-2d.library";
2-
export * as Graphics from "./exports/konva";
2+
export * from "./exports/konva";

0 commit comments

Comments
 (0)