From ded70d470bdf3d33ba113f5b260e2b65969c94ad Mon Sep 17 00:00:00 2001 From: Alexander Klingenbeck Date: Tue, 6 Jun 2023 08:51:42 +0200 Subject: [PATCH] Add controls --- examples/ts_game/.gitignore | 3 +- examples/ts_game/src/editor.ts | 58 ++++++++++++++++++++++++++++++ examples/ts_game/src/entity.ts | 3 +- examples/ts_game/src/game.ts | 23 ++++++++++-- examples/ts_game/src/index.ts | 2 +- examples/ts_game/webpack.config.js | 7 ++-- 6 files changed, 88 insertions(+), 8 deletions(-) create mode 100644 examples/ts_game/src/editor.ts diff --git a/examples/ts_game/.gitignore b/examples/ts_game/.gitignore index 7e9804b..bdc9544 100644 --- a/examples/ts_game/.gitignore +++ b/examples/ts_game/.gitignore @@ -1,2 +1,3 @@ node_modules/ -main.js \ No newline at end of file +main.js +editor.js \ No newline at end of file diff --git a/examples/ts_game/src/editor.ts b/examples/ts_game/src/editor.ts new file mode 100644 index 0000000..3a75603 --- /dev/null +++ b/examples/ts_game/src/editor.ts @@ -0,0 +1,58 @@ +import { Behaviour, Builder, Entity, HasBoundingBox, HasMouseInteraction, combine, hasDefault, hasDefaultFn, makeEntity, which, withBoundingBox, withComponent, withMouseInteraction } from "./entity" +import { entityAdd, runGame } from "./game" +import { HasText, withText } from "./text" + +const withGuiBounds = withComponent(x => hasDefaultFn(x, 'boundingBox', () => new Rectangle(10,10,100,20))) + +type Button = Entity & HasBoundingBox & HasMouseInteraction & HasText +const drawsButton: Behaviour