narrat 2.10.2 → 2.10.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2020 Liana Pigeot
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2020 Liana Pigeot
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,136 +1,136 @@
1
- # 🚀 Narrat
2
-
3
- ![example workflow](https://github.com/liana-p/narrat-engine/actions/workflows/main.yml/badge.svg) [![Netlify Status](https://api.netlify.com/api/v1/badges/55d4b9ba-62b7-4c43-86ce-8bc2aaf98643/deploy-status)](https://app.netlify.com/sites/ornate-pie-561978/deploys)
4
-
5
- Work on the engine directly in Codeflow:
6
-
7
- [![Open in Codeflow](./docs/open-in-codeflow.svg)](https://pr.new/liana-p/narrat-engine)
8
-
9
- Or try editing the default narrat game easily:
10
-
11
- [![Try editing the default game](./docs/open-in-codeflow.svg)](https:///pr.new/github.com/liana-p/narrat-engine/edit/main/packages/narrat/examples/games/default/scripts/default.nar)
12
-
13
- Narrat is a game engine for making interactive narrative RPGs packed with features.. Create your game by editing with a Simple scripting syntax. It supports Skills with skill check rolls, an Items inventory, and has a Quests System. The script system is very powerful and allows branching choices, functions, variables and conditions.
14
-
15
- More info on the [narrat website](https://get-narrat.com). There is an [online demo](https://get-narrat.com/demo/) available to try in the browser.
16
-
17
- ## Getting Started
18
-
19
- The best way to get started in a minute is to follow the [Getting Started](https://docs.get-narrat.com/guides/getting-started) documentation page. It shows you to download the ready-to-use game template to get started writing a game with narrat.
20
-
21
- ## Development (for contributors)
22
-
23
- Note: Narrat is a monorepo using `pnpm` as package manager. The `packages` folder contains the individual packages, including the main `narrat` package.
24
-
25
- Narrat is written in [TypeScript](https://www.typescriptlang.org/). It uses the [Vue](https://vuejs.org/) framework for front-end development. It also uses [pinia](https://pinia.vuejs.org/) for state management
26
-
27
- ### Requirements
28
-
29
- - [node.js](https://nodejs.org/en/) (Downloading LTS is fine)
30
- - [pnpm](https://pnpm.io/). This Narrat repo is a monorepo using pnpm workspaces to easily manage the different packages.
31
- - A text editor capable of editing a TypeScript and Vue.js project. Recommended: [VSCode](https://code.visualstudio.com/) and the extension [Volar](https://marketplace.visualstudio.com/items?itemName=ms-vscode.vscode-volar) for Vue.
32
-
33
- ### Running the engine for development
34
-
35
- 1. Install dependencies
36
-
37
- `pnpm install`
38
-
39
- 2. Run the demo
40
-
41
- `pnpm dev`
42
-
43
- This starts the engine on the demo page with the `example.nar` demo script loaded for testing.
44
-
45
- ### Developping narrat specifically
46
-
47
- If developping on the narrat package, it's better to go inside the narrat package folder and run commands there.
48
-
49
- ### Multiple demo games
50
-
51
- There are multiple demo games and it's possible to add new ones. For example `npm run rpg` will run the `rpg` demo. Demos are in the `examples` folder.
52
-
53
- Running a specific demo is done by changing an environment variables. See the scripts in `package.json` for how to run a specific demo.
54
-
55
- ### Available pnpm commands in narrat
56
-
57
- - `start`: Start the demo for development
58
- - `build`: The main build command, builds the library in a state ready to use or publish.
59
- - `test`: Unit tests, used in CI
60
- - `dev`: Same as start
61
- - `generate-types`: Generates `.d.ts` type declaration files for the library (auto run on builds)
62
- - `fix-type-aliases`: Uses [tsc-alias](https://www.npmjs.com/package/tsc-alias) to auto-replace [path mappings](https://www.typescriptlang.org/docs/handbook/module-resolution.html#path-mapping) in the built files, as the TypeScript compiler doesn't do it. (auto run at the end of builds)
63
- - `lint`: Runs the linter on the code (used in CI)
64
- - `check-types`: Validates TypeScript types.
65
-
66
- ### CI info
67
-
68
- The following tasks run on CI, and CI is required to pass for pull requests to be merged:
69
-
70
- - Linting
71
- - Engine build
72
- - Unit tests (currently only the parser is unit tested)
73
- - TypeScript type checking.
74
-
75
- Please make sure your code passes lint/tests/build/type checks before opening a PR.
76
-
77
- ### Working on the code
78
-
79
- The narrat codebase isn't currently documented, outside of the [usage docs](https://docs.get-narrat.com). The code is fully written in TypeScript though and should be clearly separated enough to be approachable.
80
-
81
- ### Engine architecture
82
-
83
- The narrat engine runs primarily as a Vue app. All the UI in the game is made of Vue components, and when a game uses narrat it effectively creates a Vue app.
84
-
85
- #### App state
86
-
87
- The engine's state is stored in pinia. It is split in separate pinia modules for different areas of the engine. They can all be found in the [src/stores](src/stores) folder.
88
-
89
- - `audio`: handles playing and stopping audio and music
90
- - `dialog`: Receives and stores all lines of dialogue created by game scripts which appear at the right of the game in the main interactive narrative view.
91
- - `hud`: Stores stats which are displayed on the hud
92
- - `inventory`: Manages the player's item inventory
93
- - `main`: Manages app-level logic and other generic systems like startup/reset/load/save
94
- - `notifications`: Manages notifications which appear at the top of the screen
95
- - `quests`: Manages quests and objectives
96
- - `rendering`: Manages the layout's state for dynamically placing and resizing the game UI
97
- - `skills`: Manages player skills and xp. Also store skill check states
98
- - `vm`: Manages the virtual machine which runs the scripting language and controls the game flow.
99
-
100
- All stores can be accessed anywhere in the code with the `use` hooks (example: `useVM()`).
101
-
102
- #### Scripting language (VM and parser)
103
-
104
- The scripting language for narrat runs in a virtual machine which has its state stored in the Vue app with Pinia.
105
-
106
- The narrat scripting language relies on the parser and the vm. The code for the parser is mainly in [src/vm/vm-parser.ts](src/vm/vm-parser.ts). The parser is in charge of taking the `.nar` files as input, and returning a tree of parsed expressions that the engine can use.
107
-
108
- The actual VM is what runs narrat games, and generally controls the flow of the application. The general logic for the vm is in the `vm` store, but there is also some logic sprinkled in the `src/vm` file.
109
-
110
- All the actual operations available to the scripting language (like `talk`) are defined as Command plugins. The built-in commands included in the language by default are in the [src/vm/commands](src/vm/commands/) folder. More command can be added by games by registering plugins.
111
-
112
- #### Adding new commands
113
-
114
- Language commands are defined in the `vm/commands` folder. It should be easy to add new commands to the game engine by looking at the existing commands as an example. New command plugins are included in the `vm/commands/index` file.
115
-
116
- #### Config file
117
-
118
- The main config file has a type defined in `src/config.ts`. The vast majority of the config options for narrat are passed in this config files, which games must provide to the engine when starting. New options for the engine should be added to the type for the config file, and also have their default value included in the `src/defaultConfig.ts` file.
119
-
120
- Engine code can access the config with the `getConfig()` function.
121
-
122
- #### Plugin system
123
-
124
- There is now a plugin system developers can use to add new functionality to narrat (more documentation soon). See the [narrat-bitsy](https://github.com/liana-pigeot/narrat-bitsy) plugin for an example.
125
-
126
- (Note: The narrat-bitsy plugin hasn't been updated for 2.0.0 and might be a bit out of date).
127
-
128
- ## Assets used in demo games
129
-
130
- - [Pointing arrows from OpenGameArt](https://opengameart.org/content/pointing-arrows)
131
- - [UI button from OpenGameArt](https://opengameart.org/content/buttons-and-frame)
132
- - [10 Basic RPG enemies](https://opengameart.org/content/10-basic-rpg-enemies)
133
- - [RPG Battle backgrounds from OpenGameArt](https://opengameart.org/content/backgrounds-3)
134
- - [3D City from OpenGameArt](https://opengameart.org/content/3d-city)
135
-
136
- The rest is handmade.
1
+ # 🚀 Narrat
2
+
3
+ ![example workflow](https://github.com/liana-p/narrat-engine/actions/workflows/main.yml/badge.svg) [![Netlify Status](https://api.netlify.com/api/v1/badges/55d4b9ba-62b7-4c43-86ce-8bc2aaf98643/deploy-status)](https://app.netlify.com/sites/ornate-pie-561978/deploys)
4
+
5
+ Work on the engine directly in Codeflow:
6
+
7
+ [![Open in Codeflow](./docs/open-in-codeflow.svg)](https://pr.new/liana-p/narrat-engine)
8
+
9
+ Or try editing the default narrat game easily:
10
+
11
+ [![Try editing the default game](./docs/open-in-codeflow.svg)](https:///pr.new/github.com/liana-p/narrat-engine/edit/main/packages/narrat/examples/games/default/scripts/default.nar)
12
+
13
+ Narrat is a game engine for making interactive narrative RPGs packed with features.. Create your game by editing with a Simple scripting syntax. It supports Skills with skill check rolls, an Items inventory, and has a Quests System. The script system is very powerful and allows branching choices, functions, variables and conditions.
14
+
15
+ More info on the [narrat website](https://get-narrat.com). There is an [online demo](https://get-narrat.com/demo/) available to try in the browser.
16
+
17
+ ## Getting Started
18
+
19
+ The best way to get started in a minute is to follow the [Getting Started](https://docs.get-narrat.com/guides/getting-started) documentation page. It shows you to download the ready-to-use game template to get started writing a game with narrat.
20
+
21
+ ## Development (for contributors)
22
+
23
+ Note: Narrat is a monorepo using `pnpm` as package manager. The `packages` folder contains the individual packages, including the main `narrat` package.
24
+
25
+ Narrat is written in [TypeScript](https://www.typescriptlang.org/). It uses the [Vue](https://vuejs.org/) framework for front-end development. It also uses [pinia](https://pinia.vuejs.org/) for state management
26
+
27
+ ### Requirements
28
+
29
+ - [node.js](https://nodejs.org/en/) (Downloading LTS is fine)
30
+ - [pnpm](https://pnpm.io/). This Narrat repo is a monorepo using pnpm workspaces to easily manage the different packages.
31
+ - A text editor capable of editing a TypeScript and Vue.js project. Recommended: [VSCode](https://code.visualstudio.com/) and the extension [Volar](https://marketplace.visualstudio.com/items?itemName=ms-vscode.vscode-volar) for Vue.
32
+
33
+ ### Running the engine for development
34
+
35
+ 1. Install dependencies
36
+
37
+ `pnpm install`
38
+
39
+ 2. Run the demo
40
+
41
+ `pnpm dev`
42
+
43
+ This starts the engine on the demo page with the `example.nar` demo script loaded for testing.
44
+
45
+ ### Developping narrat specifically
46
+
47
+ If developping on the narrat package, it's better to go inside the narrat package folder and run commands there.
48
+
49
+ ### Multiple demo games
50
+
51
+ There are multiple demo games and it's possible to add new ones. For example `npm run rpg` will run the `rpg` demo. Demos are in the `examples` folder.
52
+
53
+ Running a specific demo is done by changing an environment variables. See the scripts in `package.json` for how to run a specific demo.
54
+
55
+ ### Available pnpm commands in narrat
56
+
57
+ - `start`: Start the demo for development
58
+ - `build`: The main build command, builds the library in a state ready to use or publish.
59
+ - `test`: Unit tests, used in CI
60
+ - `dev`: Same as start
61
+ - `generate-types`: Generates `.d.ts` type declaration files for the library (auto run on builds)
62
+ - `fix-type-aliases`: Uses [tsc-alias](https://www.npmjs.com/package/tsc-alias) to auto-replace [path mappings](https://www.typescriptlang.org/docs/handbook/module-resolution.html#path-mapping) in the built files, as the TypeScript compiler doesn't do it. (auto run at the end of builds)
63
+ - `lint`: Runs the linter on the code (used in CI)
64
+ - `check-types`: Validates TypeScript types.
65
+
66
+ ### CI info
67
+
68
+ The following tasks run on CI, and CI is required to pass for pull requests to be merged:
69
+
70
+ - Linting
71
+ - Engine build
72
+ - Unit tests (currently only the parser is unit tested)
73
+ - TypeScript type checking.
74
+
75
+ Please make sure your code passes lint/tests/build/type checks before opening a PR.
76
+
77
+ ### Working on the code
78
+
79
+ The narrat codebase isn't currently documented, outside of the [usage docs](https://docs.get-narrat.com). The code is fully written in TypeScript though and should be clearly separated enough to be approachable.
80
+
81
+ ### Engine architecture
82
+
83
+ The narrat engine runs primarily as a Vue app. All the UI in the game is made of Vue components, and when a game uses narrat it effectively creates a Vue app.
84
+
85
+ #### App state
86
+
87
+ The engine's state is stored in pinia. It is split in separate pinia modules for different areas of the engine. They can all be found in the [src/stores](src/stores) folder.
88
+
89
+ - `audio`: handles playing and stopping audio and music
90
+ - `dialog`: Receives and stores all lines of dialogue created by game scripts which appear at the right of the game in the main interactive narrative view.
91
+ - `hud`: Stores stats which are displayed on the hud
92
+ - `inventory`: Manages the player's item inventory
93
+ - `main`: Manages app-level logic and other generic systems like startup/reset/load/save
94
+ - `notifications`: Manages notifications which appear at the top of the screen
95
+ - `quests`: Manages quests and objectives
96
+ - `rendering`: Manages the layout's state for dynamically placing and resizing the game UI
97
+ - `skills`: Manages player skills and xp. Also store skill check states
98
+ - `vm`: Manages the virtual machine which runs the scripting language and controls the game flow.
99
+
100
+ All stores can be accessed anywhere in the code with the `use` hooks (example: `useVM()`).
101
+
102
+ #### Scripting language (VM and parser)
103
+
104
+ The scripting language for narrat runs in a virtual machine which has its state stored in the Vue app with Pinia.
105
+
106
+ The narrat scripting language relies on the parser and the vm. The code for the parser is mainly in [src/vm/vm-parser.ts](src/vm/vm-parser.ts). The parser is in charge of taking the `.nar` files as input, and returning a tree of parsed expressions that the engine can use.
107
+
108
+ The actual VM is what runs narrat games, and generally controls the flow of the application. The general logic for the vm is in the `vm` store, but there is also some logic sprinkled in the `src/vm` file.
109
+
110
+ All the actual operations available to the scripting language (like `talk`) are defined as Command plugins. The built-in commands included in the language by default are in the [src/vm/commands](src/vm/commands/) folder. More command can be added by games by registering plugins.
111
+
112
+ #### Adding new commands
113
+
114
+ Language commands are defined in the `vm/commands` folder. It should be easy to add new commands to the game engine by looking at the existing commands as an example. New command plugins are included in the `vm/commands/index` file.
115
+
116
+ #### Config file
117
+
118
+ The main config file has a type defined in `src/config.ts`. The vast majority of the config options for narrat are passed in this config files, which games must provide to the engine when starting. New options for the engine should be added to the type for the config file, and also have their default value included in the `src/defaultConfig.ts` file.
119
+
120
+ Engine code can access the config with the `getConfig()` function.
121
+
122
+ #### Plugin system
123
+
124
+ There is now a plugin system developers can use to add new functionality to narrat (more documentation soon). See the [narrat-bitsy](https://github.com/liana-pigeot/narrat-bitsy) plugin for an example.
125
+
126
+ (Note: The narrat-bitsy plugin hasn't been updated for 2.0.0 and might be a bit out of date).
127
+
128
+ ## Assets used in demo games
129
+
130
+ - [Pointing arrows from OpenGameArt](https://opengameart.org/content/pointing-arrows)
131
+ - [UI button from OpenGameArt](https://opengameart.org/content/buttons-and-frame)
132
+ - [10 Basic RPG enemies](https://opengameart.org/content/10-basic-rpg-enemies)
133
+ - [RPG Battle backgrounds from OpenGameArt](https://opengameart.org/content/backgrounds-3)
134
+ - [3D City from OpenGameArt](https://opengameart.org/content/3d-city)
135
+
136
+ The rest is handmade.
@@ -1,7 +1,7 @@
1
1
  import { TabOptions } from './tab-selector.vue';
2
2
  export interface TabControllerProps {
3
3
  tabs: TabOptions[];
4
- defaultTab: string;
4
+ defaultTab: number;
5
5
  }
6
6
  declare const _default: {
7
7
  new (...args: any[]): {
@@ -1 +1,2 @@
1
1
  export { getConfig } from '../config';
2
+ export { audioConfig, skillsConfig, itemsConfig, questsConfig, screensConfig, buttonsConfig, tooltipsConfig, charactersConfig, getSkillConfig, getImageUrl, getAssetUrl, getSplitConfigUrl, getDataUrl, getButtonConfig, getScreenConfig, getItemConfig, getQuestConfig, getObjectiveConfig, } from '../config';
@@ -0,0 +1 @@
1
+ export type { ButtonKeybind, AnalogKeybind, ButtonAction, AnalogAction, ButtonActionState, AnalogDirectionState, AnalogActionState, Action, Inputs, } from '../inputs/Inputs';
@@ -28,6 +28,7 @@ export interface CustomMenuTab {
28
28
  component: any;
29
29
  }
30
30
  export declare type NarratPluginObject<T> = {
31
+ pluginId: string;
31
32
  onPageLoaded?: NarratLifecycleHook;
32
33
  onNarratSetup?: NarratLifecycleHook;
33
34
  onAppMounted?: NarratLifecycleHook;
@@ -40,7 +41,26 @@ export declare type NarratPluginObject<T> = {
40
41
  customStores?: CustomStores;
41
42
  customMenuButtons?: CustomMenuButton[];
42
43
  customMenuTabs?: CustomMenuTab[];
44
+ startMenuButtons?: CustomStartMenuButton[];
45
+ save?: () => any;
46
+ load?: (data: any) => void;
47
+ reset?: () => void;
48
+ loadingPromises?: Promise<any>[];
43
49
  };
50
+ /**
51
+ * Custom buttons that get added to the start menu (where the New Game etc buttons are)
52
+ * Action option is to provide a function to run on click
53
+ * popupComponent option is to provide a component to display in a modal window on click (for custom pieces of UI)
54
+ */
55
+ export interface CustomStartMenuButton {
56
+ id: string;
57
+ text: string;
58
+ action?: () => void;
59
+ popupComponent?: {
60
+ name: string;
61
+ component: any;
62
+ };
63
+ }
44
64
  declare function registerPlugin<T>(plugin: NarratPluginObject<T>): void;
45
65
  declare function addCommand<T>(command: CommandPlugin<T>): void;
46
66
  export { CommandRunner };
@@ -1,11 +1,16 @@
1
- export { useMain } from '../stores/main-store';
2
1
  export { useAudio } from '../stores/audio-store';
2
+ export { useConfig } from '../stores/config-store';
3
3
  export { useDialogStore } from '../stores/dialog-store';
4
4
  export { useHud } from '../stores/hud-stats-store';
5
+ export { useInputs } from '../stores/inputs-store';
5
6
  export { useInventory } from '../stores/inventory-store';
7
+ export { useMain } from '../stores/main-store';
8
+ export { useMenu } from '../stores/menu-store';
6
9
  export { useNotifications } from '../stores/notification-store';
7
10
  export { useQuests } from '../stores/quest-log';
8
11
  export { useRenderingStore } from '../stores/rendering-store';
12
+ export { useScreenObjects } from '../stores/screen-objects-store';
9
13
  export { useScreens } from '../stores/screens-store';
10
14
  export { useSkills } from '../stores/skills';
15
+ export { useTooltips } from '../stores/tooltip-store';
11
16
  export { useVM } from '../stores/vm-store';
@@ -0,0 +1,12 @@
1
+ export { error, warning } from '../utils/error-handling';
2
+ export { processText, findVariable } from '../utils/string-helpers';
3
+ export { getFile, loadDataFile } from '../utils/ajax';
4
+ export { getWindow } from '../utils/getWindow';
5
+ export { InputsListener, inputEvents } from '../utils/InputsListener';
6
+ export type { InputEvents } from '../utils/InputsListener';
7
+ export { LogManager, logManager, logger } from '../utils/logger';
8
+ export { timeout } from '../utils/promises';
9
+ export { randomId } from '../utils/randomId';
10
+ export { Vec2 } from '../utils/Vector2';
11
+ export type { Vector2 } from '../utils/Vector2';
12
+ export { gameloop } from '../utils/gameloop';
package/dist/favicon.svg CHANGED
@@ -1,30 +1,30 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <!-- Generator: Adobe Illustrator 19.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
3
- <svg version="1.1" id="Rat" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
4
- viewBox="0 0 595.3 595.3" style="enable-background:new 0 0 595.3 595.3;" xml:space="preserve">
5
- <style type="text/css">
6
- .st0{fill:#E23B33;}
7
- </style>
8
- <path id="Rat_Shape" class="st0" d="M556.9,82.5c-10.8-24.3-47-57.1-71.3-65.6c-24.3-8.4-64.1-0.3-88.7,22.3
9
- c-20,18.4-26,28.2-29.1,37c-2.1,5.9-4.8,13.5-6,20.9v0c-0.5,4.1-4.5,7-8.6,6.1c-10.4-2.3-29.5-6-44.4-6.3
10
- c-13.7-0.2-30.1,3.2-40.4,5.7c-4.5,1.1-8.8-2.2-8.8-6.8c-0.1-5.3-1.1-12.3-4.8-19.6c-8.5-16.9-19.6-32.6-57.8-47.4
11
- c-31.9-12.4-75.1-9.7-100.8,1.8c-28.1,12.6-42.4,37.9-54,61.8c-14.4,29.8-14.9,83.6-6.4,104c12.8,30.7,35.8,47.2,52.6,53
12
- c11.3,3.8,28.2,3.7,38.2,3.3c4.2-0.2,7.7,3.3,7.5,7.5c-0.7,13.6-0.9,41.5,7,61.4c7.7,19.4,29.7,62.3,50.7,101.2
13
- c0,0.1-14.6,2.9-31.4,6.8c-23.9,5.5-52.6,12.7-54.3,13.7c-3.5,2.1-3,10-2.7,12c0.5,3.4,5.3,8.1,6.9,8.3c3.9,0.3,31.3-7.6,55.7-14.6
14
- c18.5-5.3,34.9-9.3,35.5-8.2c5.1,9.3,10,18,14.4,25.8c5.2,9.1,10.7,16.4,14.1,23.6c1.1,2.3-16.6,5.8-32.5,14.7
15
- c-16.4,9.1-29.7,21-32.3,24c-1.8,2.1-3,6-1.2,10.7c1.1,2.9,10,5.7,12.4,5.1c6.8-1.7,16.5-12.5,33.1-21.1
16
- c16.3-8.5,32.9-14.9,33.8-13.6c9.7,14.3,16.9,21.6,22.6,31.2c9.8,16.5,27.3,45.9,46.6,39.5c6.4-2.1,31.1-33.6,53.3-68.6
17
- c1.3-2.1,16.1,11.3,30.4,23.2c13.8,11.4,22.7,20.6,27.1,21.4c5.4,1,14.2-7.7,14.1-14.7c-0.1-2.7-14.3-13.8-29.1-26.2
18
- c-14.5-12.1-30.1-22.8-29.2-24.3c7.6-12,14.5-23.7,20.1-33.9c4.3-7.8,8.9-16,13-24.7c0.6-1.2,15.9,3,31.4,7.1c15.3,4,26.7,10,31,8
19
- c6.9-3,11.6-13.8,9.4-18.3c-1.1-2.3-17-7.3-33.2-12c-14.2-4.1-28-6.5-27.7-7.3c15.5-34,28.8-64.8,27.6-69.6
20
- c-1.7-7.1,2.6-11.9,7-36.5c3.2-18.1,4.7-40.9,5.2-51.7c0.2-3.5,2.8-6.3,6.3-6.7c3.1-0.3,6.9-0.9,10.5-1.9c7.8-2,18.6-7.8,36.4-20.6
21
- c17.9-12.8,38.7-49.6,44.4-67.8S567.6,106.8,556.9,82.5z M265.1,336.2c-8.1,4-13,7-26.4,9.6c-6.9,1.4-29.4-0.2-40.7-4.6
22
- c-10.5-4.1-19.9-7.6-30-15.4s-15.7-13.2-15.7-15.3c0-4.4,6-9.4,11-9.4c5.1,0,14.5,9.2,29.7,16.6c14.3,7,17.9,6.1,25.4,7.3
23
- c2.9,0.5,7.7,0.6,10.7,0.4c14.1-1.3,21.4-5.9,25.3-8.8c4-3,13.7-12.9,17.2-12.5c8,1,18.9,3.4,18.9,7.1
24
- C290.4,319,273.2,332.1,265.1,336.2z M320.9,521.4c-4.3,3.7-17.7,13.5-23.3,13.5c-2.8,0-7.4-8.2-11.5-16.8
25
- c-4.1-8.5-9.1-21.1-9.1-31.6c0-4.6,6-7.4,13.4-9.2c7.2-1.7,27.3-1.8,29.9-1.1c6.8,1.7,12.9,2.2,12.7,6.4c-0.4,12.7-7,18.9-8.3,24.3
26
- C323.4,512.3,323.4,519.2,320.9,521.4z M431.1,320.3c-9.2,7.4-10.6,8.1-24.9,13.7c-11.3,4.4-28.6,5.8-41.6,3.6
27
- c-12.2-2.1-22.3-4.6-29.5-10.1c-9.7-7.3-16.4-15.1-16.4-19.8c0-3.7,6.4-4.3,14.5-4.9c3.5-0.3,9.3,5.9,13.2,9.2
28
- c8.1,6.8,14.8,8,28.8,9.9c2.9,0.4,7.8,0.4,10.7,0.1c7.5-0.9,12-0.4,25.8-8.2c20-11.2,17.8-14.4,25.1-12.6c2.2,0.6,5.8,1.2,5.6,5.6
29
- C442.4,309,440.5,312.7,431.1,320.3z"/>
30
- </svg>
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <!-- Generator: Adobe Illustrator 19.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
3
+ <svg version="1.1" id="Rat" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
4
+ viewBox="0 0 595.3 595.3" style="enable-background:new 0 0 595.3 595.3;" xml:space="preserve">
5
+ <style type="text/css">
6
+ .st0{fill:#E23B33;}
7
+ </style>
8
+ <path id="Rat_Shape" class="st0" d="M556.9,82.5c-10.8-24.3-47-57.1-71.3-65.6c-24.3-8.4-64.1-0.3-88.7,22.3
9
+ c-20,18.4-26,28.2-29.1,37c-2.1,5.9-4.8,13.5-6,20.9v0c-0.5,4.1-4.5,7-8.6,6.1c-10.4-2.3-29.5-6-44.4-6.3
10
+ c-13.7-0.2-30.1,3.2-40.4,5.7c-4.5,1.1-8.8-2.2-8.8-6.8c-0.1-5.3-1.1-12.3-4.8-19.6c-8.5-16.9-19.6-32.6-57.8-47.4
11
+ c-31.9-12.4-75.1-9.7-100.8,1.8c-28.1,12.6-42.4,37.9-54,61.8c-14.4,29.8-14.9,83.6-6.4,104c12.8,30.7,35.8,47.2,52.6,53
12
+ c11.3,3.8,28.2,3.7,38.2,3.3c4.2-0.2,7.7,3.3,7.5,7.5c-0.7,13.6-0.9,41.5,7,61.4c7.7,19.4,29.7,62.3,50.7,101.2
13
+ c0,0.1-14.6,2.9-31.4,6.8c-23.9,5.5-52.6,12.7-54.3,13.7c-3.5,2.1-3,10-2.7,12c0.5,3.4,5.3,8.1,6.9,8.3c3.9,0.3,31.3-7.6,55.7-14.6
14
+ c18.5-5.3,34.9-9.3,35.5-8.2c5.1,9.3,10,18,14.4,25.8c5.2,9.1,10.7,16.4,14.1,23.6c1.1,2.3-16.6,5.8-32.5,14.7
15
+ c-16.4,9.1-29.7,21-32.3,24c-1.8,2.1-3,6-1.2,10.7c1.1,2.9,10,5.7,12.4,5.1c6.8-1.7,16.5-12.5,33.1-21.1
16
+ c16.3-8.5,32.9-14.9,33.8-13.6c9.7,14.3,16.9,21.6,22.6,31.2c9.8,16.5,27.3,45.9,46.6,39.5c6.4-2.1,31.1-33.6,53.3-68.6
17
+ c1.3-2.1,16.1,11.3,30.4,23.2c13.8,11.4,22.7,20.6,27.1,21.4c5.4,1,14.2-7.7,14.1-14.7c-0.1-2.7-14.3-13.8-29.1-26.2
18
+ c-14.5-12.1-30.1-22.8-29.2-24.3c7.6-12,14.5-23.7,20.1-33.9c4.3-7.8,8.9-16,13-24.7c0.6-1.2,15.9,3,31.4,7.1c15.3,4,26.7,10,31,8
19
+ c6.9-3,11.6-13.8,9.4-18.3c-1.1-2.3-17-7.3-33.2-12c-14.2-4.1-28-6.5-27.7-7.3c15.5-34,28.8-64.8,27.6-69.6
20
+ c-1.7-7.1,2.6-11.9,7-36.5c3.2-18.1,4.7-40.9,5.2-51.7c0.2-3.5,2.8-6.3,6.3-6.7c3.1-0.3,6.9-0.9,10.5-1.9c7.8-2,18.6-7.8,36.4-20.6
21
+ c17.9-12.8,38.7-49.6,44.4-67.8S567.6,106.8,556.9,82.5z M265.1,336.2c-8.1,4-13,7-26.4,9.6c-6.9,1.4-29.4-0.2-40.7-4.6
22
+ c-10.5-4.1-19.9-7.6-30-15.4s-15.7-13.2-15.7-15.3c0-4.4,6-9.4,11-9.4c5.1,0,14.5,9.2,29.7,16.6c14.3,7,17.9,6.1,25.4,7.3
23
+ c2.9,0.5,7.7,0.6,10.7,0.4c14.1-1.3,21.4-5.9,25.3-8.8c4-3,13.7-12.9,17.2-12.5c8,1,18.9,3.4,18.9,7.1
24
+ C290.4,319,273.2,332.1,265.1,336.2z M320.9,521.4c-4.3,3.7-17.7,13.5-23.3,13.5c-2.8,0-7.4-8.2-11.5-16.8
25
+ c-4.1-8.5-9.1-21.1-9.1-31.6c0-4.6,6-7.4,13.4-9.2c7.2-1.7,27.3-1.8,29.9-1.1c6.8,1.7,12.9,2.2,12.7,6.4c-0.4,12.7-7,18.9-8.3,24.3
26
+ C323.4,512.3,323.4,519.2,320.9,521.4z M431.1,320.3c-9.2,7.4-10.6,8.1-24.9,13.7c-11.3,4.4-28.6,5.8-41.6,3.6
27
+ c-12.2-2.1-22.3-4.6-29.5-10.1c-9.7-7.3-16.4-15.1-16.4-19.8c0-3.7,6.4-4.3,14.5-4.9c3.5-0.3,9.3,5.9,13.2,9.2
28
+ c8.1,6.8,14.8,8,28.8,9.9c2.9,0.4,7.8,0.4,10.7,0.1c7.5-0.9,12-0.4,25.8-8.2c20-11.2,17.8-14.4,25.1-12.6c2.2,0.6,5.8,1.2,5.6,5.6
29
+ C442.4,309,440.5,312.7,431.1,320.3z"/>
30
+ </svg>
@@ -0,0 +1,61 @@
1
+ import { Vector2 } from '../utils/Vector2';
2
+ export interface ButtonKeybind {
3
+ keyboardKey: string;
4
+ }
5
+ export interface AnalogKeybind {
6
+ left: string;
7
+ right: string;
8
+ up: string;
9
+ down: string;
10
+ }
11
+ export interface ButtonAction {
12
+ id: string;
13
+ type: 'button';
14
+ action: 'press' | 'release';
15
+ keybinds: ButtonKeybind[];
16
+ }
17
+ export interface AnalogAction {
18
+ id: string;
19
+ type: 'analog';
20
+ keybinds: AnalogKeybind[];
21
+ }
22
+ export interface ButtonActionState {
23
+ active: boolean;
24
+ previous: boolean;
25
+ }
26
+ export interface AnalogDirectionState {
27
+ left: number;
28
+ right: number;
29
+ up: number;
30
+ down: number;
31
+ }
32
+ export interface AnalogActionState {
33
+ value: Vector2;
34
+ previous: Vector2;
35
+ fullState: AnalogDirectionState;
36
+ previousFullState: AnalogDirectionState;
37
+ }
38
+ export declare type Action = ButtonAction | AnalogAction;
39
+ export declare class Inputs {
40
+ gameActions: {
41
+ [key: string]: Action;
42
+ };
43
+ keyboardState: {
44
+ [key: string]: {
45
+ current: boolean;
46
+ previous: boolean;
47
+ };
48
+ };
49
+ actions: {
50
+ [key: string]: ButtonActionState | AnalogActionState;
51
+ };
52
+ startListening(): void;
53
+ addAction(action: Action): void;
54
+ getAnalog(actionId: string): AnalogActionState;
55
+ getButton(actionId: string): ButtonActionState;
56
+ getKeyState(key: string): {
57
+ current: boolean;
58
+ previous: boolean;
59
+ };
60
+ update(): void;
61
+ }
package/dist/lib.d.ts CHANGED
@@ -13,6 +13,8 @@ export * from './exports/plugins';
13
13
  export * from './exports/display';
14
14
  export * from './exports/config';
15
15
  export * from './exports/events';
16
+ export * from './exports/inputs';
16
17
  export * from './exports/stores';
17
18
  export * from './exports/others';
18
19
  export * from './exports/components';
20
+ export * from './exports/utils';