@inglorious/engine 0.1.0 → 0.1.1

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.
Files changed (92) hide show
  1. package/package.json +11 -12
  2. package/src/docs/ai/movement/dynamic/align.js +0 -131
  3. package/src/docs/ai/movement/dynamic/arrive.js +0 -88
  4. package/src/docs/ai/movement/dynamic/dynamic.mdx +0 -99
  5. package/src/docs/ai/movement/dynamic/dynamic.stories.js +0 -58
  6. package/src/docs/ai/movement/dynamic/evade.js +0 -72
  7. package/src/docs/ai/movement/dynamic/face.js +0 -90
  8. package/src/docs/ai/movement/dynamic/flee.js +0 -38
  9. package/src/docs/ai/movement/dynamic/look-where-youre-going.js +0 -114
  10. package/src/docs/ai/movement/dynamic/match-velocity.js +0 -92
  11. package/src/docs/ai/movement/dynamic/pursue.js +0 -72
  12. package/src/docs/ai/movement/dynamic/seek.js +0 -37
  13. package/src/docs/ai/movement/dynamic/wander.js +0 -71
  14. package/src/docs/ai/movement/kinematic/align.js +0 -122
  15. package/src/docs/ai/movement/kinematic/arrive.js +0 -78
  16. package/src/docs/ai/movement/kinematic/face.js +0 -82
  17. package/src/docs/ai/movement/kinematic/flee.js +0 -36
  18. package/src/docs/ai/movement/kinematic/kinematic.mdx +0 -67
  19. package/src/docs/ai/movement/kinematic/kinematic.stories.js +0 -42
  20. package/src/docs/ai/movement/kinematic/seek.js +0 -34
  21. package/src/docs/ai/movement/kinematic/wander-as-seek.js +0 -62
  22. package/src/docs/ai/movement/kinematic/wander.js +0 -28
  23. package/src/docs/bounds.js +0 -7
  24. package/src/docs/code-reuse.js +0 -35
  25. package/src/docs/collision/circles.js +0 -58
  26. package/src/docs/collision/collision.mdx +0 -27
  27. package/src/docs/collision/collision.stories.js +0 -22
  28. package/src/docs/collision/platform.js +0 -76
  29. package/src/docs/collision/tilemap.js +0 -181
  30. package/src/docs/empty.js +0 -1
  31. package/src/docs/engine.mdx +0 -81
  32. package/src/docs/engine.stories.js +0 -37
  33. package/src/docs/event-handlers.js +0 -68
  34. package/src/docs/framerate.js +0 -37
  35. package/src/docs/game.jsx +0 -15
  36. package/src/docs/image/image.js +0 -19
  37. package/src/docs/image/image.stories.js +0 -22
  38. package/src/docs/image/sprite.js +0 -39
  39. package/src/docs/image/tilemap.js +0 -84
  40. package/src/docs/input/controls.js +0 -67
  41. package/src/docs/input/gamepad.js +0 -67
  42. package/src/docs/input/input.mdx +0 -55
  43. package/src/docs/input/input.stories.js +0 -27
  44. package/src/docs/input/keyboard.js +0 -58
  45. package/src/docs/input/mouse.js +0 -32
  46. package/src/docs/instances.js +0 -49
  47. package/src/docs/player/dynamic/double-jump.js +0 -90
  48. package/src/docs/player/dynamic/dynamic.stories.js +0 -32
  49. package/src/docs/player/dynamic/jump.js +0 -83
  50. package/src/docs/player/dynamic/modern-controls.js +0 -57
  51. package/src/docs/player/dynamic/shooter-controls.js +0 -51
  52. package/src/docs/player/dynamic/tank-controls.js +0 -44
  53. package/src/docs/player/kinematic/double-jump.js +0 -90
  54. package/src/docs/player/kinematic/jump.js +0 -82
  55. package/src/docs/player/kinematic/kinematic.stories.js +0 -32
  56. package/src/docs/player/kinematic/modern-controls.js +0 -56
  57. package/src/docs/player/kinematic/shooter-controls.js +0 -48
  58. package/src/docs/player/kinematic/tank-controls.js +0 -42
  59. package/src/docs/quick-start/first-game.js +0 -49
  60. package/src/docs/quick-start/hello-world.js +0 -1
  61. package/src/docs/quick-start.mdx +0 -127
  62. package/src/docs/quick-start.stories.js +0 -17
  63. package/src/docs/recipes/add-and-remove.js +0 -71
  64. package/src/docs/recipes/add-instance.js +0 -42
  65. package/src/docs/recipes/decision-tree.js +0 -169
  66. package/src/docs/recipes/random-instances.js +0 -25
  67. package/src/docs/recipes/recipes.mdx +0 -81
  68. package/src/docs/recipes/recipes.stories.js +0 -37
  69. package/src/docs/recipes/remove-instance.js +0 -52
  70. package/src/docs/recipes/states.js +0 -64
  71. package/src/docs/ui/button.js +0 -28
  72. package/src/docs/ui/form.stories.js +0 -55
  73. package/src/docs/ui-chooser.jsx +0 -6
  74. package/src/docs/utils/data-structures/object.mdx +0 -47
  75. package/src/docs/utils/data-structures/objects.mdx +0 -30
  76. package/src/docs/utils/functions/functions.mdx +0 -34
  77. package/src/docs/utils/math/geometry/circle.mdx +0 -55
  78. package/src/docs/utils/math/geometry/point.mdx +0 -38
  79. package/src/docs/utils/math/geometry/rectangle.mdx +0 -24
  80. package/src/docs/utils/math/geometry/segment.mdx +0 -55
  81. package/src/docs/utils/math/geometry/triangle.mdx +0 -22
  82. package/src/docs/utils/math/linear-algebra/2d.mdx +0 -22
  83. package/src/docs/utils/math/linear-algebra/quaternion.mdx +0 -21
  84. package/src/docs/utils/math/linear-algebra/quaternions.mdx +0 -22
  85. package/src/docs/utils/math/linear-algebra/vector.mdx +0 -177
  86. package/src/docs/utils/math/linear-algebra/vectors.mdx +0 -58
  87. package/src/docs/utils/math/numbers.mdx +0 -76
  88. package/src/docs/utils/math/random.mdx +0 -35
  89. package/src/docs/utils/math/statistics.mdx +0 -38
  90. package/src/docs/utils/math/trigonometry.mdx +0 -85
  91. package/src/docs/utils/physics/friction.mdx +0 -20
  92. package/src/docs/utils/physics/gravity.mdx +0 -28
@@ -1,114 +0,0 @@
1
- import {
2
- DEFAULT_SLOW_RADIUS,
3
- DEFAULT_TARGET_RADIUS,
4
- DEFAULT_TIME_TO_TARGET,
5
- } from "@inglorious/engine/ai/movement/dynamic/align.js"
6
- import lookWhereYoureGoing from "@inglorious/engine/ai/movement/dynamic/look-where-youre-going.js"
7
- import { clampToBounds } from "@inglorious/game/bounds.js"
8
- import { enableCharacter } from "@inglorious/game/decorators/character.js"
9
- import {
10
- createControls,
11
- enableControls,
12
- } from "@inglorious/game/decorators/input/controls.js"
13
- import { merge } from "@inglorious/utils/data-structures/objects.js"
14
- import { sum } from "@inglorious/utils/math/linear-algebra/vectors.js"
15
- import { pi } from "@inglorious/utils/math/trigonometry.js"
16
-
17
- export default {
18
- types: {
19
- ...enableControls(),
20
-
21
- character: [
22
- enableCharacter(),
23
- {
24
- "game:update"(instance, event, { dt, instances }) {
25
- const { fields } = instances.parameters.groups.lookWhereYoureGoing
26
-
27
- const { input0 } = instances
28
-
29
- const target = { velocity: [0, 0, 0] }
30
- if (input0.left) {
31
- target.velocity[0] = -1
32
- }
33
- if (input0.down) {
34
- target.velocity[2] = -1
35
- }
36
- if (input0.right) {
37
- target.velocity[0] = 1
38
- }
39
- if (input0.up) {
40
- target.velocity[2] = 1
41
- }
42
-
43
- merge(instance, {
44
- velocity: target.velocity,
45
- position: sum(instance.position, target.velocity),
46
- })
47
-
48
- merge(
49
- instance,
50
- lookWhereYoureGoing(instance, {
51
- dt,
52
- targetRadius: fields.targetRadius.value,
53
- slowRadius: fields.slowRadius.value,
54
- timeToTarget: fields.timeToTarget.value,
55
- }),
56
- )
57
-
58
- clampToBounds(instance, instances.game.bounds)
59
- },
60
- },
61
- ],
62
-
63
- form: {
64
- "field:change"(instance, event) {
65
- const { id, value } = event.payload
66
- instance.groups.lookWhereYoureGoing.fields[id].value = value
67
- },
68
- },
69
- },
70
-
71
- instances: {
72
- ...createControls("input0", {
73
- ArrowLeft: "left",
74
- ArrowRight: "right",
75
- ArrowDown: "down",
76
- ArrowUp: "up",
77
- }),
78
-
79
- character: {
80
- type: "character",
81
- maxAngularAcceleration: 1000,
82
- maxAngularSpeed: pi() / 4,
83
- position: [400, 0, 300],
84
- },
85
-
86
- parameters: {
87
- type: "form",
88
- position: [800 - 328, 0, 600],
89
- groups: {
90
- lookWhereYoureGoing: {
91
- title: "Look Where You're Going",
92
- fields: {
93
- targetRadius: {
94
- label: "Target Radius",
95
- inputType: "number",
96
- defaultValue: DEFAULT_TARGET_RADIUS,
97
- },
98
- slowRadius: {
99
- label: "Slow Radius",
100
- inputType: "number",
101
- defaultValue: DEFAULT_SLOW_RADIUS,
102
- },
103
- timeToTarget: {
104
- label: "Time To Target",
105
- inputType: "number",
106
- step: 0.1,
107
- defaultValue: DEFAULT_TIME_TO_TARGET,
108
- },
109
- },
110
- },
111
- },
112
- },
113
- },
114
- }
@@ -1,92 +0,0 @@
1
- import matchVelocity, {
2
- DEFAULT_TIME_TO_TARGET,
3
- } from "@inglorious/engine/ai/movement/dynamic/match-velocity.js"
4
- import { clampToBounds } from "@inglorious/game/bounds.js"
5
- import { enableCharacter } from "@inglorious/game/decorators/character.js"
6
- import {
7
- createControls,
8
- enableControls,
9
- } from "@inglorious/game/decorators/input/controls.js"
10
- import { merge } from "@inglorious/utils/data-structures/objects.js"
11
-
12
- export default {
13
- types: {
14
- ...enableControls(),
15
-
16
- character: [
17
- enableCharacter(),
18
- {
19
- "game:update"(instance, event, options) {
20
- const { parameters, input0, game } = options.instances
21
- const { fields } = parameters.groups.matchVelocity
22
- const SPEED = instance.maxSpeed
23
-
24
- const target = { velocity: [0, 0, 0] }
25
- if (input0.left) {
26
- target.velocity[0] = -SPEED
27
- }
28
- if (input0.down) {
29
- target.velocity[2] = -SPEED
30
- }
31
- if (input0.right) {
32
- target.velocity[0] = SPEED
33
- }
34
- if (input0.up) {
35
- target.velocity[2] = SPEED
36
- }
37
-
38
- merge(
39
- instance,
40
- matchVelocity(instance, target, {
41
- dt: options.dt,
42
- timeToTarget: fields.timeToTarget.value,
43
- }),
44
- )
45
-
46
- clampToBounds(instance, game.bounds)
47
- },
48
- },
49
- ],
50
-
51
- form: {
52
- "field:change"(instance, event) {
53
- const { id, value } = event.payload
54
- instance.groups.matchVelocity.fields[id].value = value
55
- },
56
- },
57
- },
58
-
59
- instances: {
60
- ...createControls("input0", {
61
- ArrowLeft: "left",
62
- ArrowRight: "right",
63
- ArrowDown: "down",
64
- ArrowUp: "up",
65
- }),
66
-
67
- character: {
68
- type: "character",
69
- maxAcceleration: 1000,
70
- maxSpeed: 250,
71
- position: [400, 0, 300],
72
- },
73
-
74
- parameters: {
75
- type: "form",
76
- position: [800 - 328, 0, 600],
77
- groups: {
78
- matchVelocity: {
79
- title: "Match Velocity",
80
- fields: {
81
- timeToTarget: {
82
- label: "Time To Target",
83
- inputType: "number",
84
- step: 0.1,
85
- defaultValue: DEFAULT_TIME_TO_TARGET,
86
- },
87
- },
88
- },
89
- },
90
- },
91
- },
92
- }
@@ -1,72 +0,0 @@
1
- import pursue, {
2
- DEFAULT_MAX_PREDICTION,
3
- } from "@inglorious/engine/ai/movement/dynamic/pursue.js"
4
- import { clampToBounds } from "@inglorious/game/bounds.js"
5
- import { enableCharacter } from "@inglorious/game/decorators/character.js"
6
- import { enableMouse } from "@inglorious/game/decorators/input/mouse.js"
7
- import { merge } from "@inglorious/utils/data-structures/objects.js"
8
-
9
- export default {
10
- types: {
11
- mouse: [enableMouse()],
12
-
13
- character: [
14
- enableCharacter(),
15
- {
16
- "game:update"(instance, event, { dt, instances }) {
17
- const target = instances.mouse
18
- const { fields } = instances.parameters.groups.pursue
19
-
20
- merge(
21
- instance,
22
- pursue(instance, target, {
23
- dt,
24
- maxPrediction: fields.maxPrediction.value,
25
- }),
26
- )
27
-
28
- clampToBounds(instance, instances.game.bounds)
29
- },
30
- },
31
- ],
32
-
33
- form: {
34
- "field:change"(instance, event) {
35
- const { id, value } = event.payload
36
- instance.groups.pursue.fields[id].value = value
37
- },
38
- },
39
- },
40
-
41
- instances: {
42
- mouse: {
43
- type: "mouse",
44
- position: [400, 0, 300],
45
- velocity: [0, 0, 0],
46
- },
47
-
48
- character: {
49
- type: "character",
50
- maxAcceleration: 1000,
51
- maxSpeed: 250,
52
- position: [400, 0, 300],
53
- },
54
-
55
- parameters: {
56
- type: "form",
57
- position: [800 - 343, 0, 600],
58
- groups: {
59
- pursue: {
60
- title: "Pursue",
61
- fields: {
62
- maxPrediction: {
63
- label: "Max Prediction",
64
- inputType: "number",
65
- defaultValue: DEFAULT_MAX_PREDICTION,
66
- },
67
- },
68
- },
69
- },
70
- },
71
- },
72
- }
@@ -1,37 +0,0 @@
1
- import seek from "@inglorious/engine/ai/movement/dynamic/seek.js"
2
- import { clampToBounds } from "@inglorious/game/bounds.js"
3
- import { enableCharacter } from "@inglorious/game/decorators/character.js"
4
- import { enableMouse } from "@inglorious/game/decorators/input/mouse.js"
5
- import { merge } from "@inglorious/utils/data-structures/objects.js"
6
-
7
- export default {
8
- types: {
9
- mouse: [enableMouse()],
10
-
11
- character: [
12
- enableCharacter(),
13
- {
14
- "game:update"(instance, event, { dt, instances }) {
15
- const target = instances.mouse
16
-
17
- merge(instance, seek(instance, target, { dt }))
18
- clampToBounds(instance, instances.game.bounds)
19
- },
20
- },
21
- ],
22
- },
23
-
24
- instances: {
25
- mouse: {
26
- type: "mouse",
27
- position: [400, 0, 300],
28
- },
29
-
30
- character: {
31
- type: "character",
32
- maxAcceleration: 1000,
33
- maxSpeed: 250,
34
- position: [400, 0, 300],
35
- },
36
- },
37
- }
@@ -1,71 +0,0 @@
1
- import wander, {
2
- DEFAULT_WANDER_OFFSET,
3
- DEFAULT_WANDER_RADIUS,
4
- } from "@inglorious/engine/ai/movement/dynamic/wander.js"
5
- import { flip } from "@inglorious/game/bounds.js"
6
- import { enableCharacter } from "@inglorious/game/decorators/character.js"
7
- import { merge } from "@inglorious/utils/data-structures/objects.js"
8
- import { pi } from "@inglorious/utils/math/trigonometry.js"
9
-
10
- export default {
11
- types: {
12
- character: [
13
- enableCharacter(),
14
- {
15
- "game:update"(instance, event, { dt, instances }) {
16
- const { fields } = instances.parameters.groups.wander
17
-
18
- merge(
19
- instance,
20
- wander(instance, {
21
- dt,
22
- wanderOffset: fields.wanderOffset.value,
23
- wanderRadius: fields.wanderRadius.value,
24
- }),
25
- )
26
- flip(instance, instances.game.bounds)
27
- },
28
- },
29
- ],
30
-
31
- form: {
32
- "field:change"(instance, event) {
33
- const { id, value } = event.payload
34
- instance.groups.wander.fields[id].value = value
35
- },
36
- },
37
- },
38
-
39
- instances: {
40
- character: {
41
- type: "character",
42
- maxAcceleration: 1000,
43
- maxSpeed: 250,
44
- maxAngularSpeed: pi() / 4,
45
- position: [400, 0, 300],
46
- },
47
-
48
- parameters: {
49
- type: "form",
50
- position: [800 - 352, 0, 600],
51
- groups: {
52
- wander: {
53
- title: "Dynamic Wander",
54
- fields: {
55
- wanderOffset: {
56
- label: "Wander Offset",
57
- inputType: "number",
58
- defaultValue: DEFAULT_WANDER_OFFSET,
59
- },
60
- wanderRadius: {
61
- label: "Wander Radius",
62
- inputType: "number",
63
- step: 0.1,
64
- defaultValue: DEFAULT_WANDER_RADIUS,
65
- },
66
- },
67
- },
68
- },
69
- },
70
- },
71
- }
@@ -1,122 +0,0 @@
1
- import align, {
2
- DEFAULT_TARGET_RADIUS,
3
- DEFAULT_TIME_TO_TARGET,
4
- } from "@inglorious/engine/ai/movement/kinematic/align.js"
5
- import { clampToBounds } from "@inglorious/game/bounds.js"
6
- import { enableCharacter } from "@inglorious/game/decorators/character.js"
7
- import {
8
- createControls,
9
- enableControls,
10
- } from "@inglorious/game/decorators/input/controls.js"
11
- import { enableMouse } from "@inglorious/game/decorators/input/mouse.js"
12
- import { merge } from "@inglorious/utils/data-structures/objects.js"
13
- import { clamp } from "@inglorious/utils/math/numbers.js"
14
- import { pi } from "@inglorious/utils/math/trigonometry.js"
15
-
16
- export default {
17
- types: {
18
- mouse: [
19
- enableMouse(),
20
- {
21
- "field:change"(instance, event) {
22
- const { id, value } = event.payload
23
- if (id === "targetOrientation") {
24
- instance.orientation = -value * pi()
25
- }
26
- },
27
-
28
- "game:update"(instance, event, options) {
29
- const { input0 } = options.instances
30
-
31
- if (input0.left || input0.up) {
32
- instance.orientation += 0.1
33
- } else if (input0.right || input0.down) {
34
- instance.orientation -= 0.1
35
- }
36
- instance.orientation = clamp(instance.orientation, -pi(), pi())
37
- },
38
- },
39
- ],
40
-
41
- ...enableControls(),
42
-
43
- character: [
44
- enableCharacter(),
45
- {
46
- "game:update"(instance, event, { dt, instances }) {
47
- const target = instances.mouse
48
- const { fields } = instances.parameters.groups.align
49
-
50
- merge(
51
- instance,
52
- align(instance, target, {
53
- dt,
54
- targetRadius: fields.targetRadius.value,
55
- timeToTarget: fields.timeToTarget.value,
56
- }),
57
- )
58
-
59
- clampToBounds(instance, instances.game.bounds)
60
- },
61
- },
62
- ],
63
-
64
- form: {
65
- "field:change"(instance, event) {
66
- const { id, value } = event.payload
67
- instance.groups.align.fields[id].value = value
68
- },
69
- },
70
- },
71
-
72
- instances: {
73
- mouse: {
74
- type: "mouse",
75
- position: [400, 0, 300],
76
- orientation: 0,
77
- },
78
- ...createControls("input0", {
79
- ArrowLeft: "left",
80
- ArrowRight: "right",
81
- ArrowDown: "down",
82
- ArrowUp: "up",
83
- }),
84
-
85
- character: {
86
- type: "character",
87
- maxAngularSpeed: pi() / 4,
88
- position: [400, 0, 300],
89
- },
90
-
91
- parameters: {
92
- type: "form",
93
- position: [800 - 328, 0, 600],
94
- groups: {
95
- align: {
96
- title: "Kinematic Align",
97
- fields: {
98
- targetRadius: {
99
- label: "Target Radius",
100
- inputType: "number",
101
- defaultValue: DEFAULT_TARGET_RADIUS,
102
- },
103
- timeToTarget: {
104
- label: "Time To Target",
105
- inputType: "number",
106
- step: 0.1,
107
- defaultValue: DEFAULT_TIME_TO_TARGET,
108
- },
109
- targetOrientation: {
110
- label: "Target Orientation",
111
- inputType: "number",
112
- step: 0.25,
113
- min: -1,
114
- max: 1,
115
- defaultValue: 0,
116
- },
117
- },
118
- },
119
- },
120
- },
121
- },
122
- }
@@ -1,78 +0,0 @@
1
- import arrive, {
2
- DEFAULT_TARGET_RADIUS,
3
- DEFAULT_TIME_TO_TARGET,
4
- } from "@inglorious/engine/ai/movement/kinematic/arrive.js"
5
- import { clampToBounds } from "@inglorious/game/bounds.js"
6
- import { enableCharacter } from "@inglorious/game/decorators/character.js"
7
- import { enableMouse } from "@inglorious/game/decorators/input/mouse.js"
8
- import { merge } from "@inglorious/utils/data-structures/objects.js"
9
-
10
- export default {
11
- types: {
12
- mouse: [enableMouse()],
13
-
14
- character: [
15
- enableCharacter(),
16
- {
17
- "game:update"(instance, event, { dt, instances }) {
18
- const target = instances.mouse
19
- const { fields } = instances.parameters.groups.arrive
20
-
21
- merge(
22
- instance,
23
- arrive(instance, target, {
24
- dt,
25
- targetRadius: fields.targetRadius.value,
26
- timeToTarget: fields.timeToTarget.value,
27
- }),
28
- )
29
-
30
- clampToBounds(instance, instances.game.bounds)
31
- },
32
- },
33
- ],
34
-
35
- form: {
36
- "field:change"(instance, event) {
37
- const { id, value } = event.payload
38
- instance.groups.arrive.fields[id].value = value
39
- },
40
- },
41
- },
42
-
43
- instances: {
44
- mouse: {
45
- type: "mouse",
46
- position: [400, 0, 300],
47
- },
48
-
49
- character: {
50
- type: "character",
51
- maxSpeed: 250,
52
- position: [400, 0, 300],
53
- },
54
-
55
- parameters: {
56
- type: "form",
57
- position: [800 - 328, 0, 600],
58
- groups: {
59
- arrive: {
60
- title: "Kinematic Arrive",
61
- fields: {
62
- targetRadius: {
63
- label: "Target Radius",
64
- inputType: "number",
65
- defaultValue: DEFAULT_TARGET_RADIUS,
66
- },
67
- timeToTarget: {
68
- label: "Time To Target",
69
- inputType: "number",
70
- step: 0.1,
71
- defaultValue: DEFAULT_TIME_TO_TARGET,
72
- },
73
- },
74
- },
75
- },
76
- },
77
- },
78
- }
@@ -1,82 +0,0 @@
1
- import {
2
- DEFAULT_TARGET_RADIUS,
3
- DEFAULT_TIME_TO_TARGET,
4
- } from "@inglorious/engine/ai/movement/kinematic/align.js"
5
- import face from "@inglorious/engine/ai/movement/kinematic/face.js"
6
- import { clampToBounds } from "@inglorious/game/bounds.js"
7
- import { enableCharacter } from "@inglorious/game/decorators/character.js"
8
- import { enableMouse } from "@inglorious/game/decorators/input/mouse.js"
9
- import { merge } from "@inglorious/utils/data-structures/objects.js"
10
- import { pi } from "@inglorious/utils/math/trigonometry.js"
11
-
12
- export default {
13
- types: {
14
- mouse: [enableMouse()],
15
-
16
- character: [
17
- enableCharacter(),
18
- {
19
- "game:update"(instance, event, { dt, instances }) {
20
- const target = instances.mouse
21
- const { fields } = instances.parameters.groups.face
22
-
23
- merge(
24
- instance,
25
- face(instance, target, {
26
- dt,
27
- targetRadius: fields.targetRadius.value,
28
- timeToTarget: fields.timeToTarget.value,
29
- }),
30
- )
31
-
32
- clampToBounds(instance, instances.game.bounds)
33
- },
34
- },
35
- ],
36
-
37
- form: {
38
- "field:change"(instance, event) {
39
- const { id, value } = event.payload
40
- instance.groups.face.fields[id].value = value
41
- },
42
- },
43
- },
44
-
45
- instances: {
46
- mouse: {
47
- type: "mouse",
48
- position: [400, 0, 300],
49
- },
50
-
51
- character: {
52
- type: "character",
53
- maxAngularSpeed: pi() / 4,
54
- maxAngularAcceleration: 1000,
55
- position: [400, 0, 300],
56
- },
57
-
58
- parameters: {
59
- type: "form",
60
- position: [800 - 328, 0, 600],
61
- groups: {
62
- face: {
63
- title: "Face",
64
- fields: {
65
- targetRadius: {
66
- label: "Target Radius",
67
- inputType: "number",
68
- step: 0.1,
69
- defaultValue: DEFAULT_TARGET_RADIUS,
70
- },
71
- timeToTarget: {
72
- label: "Time To Target",
73
- inputType: "number",
74
- step: 0.1,
75
- defaultValue: DEFAULT_TIME_TO_TARGET,
76
- },
77
- },
78
- },
79
- },
80
- },
81
- },
82
- }
@@ -1,36 +0,0 @@
1
- import flee from "@inglorious/engine/ai/movement/kinematic/flee.js"
2
- import { clampToBounds } from "@inglorious/game/bounds.js"
3
- import { enableCharacter } from "@inglorious/game/decorators/character.js"
4
- import { enableMouse } from "@inglorious/game/decorators/input/mouse.js"
5
- import { merge } from "@inglorious/utils/data-structures/objects.js"
6
-
7
- export default {
8
- types: {
9
- mouse: [enableMouse()],
10
-
11
- character: [
12
- enableCharacter(),
13
- {
14
- "game:update"(instance, event, { dt, instances }) {
15
- const target = instances.mouse
16
-
17
- merge(instance, flee(instance, target, { dt }))
18
- clampToBounds(instance, instances.game.bounds)
19
- },
20
- },
21
- ],
22
- },
23
-
24
- instances: {
25
- mouse: {
26
- type: "mouse",
27
- position: [400, 0, 300],
28
- },
29
-
30
- character: {
31
- type: "character",
32
- maxSpeed: 250,
33
- position: [400, 0, 300],
34
- },
35
- },
36
- }