@makefully/platypus 4.1.4 → 4.1.6

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 (134) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +4 -2
  3. package/lib/platypus.js +1 -1
  4. package/package.json +7 -2
  5. package/src/AABB.js +685 -0
  6. package/src/ActionState.js +121 -0
  7. package/src/AssetManager.js +206 -0
  8. package/src/CollisionData.js +96 -0
  9. package/src/CollisionDataContainer.js +127 -0
  10. package/src/CollisionShape.js +315 -0
  11. package/src/Component.js +231 -0
  12. package/src/Data.js +64 -0
  13. package/src/DataMap.js +204 -0
  14. package/src/Entity.js +404 -0
  15. package/src/EntityLinker.js +113 -0
  16. package/src/EventHandler.js +115 -0
  17. package/src/EventHandlerList.js +251 -0
  18. package/src/Game.js +840 -0
  19. package/src/Gamepad.js +175 -0
  20. package/src/ID3CaptionPlayer.js +61 -0
  21. package/src/Messenger.js +365 -0
  22. package/src/PIXIAnimation.js +622 -0
  23. package/src/RandomSet.js +140 -0
  24. package/src/SFXPlayer.js +120 -0
  25. package/src/StateMap.js +252 -0
  26. package/src/Storage.js +152 -0
  27. package/src/TickerClient.js +48 -0
  28. package/src/TickerServer.js +23 -0
  29. package/src/TimeEvent.js +50 -0
  30. package/src/TimeEventList.js +100 -0
  31. package/src/VOPlayer.js +684 -0
  32. package/src/Vector.js +702 -0
  33. package/src/components/AIChaser.js +161 -0
  34. package/src/components/AIPacer.js +107 -0
  35. package/src/components/AudioMusic.js +151 -0
  36. package/src/components/AudioSFX.js +673 -0
  37. package/src/components/AudioVO.js +301 -0
  38. package/src/components/CollisionBasic.js +826 -0
  39. package/src/components/CollisionFilter.js +74 -0
  40. package/src/components/CollisionGroup.js +448 -0
  41. package/src/components/CollisionTiles.js +608 -0
  42. package/src/components/ComponentSwitcher.js +173 -0
  43. package/src/components/ControllerInput.js +65 -0
  44. package/src/components/Counter.js +165 -0
  45. package/src/components/EntityCamera.js +215 -0
  46. package/src/components/EntityContainer.js +549 -0
  47. package/src/components/EntityController.js +541 -0
  48. package/src/components/HandlerCamera.js +1052 -0
  49. package/src/components/HandlerCollision.js +1318 -0
  50. package/src/components/HandlerController.js +291 -0
  51. package/src/components/HandlerLogic.js +394 -0
  52. package/src/components/HandlerRender.js +217 -0
  53. package/src/components/Interactive.js +502 -0
  54. package/src/components/LevelBuilder.js +524 -0
  55. package/src/components/LogicAngularMovement.js +154 -0
  56. package/src/components/LogicAttachment.js +265 -0
  57. package/src/components/LogicButton.js +466 -0
  58. package/src/components/LogicCarrier.js +39 -0
  59. package/src/components/LogicDestroyMe.js +58 -0
  60. package/src/components/LogicDirectionalMovement.js +325 -0
  61. package/src/components/LogicDragDrop.js +371 -0
  62. package/src/components/LogicImpactLaunch.js +144 -0
  63. package/src/components/LogicPacingPlatform.js +64 -0
  64. package/src/components/LogicPortable.js +112 -0
  65. package/src/components/LogicPortal.js +115 -0
  66. package/src/components/LogicPushable.js +98 -0
  67. package/src/components/LogicRebounder.js +136 -0
  68. package/src/components/LogicRegionSpawner.js +139 -0
  69. package/src/components/LogicRotationalMovement.js +205 -0
  70. package/src/components/LogicSpawner.js +159 -0
  71. package/src/components/LogicStateMachine.js +382 -0
  72. package/src/components/LogicSwitch.js +77 -0
  73. package/src/components/LogicTeleportee.js +68 -0
  74. package/src/components/LogicTeleporter.js +93 -0
  75. package/src/components/LogicTimer.js +178 -0
  76. package/src/components/LogicWindUpRacer.js +179 -0
  77. package/src/components/Motion.js +371 -0
  78. package/src/components/Mover.js +566 -0
  79. package/src/components/Node.js +289 -0
  80. package/src/components/NodeMap.js +295 -0
  81. package/src/components/NodeResident.js +636 -0
  82. package/src/components/Orientation.js +697 -0
  83. package/src/components/RandomEvents.js +73 -0
  84. package/src/components/RelativePosition.js +204 -0
  85. package/src/components/RelayFamily.js +106 -0
  86. package/src/components/RelayGame.js +53 -0
  87. package/src/components/RelayLinker.js +94 -0
  88. package/src/components/RelayParent.js +57 -0
  89. package/src/components/RelaySelf.js +55 -0
  90. package/src/components/Render.js +178 -0
  91. package/src/components/RenderAnimator.js +275 -0
  92. package/src/components/RenderContainer.js +646 -0
  93. package/src/components/RenderDebug.js +319 -0
  94. package/src/components/RenderDestroyMe.js +59 -0
  95. package/src/components/RenderLottie.js +149 -0
  96. package/src/components/RenderProgress.js +120 -0
  97. package/src/components/RenderSpine.js +833 -0
  98. package/src/components/RenderSprite.js +527 -0
  99. package/src/components/RenderText.js +147 -0
  100. package/src/components/RenderTiles.js +1391 -0
  101. package/src/components/SceneChanger.js +128 -0
  102. package/src/components/TiledLoader.js +1451 -0
  103. package/src/components/Timeline.js +314 -0
  104. package/src/components/Tutorial.js +267 -0
  105. package/src/components/Tween.js +296 -0
  106. package/src/components/VoiceOver.js +373 -0
  107. package/src/components/XHR.js +129 -0
  108. package/src/components/index.js +79 -0
  109. package/src/factory.js +305 -0
  110. package/src/index.js +159 -0
  111. package/src/mixins/PIXI.Graphics.js +41 -0
  112. package/src/platypus.css +68 -0
  113. package/src/sayHello.js +50 -0
  114. package/src/shapes/Capsule.js +74 -0
  115. package/src/shapes/Circle.js +43 -0
  116. package/src/shapes/Ellipse.js +117 -0
  117. package/src/shapes/Point.js +191 -0
  118. package/src/shapes/Polygon.js +112 -0
  119. package/src/shapes/Polyline.js +97 -0
  120. package/src/shapes/Rectangle.js +78 -0
  121. package/src/shapes/RoundedRectangle.js +33 -0
  122. package/src/shapes/Segment.js +346 -0
  123. package/src/shapes/adjustedXY.js +19 -0
  124. package/src/shapes/castFromBox2D.js +92 -0
  125. package/src/shapes/castFromObject.js +53 -0
  126. package/src/shapes/castFromPixiGraphics.js +6 -0
  127. package/src/shapes/castFromPixiShape.js +89 -0
  128. package/src/shapes/castToBox2D.js +190 -0
  129. package/src/shapes/castToPixiGraphics.js +100 -0
  130. package/src/shapes/castToPixiShape.js +61 -0
  131. package/src/shapes/checkPointsMap.js +313 -0
  132. package/src/shapes/index.js +35 -0
  133. package/src/utils/array.js +73 -0
  134. package/src/utils/string.js +39 -0
@@ -0,0 +1,178 @@
1
+ import createComponentClass from '../factory.js';
2
+
3
+ export default (function () {
4
+ return createComponentClass(/** @lends platypus.components.LogicTimer.prototype */{
5
+ id: 'LogicTimer',
6
+
7
+ properties: {
8
+ /**
9
+ * The starting time for the timer.
10
+ *
11
+ * @property time
12
+ * @type Number
13
+ * @default 0
14
+ */
15
+ time: 0,
16
+
17
+ /**
18
+ * The time when the alarm will trigger the alarm message. Defaults to `0``, which never triggers the alarm.
19
+ *
20
+ * @property alarmTime
21
+ * @type Number
22
+ * @default 0
23
+ */
24
+ alarmTime: 0,
25
+
26
+ /**
27
+ * Whether or not the alarm fires at intervals of the alarmTime.
28
+ *
29
+ * @property isInterval
30
+ * @type Boolean
31
+ * @default false
32
+ */
33
+ isInterval: false,
34
+
35
+ /**
36
+ * The message sent when the alarm goes off.
37
+ *
38
+ * @property alarmMessage
39
+ * @type String
40
+ * @default ''
41
+ */
42
+ alarmMessage: '',
43
+
44
+ /**
45
+ * The message sent when the timer updates.
46
+ *
47
+ * @property updateMessage
48
+ * @type String
49
+ * @default ''
50
+ */
51
+ updateMessage: '',
52
+
53
+ /**
54
+ * Whether the alarm starts on.
55
+ *
56
+ * @property isOn
57
+ * @type Boolean
58
+ * @default true
59
+ */
60
+ isOn: true,
61
+
62
+ /**
63
+ * Whether the timer is incrementing or decrementing. If the value is `false` it is decrementing.
64
+ *
65
+ * @property isIncrementing
66
+ * @type Boolean
67
+ * @default true
68
+ */
69
+ isIncrementing: true,
70
+
71
+ /**
72
+ * The max value in MS, positive or negative, that the timer will count to. Once reached, it stops counting. Defaults to one hour.
73
+ *
74
+ * @property maxTime
75
+ * @type Number
76
+ * @default 3600000
77
+ */
78
+ maxTime: 3600000,
79
+
80
+ /**
81
+ * Whether this alarm should reset to full initial time if restarted after being stopped.
82
+ *
83
+ * @property resetOnStop
84
+ * @type Boolean
85
+ * @default false
86
+ */
87
+ resetOnStop: false
88
+ },
89
+
90
+ /**
91
+ * A timer that can used to trigger events. The timer can increment and decrement. It can be an interval timer, going off over and over. Has a max time which it will not exceed by default this is 1 hour.
92
+ *
93
+ * @memberof platypus.components
94
+ * @uses platypus.Component
95
+ * @constructs
96
+ * @listens platypus.Entity#handle-logic
97
+ * @listens platypus.Entity#set-timer
98
+ * @listens platypus.Entity#start-timer
99
+ * @listens platypus.Entity#stop-timer
100
+ */
101
+ initialize: function () {
102
+ this.prevTime = this.time;
103
+ },
104
+
105
+ events: {
106
+ "handle-logic": function (tick) {
107
+ if (this.isOn) {
108
+ this.prevTime = this.time;
109
+ if (this.isIncrementing) {
110
+ this.time += tick.delta;
111
+ } else {
112
+ this.time -= tick.delta;
113
+ }
114
+
115
+ if (Math.abs(this.time) > this.maxTime) {
116
+ //If the timer hits the max time we turn it off so we don't overflow anything.
117
+ if (this.time > 0) {
118
+ this.time = this.maxTime;
119
+ } else if (this.time < 0) {
120
+ this.time = -this.maxTime;
121
+ }
122
+ this.triggerEvent('stop-timer');
123
+ }
124
+
125
+ if (this.alarmTime !== 0) {
126
+ if (this.isInterval) {
127
+ if (this.isIncrementing) {
128
+ if (Math.floor(this.time / this.alarmTime) > Math.floor(this.prevTime / this.alarmTime)) {
129
+ this.owner.trigger(this.alarmMessage);
130
+ }
131
+ } else if (Math.floor(this.time / this.alarmTime) < Math.floor(this.prevTime / this.alarmTime)) {
132
+ this.owner.trigger(this.alarmMessage);
133
+ }
134
+ } else if (this.isIncrementing) {
135
+ if (this.time > this.alarmTime && this.prevTime < this.alarmTime) {
136
+ this.owner.trigger(this.alarmMessage);
137
+ }
138
+ } else if (this.time < this.alarmTime && this.prevTime > this.alarmTime) {
139
+ this.owner.trigger(this.alarmMessage);
140
+ }
141
+ }
142
+ }
143
+ this.owner.trigger(this.updateMessage, {time: this.time});
144
+ },
145
+
146
+ /**
147
+ * Sets time for alarm.
148
+ *
149
+ * @event platypus.Entity#set-timer
150
+ * @param {Number} data.time Time to set for alarm.
151
+ */
152
+ "set-timer": function (data) {
153
+ this.time = data.time;
154
+ },
155
+
156
+ /**
157
+ * Starts the timer's countdown.
158
+ *
159
+ * @event platypus.Entity#start-timer
160
+ */
161
+ "start-timer": function () {
162
+ this.isOn = true;
163
+ },
164
+
165
+ /**
166
+ * Stops the timer's countdown. If `resetOnStop` is `true`, resets timer.
167
+ *
168
+ * @event platypus.Entity#stop-timer
169
+ */
170
+ "stop-timer": function () {
171
+ this.isOn = false;
172
+ if (this.resetOnStop) {
173
+ this.time = 0;
174
+ }
175
+ }
176
+ }
177
+ });
178
+ }());
@@ -0,0 +1,179 @@
1
+ import createComponentClass from '../factory.js';
2
+
3
+ export default (function () {
4
+ return createComponentClass(/** @lends platypus.components.LogicWindUpRacer.prototype */{
5
+
6
+ id: 'LogicWindUpRacer',
7
+
8
+ properties: {
9
+ /**
10
+ * Velocity at which the entity should travel while racing.
11
+ *
12
+ * @property speed
13
+ * @type Number
14
+ * @default 0.3
15
+ */
16
+ speed: 0.3,
17
+
18
+ /**
19
+ * Time in milliseconds that entity will race before coming to a stop.
20
+ *
21
+ * @property raceTime
22
+ * @type Number
23
+ * @default 5000
24
+ */
25
+ raceTime: 5000,
26
+
27
+ /**
28
+ * Time in milliseconds that entity needs to receive wind-up calls before racing can begin.
29
+ *
30
+ * @property windTime
31
+ * @type Number
32
+ * @default 500
33
+ */
34
+ windTime: 500
35
+ },
36
+
37
+ /**
38
+ * Replicates logic for a wind-up toy: listens for a wind-up message over a series of ticks to charge, and then begins racing once the charge is complete.
39
+ *
40
+ * @memberof platypus.components
41
+ * @uses platypus.Component
42
+ * @constructs
43
+ * @listens platypus.Entity#handle-logic
44
+ * @listens platypus.Entity#hit-solid
45
+ * @listens platypus.Entity#stop-racing
46
+ * @listens platypus.Entity#wind-up
47
+ * @fires platypus.Entity#racing
48
+ * @fires platypus.Entity#stopped-racing
49
+ * @fires platypus.Entity#winding
50
+ * @fires platypus.Entity#stopped-winding
51
+ * @fires platypus.Entity#blocked
52
+ */
53
+ initialize: function () {
54
+ const
55
+ {state} = this.owner;
56
+
57
+ this.windProgress = 0;
58
+
59
+ this.winding = false;
60
+ this.racing = false;
61
+ this.blocked = false;
62
+ this.right = false;
63
+ this.left = false;
64
+
65
+ this.state = state;
66
+ state.set('windingUp', false);
67
+ state.set('racing', false);
68
+ state.set('blocked', false);
69
+ },
70
+
71
+ events: {
72
+ "handle-logic": function (resp) {
73
+ const
74
+ {state} = this;
75
+
76
+ if (this.racing) {
77
+
78
+ /**
79
+ * This event is triggered when winding is finished and the entity begins racing.
80
+ *
81
+ * @event platypus.Entity#racing
82
+ */
83
+ if (!this.blocked && this.right && state.get('right')) {
84
+ this.owner.x += this.speed * resp.delta;
85
+ this.owner.triggerEvent('racing');
86
+ } else if (!this.blocked && this.left && state.get('left')) {
87
+ this.owner.x -= this.speed * resp.delta;
88
+ this.owner.triggerEvent('racing');
89
+ } else {
90
+ this.racing = false;
91
+
92
+ /**
93
+ * This event is triggered when the entity stops racing.
94
+ *
95
+ * @event platypus.Entity#stopped-racing
96
+ */
97
+ this.owner.triggerEvent('stopped-racing');
98
+ }
99
+ } else if (this.winding) {
100
+ if ((this.right && state.get('right')) || (this.left && state.get('left'))) {
101
+ this.windProgress += resp.delta;
102
+ }
103
+
104
+ /**
105
+ * This event is triggered as the entity winds up.
106
+ *
107
+ * @event platypus.Entity#winding
108
+ * @param fraction {Number} The amount of progress that has been made from 0 to 1.
109
+ */
110
+ this.owner.triggerEvent('winding', this.windProgress / this.windTime);
111
+ } else if (this.windProgress) {
112
+ if (this.windProgress >= this.windTime) {
113
+ this.racing = true;
114
+ }
115
+ this.windProgress = 0;
116
+
117
+ /**
118
+ * This event is triggered when the entity stops winding.
119
+ *
120
+ * @event platypus.Entity#stopped-winding
121
+ */
122
+ this.owner.triggerEvent('stopped-winding');
123
+ }
124
+
125
+ state.set('windingUp', this.winding);
126
+ state.set('racing', this.racing);
127
+ state.set('blocked', this.blocked);
128
+ this.blocked = false;
129
+ },
130
+
131
+ /**
132
+ * Causes the entity to stop racing.
133
+ *
134
+ * @event platypus.Entity#stop-racing
135
+ */
136
+ "stop-racing": function () {
137
+ this.racing = false;
138
+ this.owner.triggerEvent('stopped-racing');
139
+ },
140
+
141
+ /**
142
+ * Causes the entity to wind up for a race.
143
+ *
144
+ * @event platypus.Entity#wind-up
145
+ * @param message.pressed {Boolean} If `message` is included, the component checks the value of `pressed`: `false` causes winding to stop.
146
+ */
147
+ "wind-up": function (value) {
148
+ this.winding = !value || (value.pressed !== false);
149
+ this.right = this.state.get('right');
150
+ this.left = this.state.get('left');
151
+ },
152
+
153
+ "hit-solid": function (collision) {
154
+ if (collision.x) {
155
+ if (this.racing && ((this.right && (collision.x > 0)) || (this.left && (collision.x < 0)))) {
156
+ this.blocked = true;
157
+
158
+ /**
159
+ * This message is triggered if the entity collides while racing.
160
+ *
161
+ * @event platypus.Entity#blocked
162
+ * @param collision {platypus.CollisionData} Collision information from the entity or tile that blocked movement.
163
+ */
164
+ this.owner.triggerEvent('blocked', collision);
165
+ }
166
+ }
167
+ }
168
+ },
169
+
170
+ methods: {
171
+ destroy: function () {
172
+ this.state.set('windingUp', false);
173
+ this.state.set('racing', false);
174
+ this.state.set('blocked', false);
175
+ this.state = null;
176
+ }
177
+ }
178
+ });
179
+ }());