@guinetik/gcanvas 1.0.2 → 1.0.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.
Files changed (217) hide show
  1. package/dist/gcanvas.es.js +25656 -0
  2. package/dist/gcanvas.es.min.js +1 -0
  3. package/dist/gcanvas.umd.js +1 -0
  4. package/dist/gcanvas.umd.min.js +1 -0
  5. package/package.json +23 -6
  6. package/src/game/objects/index.js +1 -0
  7. package/src/game/objects/spritesheet.js +260 -0
  8. package/src/game/ui/theme.js +6 -0
  9. package/src/io/keys.js +9 -1
  10. package/src/math/boolean.js +481 -0
  11. package/src/math/index.js +1 -0
  12. package/.github/workflows/release.yaml +0 -70
  13. package/.jshintrc +0 -4
  14. package/.vscode/settings.json +0 -22
  15. package/CLAUDE.md +0 -310
  16. package/blackhole.jpg +0 -0
  17. package/demo.png +0 -0
  18. package/demos/CNAME +0 -1
  19. package/demos/animations.html +0 -31
  20. package/demos/basic.html +0 -38
  21. package/demos/baskara.html +0 -31
  22. package/demos/bezier.html +0 -35
  23. package/demos/beziersignature.html +0 -29
  24. package/demos/blackhole.html +0 -28
  25. package/demos/blob.html +0 -35
  26. package/demos/coordinates.html +0 -698
  27. package/demos/cube3d.html +0 -23
  28. package/demos/demos.css +0 -303
  29. package/demos/dino.html +0 -42
  30. package/demos/easing.html +0 -28
  31. package/demos/events.html +0 -195
  32. package/demos/fluent.html +0 -647
  33. package/demos/fluid-simple.html +0 -22
  34. package/demos/fluid.html +0 -37
  35. package/demos/fractals.html +0 -36
  36. package/demos/gameobjects.html +0 -626
  37. package/demos/genart.html +0 -26
  38. package/demos/gendream.html +0 -26
  39. package/demos/group.html +0 -36
  40. package/demos/home.html +0 -587
  41. package/demos/index.html +0 -376
  42. package/demos/isometric.html +0 -34
  43. package/demos/js/animations.js +0 -452
  44. package/demos/js/basic.js +0 -204
  45. package/demos/js/baskara.js +0 -751
  46. package/demos/js/bezier.js +0 -692
  47. package/demos/js/beziersignature.js +0 -241
  48. package/demos/js/blackhole/accretiondisk.obj.js +0 -379
  49. package/demos/js/blackhole/blackhole.obj.js +0 -318
  50. package/demos/js/blackhole/index.js +0 -409
  51. package/demos/js/blackhole/particle.js +0 -56
  52. package/demos/js/blackhole/starfield.obj.js +0 -218
  53. package/demos/js/blob.js +0 -2276
  54. package/demos/js/coordinates.js +0 -840
  55. package/demos/js/cube3d.js +0 -789
  56. package/demos/js/dino.js +0 -1420
  57. package/demos/js/easing.js +0 -477
  58. package/demos/js/fluent.js +0 -183
  59. package/demos/js/fluid-simple.js +0 -253
  60. package/demos/js/fluid.js +0 -527
  61. package/demos/js/fractals.js +0 -931
  62. package/demos/js/fractalworker.js +0 -93
  63. package/demos/js/gameobjects.js +0 -176
  64. package/demos/js/genart.js +0 -268
  65. package/demos/js/gendream.js +0 -209
  66. package/demos/js/group.js +0 -140
  67. package/demos/js/info-toggle.js +0 -25
  68. package/demos/js/isometric.js +0 -863
  69. package/demos/js/kerr.js +0 -1556
  70. package/demos/js/lavalamp.js +0 -590
  71. package/demos/js/layout.js +0 -354
  72. package/demos/js/mondrian.js +0 -285
  73. package/demos/js/opacity.js +0 -275
  74. package/demos/js/painter.js +0 -484
  75. package/demos/js/particles-showcase.js +0 -514
  76. package/demos/js/particles.js +0 -299
  77. package/demos/js/patterns.js +0 -397
  78. package/demos/js/penrose/artifact.js +0 -69
  79. package/demos/js/penrose/blackhole.js +0 -121
  80. package/demos/js/penrose/constants.js +0 -73
  81. package/demos/js/penrose/game.js +0 -943
  82. package/demos/js/penrose/lore.js +0 -278
  83. package/demos/js/penrose/penrosescene.js +0 -892
  84. package/demos/js/penrose/ship.js +0 -216
  85. package/demos/js/penrose/sounds.js +0 -211
  86. package/demos/js/penrose/voidparticle.js +0 -55
  87. package/demos/js/penrose/voidscene.js +0 -258
  88. package/demos/js/penrose/voidship.js +0 -144
  89. package/demos/js/penrose/wormhole.js +0 -46
  90. package/demos/js/pipeline.js +0 -555
  91. package/demos/js/plane3d.js +0 -256
  92. package/demos/js/platformer.js +0 -1579
  93. package/demos/js/scene.js +0 -304
  94. package/demos/js/scenes.js +0 -320
  95. package/demos/js/schrodinger.js +0 -410
  96. package/demos/js/schwarzschild.js +0 -1023
  97. package/demos/js/shapes.js +0 -628
  98. package/demos/js/space/alien.js +0 -171
  99. package/demos/js/space/boom.js +0 -98
  100. package/demos/js/space/boss.js +0 -353
  101. package/demos/js/space/buff.js +0 -73
  102. package/demos/js/space/bullet.js +0 -102
  103. package/demos/js/space/constants.js +0 -85
  104. package/demos/js/space/game.js +0 -1884
  105. package/demos/js/space/hud.js +0 -112
  106. package/demos/js/space/laserbeam.js +0 -179
  107. package/demos/js/space/lightning.js +0 -277
  108. package/demos/js/space/minion.js +0 -192
  109. package/demos/js/space/missile.js +0 -212
  110. package/demos/js/space/player.js +0 -430
  111. package/demos/js/space/powerup.js +0 -90
  112. package/demos/js/space/starfield.js +0 -58
  113. package/demos/js/space/starpower.js +0 -90
  114. package/demos/js/spacetime.js +0 -559
  115. package/demos/js/sphere3d.js +0 -229
  116. package/demos/js/sprite.js +0 -473
  117. package/demos/js/svgtween.js +0 -204
  118. package/demos/js/tde/accretiondisk.js +0 -471
  119. package/demos/js/tde/blackhole.js +0 -219
  120. package/demos/js/tde/blackholescene.js +0 -209
  121. package/demos/js/tde/config.js +0 -59
  122. package/demos/js/tde/index.js +0 -820
  123. package/demos/js/tde/jets.js +0 -290
  124. package/demos/js/tde/lensedstarfield.js +0 -154
  125. package/demos/js/tde/tdestar.js +0 -297
  126. package/demos/js/tde/tidalstream.js +0 -372
  127. package/demos/js/tde_old/blackhole.obj.js +0 -354
  128. package/demos/js/tde_old/debris.obj.js +0 -791
  129. package/demos/js/tde_old/flare.obj.js +0 -239
  130. package/demos/js/tde_old/index.js +0 -448
  131. package/demos/js/tde_old/star.obj.js +0 -812
  132. package/demos/js/tiles.js +0 -312
  133. package/demos/js/tweendemo.js +0 -79
  134. package/demos/js/visibility.js +0 -102
  135. package/demos/kerr.html +0 -28
  136. package/demos/lavalamp.html +0 -27
  137. package/demos/layouts.html +0 -37
  138. package/demos/logo.svg +0 -4
  139. package/demos/loop.html +0 -84
  140. package/demos/mondrian.html +0 -32
  141. package/demos/og_image.png +0 -0
  142. package/demos/opacity.html +0 -36
  143. package/demos/painter.html +0 -39
  144. package/demos/particles-showcase.html +0 -28
  145. package/demos/particles.html +0 -24
  146. package/demos/patterns.html +0 -33
  147. package/demos/penrose-game.html +0 -31
  148. package/demos/pipeline.html +0 -737
  149. package/demos/plane3d.html +0 -24
  150. package/demos/platformer.html +0 -43
  151. package/demos/scene.html +0 -33
  152. package/demos/scenes.html +0 -96
  153. package/demos/schrodinger.html +0 -27
  154. package/demos/schwarzschild.html +0 -27
  155. package/demos/shapes.html +0 -16
  156. package/demos/space.html +0 -85
  157. package/demos/spacetime.html +0 -27
  158. package/demos/sphere3d.html +0 -24
  159. package/demos/sprite.html +0 -18
  160. package/demos/svgtween.html +0 -29
  161. package/demos/tde.html +0 -28
  162. package/demos/tiles.html +0 -28
  163. package/demos/transforms.html +0 -400
  164. package/demos/tween.html +0 -45
  165. package/demos/visibility.html +0 -33
  166. package/docs/README.md +0 -230
  167. package/docs/api/FluidSystem.md +0 -173
  168. package/docs/concepts/architecture-overview.md +0 -204
  169. package/docs/concepts/coordinate-system.md +0 -384
  170. package/docs/concepts/lifecycle.md +0 -255
  171. package/docs/concepts/rendering-pipeline.md +0 -279
  172. package/docs/concepts/shapes-vs-gameobjects.md +0 -187
  173. package/docs/concepts/tde-zorder.md +0 -106
  174. package/docs/concepts/two-layer-architecture.md +0 -229
  175. package/docs/fluid-dynamics.md +0 -99
  176. package/docs/getting-started/first-game.md +0 -354
  177. package/docs/getting-started/hello-world.md +0 -269
  178. package/docs/getting-started/installation.md +0 -175
  179. package/docs/modules/collision/README.md +0 -453
  180. package/docs/modules/fluent/README.md +0 -1075
  181. package/docs/modules/game/README.md +0 -303
  182. package/docs/modules/isometric-camera.md +0 -210
  183. package/docs/modules/isometric.md +0 -275
  184. package/docs/modules/painter/README.md +0 -328
  185. package/docs/modules/particle/README.md +0 -559
  186. package/docs/modules/shapes/README.md +0 -221
  187. package/docs/modules/shapes/base/euclidian.md +0 -123
  188. package/docs/modules/shapes/base/geometry2d.md +0 -204
  189. package/docs/modules/shapes/base/renderable.md +0 -215
  190. package/docs/modules/shapes/base/shape.md +0 -262
  191. package/docs/modules/shapes/base/transformable.md +0 -243
  192. package/docs/modules/shapes/hierarchy.md +0 -218
  193. package/docs/modules/state/README.md +0 -577
  194. package/docs/modules/util/README.md +0 -99
  195. package/docs/modules/util/camera3d.md +0 -412
  196. package/docs/modules/util/scene3d.md +0 -395
  197. package/index.html +0 -17
  198. package/jsdoc.json +0 -50
  199. package/scripts/build-demo.js +0 -69
  200. package/scripts/bundle4llm.js +0 -276
  201. package/scripts/clearconsole.js +0 -48
  202. package/test/math/orbital.test.js +0 -61
  203. package/test/math/tensor.test.js +0 -114
  204. package/test/particle/emitter.test.js +0 -204
  205. package/test/particle/particle-system.test.js +0 -310
  206. package/test/particle/particle.test.js +0 -116
  207. package/test/particle/updaters.test.js +0 -386
  208. package/test/setup.js +0 -120
  209. package/test/shapes/euclidian.test.js +0 -44
  210. package/test/shapes/geometry.test.js +0 -86
  211. package/test/shapes/group.test.js +0 -86
  212. package/test/shapes/rectangle.test.js +0 -64
  213. package/test/shapes/transform.test.js +0 -379
  214. package/test/util/camera3d.test.js +0 -428
  215. package/test/util/scene3d.test.js +0 -352
  216. package/vite.config.js +0 -50
  217. package/vitest.config.js +0 -13
@@ -1,171 +0,0 @@
1
- import { GameObject, Rectangle, Circle, Group } from "../../../src/index.js";
2
- import { ALIEN_WIDTH, ALIEN_HEIGHT } from "./constants.js";
3
-
4
- export class Alien extends GameObject {
5
- constructor(game, options = {}) {
6
- super(game, {
7
- width: ALIEN_WIDTH,
8
- height: ALIEN_HEIGHT,
9
- ...options,
10
- });
11
-
12
- this.row = options.row || 0;
13
- this.col = options.col || 0;
14
- this.points = options.points || 10;
15
- this.animTime = Math.random() * 2; // Offset animation
16
-
17
- // Create alien shape based on row
18
- this.shape = this.createShape();
19
- }
20
-
21
- createShape() {
22
- const group = new Group({ cacheRendering: true });
23
-
24
- // Different alien designs based on row - classic Space Invaders style
25
- if (this.row === 0) {
26
- // Top row - Squid/UFO type (30 points) - magenta/pink
27
- this.points = 30;
28
-
29
- // Dome head
30
- const head = new Circle(8, { y: -2, color: "#ff0088" });
31
-
32
- // Body
33
- const body = new Rectangle({ width: 20, height: 8, y: 4, color: "#ff0088" });
34
-
35
- // Eyes
36
- const leftEye = new Circle(2, { x: -4, y: -3, color: "#ffffff" });
37
- const rightEye = new Circle(2, { x: 4, y: -3, color: "#ffffff" });
38
- const leftPupil = new Circle(1, { x: -4, y: -3, color: "#000000" });
39
- const rightPupil = new Circle(1, { x: 4, y: -3, color: "#000000" });
40
-
41
- // Tentacles
42
- const tent1 = new Rectangle({ width: 3, height: 6, x: -8, y: 10, color: "#cc0066" });
43
- const tent2 = new Rectangle({ width: 3, height: 8, x: -3, y: 11, color: "#cc0066" });
44
- const tent3 = new Rectangle({ width: 3, height: 8, x: 3, y: 11, color: "#cc0066" });
45
- const tent4 = new Rectangle({ width: 3, height: 6, x: 8, y: 10, color: "#cc0066" });
46
-
47
- group.add(head);
48
- group.add(body);
49
- group.add(leftEye);
50
- group.add(rightEye);
51
- group.add(leftPupil);
52
- group.add(rightPupil);
53
- group.add(tent1);
54
- group.add(tent2);
55
- group.add(tent3);
56
- group.add(tent4);
57
-
58
- } else if (this.row <= 2) {
59
- // Middle rows - Crab type (20 points) - CYAN/ELECTRIC BLUE (spacey)
60
- this.points = 20;
61
-
62
- // Main body
63
- const body = new Rectangle({ width: 22, height: 10, color: "#00ddff" });
64
-
65
- // Head bump
66
- const headBump = new Rectangle({ width: 10, height: 6, y: -6, color: "#00ddff" });
67
-
68
- // Eyes
69
- const leftEye = new Rectangle({ width: 4, height: 4, x: -6, y: -2, color: "#003344" });
70
- const rightEye = new Rectangle({ width: 4, height: 4, x: 6, y: -2, color: "#003344" });
71
-
72
- // Claws - left
73
- const leftArm = new Rectangle({ width: 4, height: 6, x: -14, y: -2, color: "#00aacc" });
74
- const leftClaw = new Rectangle({ width: 6, height: 4, x: -16, y: -6, color: "#00aacc" });
75
-
76
- // Claws - right
77
- const rightArm = new Rectangle({ width: 4, height: 6, x: 14, y: -2, color: "#00aacc" });
78
- const rightClaw = new Rectangle({ width: 6, height: 4, x: 16, y: -6, color: "#00aacc" });
79
-
80
- // Legs
81
- const leg1 = new Rectangle({ width: 3, height: 5, x: -8, y: 8, color: "#0088aa" });
82
- const leg2 = new Rectangle({ width: 3, height: 5, x: 0, y: 8, color: "#0088aa" });
83
- const leg3 = new Rectangle({ width: 3, height: 5, x: 8, y: 8, color: "#0088aa" });
84
-
85
- group.add(body);
86
- group.add(headBump);
87
- group.add(leftEye);
88
- group.add(rightEye);
89
- group.add(leftArm);
90
- group.add(leftClaw);
91
- group.add(rightArm);
92
- group.add(rightClaw);
93
- group.add(leg1);
94
- group.add(leg2);
95
- group.add(leg3);
96
-
97
- } else {
98
- // Bottom rows - Octopus/Basic type (10 points) - green
99
- this.points = 10;
100
-
101
- // Round head
102
- const head = new Circle(10, { y: -2, color: "#44ff44" });
103
-
104
- // Body extension
105
- const body = new Rectangle({ width: 16, height: 8, y: 6, color: "#44ff44" });
106
-
107
- // Eyes
108
- const leftEye = new Rectangle({ width: 4, height: 5, x: -4, y: -4, color: "#003300" });
109
- const rightEye = new Rectangle({ width: 4, height: 5, x: 4, y: -4, color: "#003300" });
110
-
111
- // Antennae
112
- const leftAntenna = new Rectangle({ width: 2, height: 6, x: -6, y: -12, color: "#22cc22" });
113
- const rightAntenna = new Rectangle({ width: 2, height: 6, x: 6, y: -12, color: "#22cc22" });
114
- const leftTip = new Circle(2, { x: -6, y: -16, color: "#88ff88" });
115
- const rightTip = new Circle(2, { x: 6, y: -16, color: "#88ff88" });
116
-
117
- // Tentacle legs
118
- const leg1 = new Rectangle({ width: 3, height: 6, x: -10, y: 12, color: "#22aa22" });
119
- const leg2 = new Rectangle({ width: 3, height: 8, x: -4, y: 13, color: "#22aa22" });
120
- const leg3 = new Rectangle({ width: 3, height: 8, x: 4, y: 13, color: "#22aa22" });
121
- const leg4 = new Rectangle({ width: 3, height: 6, x: 10, y: 12, color: "#22aa22" });
122
-
123
- group.add(head);
124
- group.add(body);
125
- group.add(leftEye);
126
- group.add(rightEye);
127
- group.add(leftAntenna);
128
- group.add(rightAntenna);
129
- group.add(leftTip);
130
- group.add(rightTip);
131
- group.add(leg1);
132
- group.add(leg2);
133
- group.add(leg3);
134
- group.add(leg4);
135
- }
136
-
137
- return group;
138
- }
139
-
140
- update(dt) {
141
- super.update(dt);
142
- this.animTime += dt;
143
- }
144
-
145
- draw() {
146
- if (!this.visible) return;
147
- super.draw();
148
-
149
- // Add subtle animation - render at origin with wobble offset
150
- // Parent transform already positions us correctly
151
- const wobble = Math.sin(this.animTime * 5) * 2;
152
-
153
- this.shape.x = 0;
154
- this.shape.y = wobble;
155
- this.shape.render();
156
- }
157
-
158
- destroy() {
159
- this.active = false;
160
- this.visible = false;
161
- }
162
-
163
- getBounds() {
164
- return {
165
- x: this.x - ALIEN_WIDTH / 2,
166
- y: this.y - ALIEN_HEIGHT / 2,
167
- width: ALIEN_WIDTH,
168
- height: ALIEN_HEIGHT,
169
- };
170
- }
171
- }
@@ -1,98 +0,0 @@
1
- import { GameObject, Rectangle, Circle } from "../../../src/index.js";
2
-
3
- export class Explosion extends GameObject {
4
- constructor(game, options = {}) {
5
- super(game, options);
6
-
7
- this.particles = [];
8
- this.lifetime = 0.4; // Shorter lifetime for better performance
9
- this.age = 0;
10
- this.baseColor = options.color || "#ffff00";
11
-
12
- // Color palette for explosion - varies based on base color
13
- const colors = this.baseColor === "#ffff00"
14
- ? ["#ffffff", "#ffff00", "#ffaa00", "#ff6600"] // Yellow explosion
15
- : ["#ffffff", "#ff8888", "#ff4444", "#ff0000"]; // Red explosion
16
-
17
- // Optimized particle count (8 circles + 3 squares = 11 total)
18
- const particleCount = 8;
19
- for (let i = 0; i < particleCount; i++) {
20
- const angle = (i / particleCount) * Math.PI * 2 + Math.random() * 0.5;
21
- const speed = 80 + Math.random() * 100;
22
- const size = 2 + Math.random() * 4;
23
- const color = colors[Math.floor(Math.random() * colors.length)];
24
-
25
- this.particles.push({
26
- x: 0,
27
- y: 0,
28
- vx: Math.cos(angle) * speed,
29
- vy: Math.sin(angle) * speed,
30
- size: size,
31
- shape: new Circle(size, { color: color }),
32
- rotSpeed: (Math.random() - 0.5) * 10,
33
- });
34
- }
35
-
36
- // Add some square debris
37
- for (let i = 0; i < 3; i++) {
38
- const angle = Math.random() * Math.PI * 2;
39
- const speed = 40 + Math.random() * 60;
40
- const size = 2 + Math.random() * 3;
41
- const color = colors[Math.floor(Math.random() * colors.length)];
42
-
43
- this.particles.push({
44
- x: 0,
45
- y: 0,
46
- vx: Math.cos(angle) * speed,
47
- vy: Math.sin(angle) * speed,
48
- size: size,
49
- shape: new Rectangle({ width: size, height: size, color: color }),
50
- rotSpeed: (Math.random() - 0.5) * 15,
51
- rotation: 0,
52
- });
53
- }
54
- }
55
-
56
- update(dt) {
57
- super.update(dt);
58
- this.age += dt;
59
-
60
- if (this.age >= this.lifetime) {
61
- this.active = false;
62
- this.visible = false;
63
- return;
64
- }
65
-
66
- // Update particles with gravity and fade
67
- const progress = this.age / this.lifetime;
68
- for (const p of this.particles) {
69
- p.x += p.vx * dt;
70
- p.y += p.vy * dt;
71
- p.vy += 100 * dt; // Gravity
72
- p.vx *= 0.99; // Air resistance
73
-
74
- // Fade and shrink
75
- p.shape.opacity = 1 - progress * progress;
76
-
77
- // Rotate debris
78
- if (p.rotation !== undefined) {
79
- p.rotation += p.rotSpeed * dt;
80
- }
81
- }
82
- }
83
-
84
- draw() {
85
- if (!this.visible) return;
86
- super.draw();
87
-
88
- // Render particles relative to origin - parent transform positions us correctly
89
- for (const p of this.particles) {
90
- p.shape.x = p.x;
91
- p.shape.y = p.y;
92
- if (p.rotation !== undefined) {
93
- p.shape.rotation = p.rotation * (180 / Math.PI); // Convert to degrees
94
- }
95
- p.shape.render();
96
- }
97
- }
98
- }
@@ -1,353 +0,0 @@
1
- import { GameObject, Rectangle } from "../../../src/index.js";
2
- import { Alien } from "./alien.js";
3
- import {
4
- ALIEN_WIDTH,
5
- ALIEN_HEIGHT,
6
- BOSS_SCALE,
7
- BOSS_BASE_HEALTH,
8
- BOSS_BASE_POINTS,
9
- BOSS_BASE_MISSILE_INTERVAL,
10
- BOSS_BASE_MINION_INTERVAL,
11
- BOSS_BASE_MAX_MINIONS,
12
- BOSS_BASE_MOVE_SPEED,
13
- GAUNTLET_BOSS_SCALE,
14
- GAUNTLET_BOSS_HEALTH_MULTIPLIER,
15
- GAUNTLET_BOSS_COLORS,
16
- } from "./constants.js";
17
-
18
- /**
19
- * Boss alien - uses composition to scale up a regular alien shape
20
- * Difficulty scales with boss type:
21
- * Type 0 = Squid (pink) - Level 3 boss (easiest, missiles only)
22
- * Type 1 = Octopus (green) - Level 6 boss (medium, missiles + lasers)
23
- * Type 2 = Crab (cyan) - Level 9 boss (hardest, missiles + lasers + lightning)
24
- *
25
- * Gauntlet mode: Larger scale, different colors, more health
26
- */
27
- export class Boss extends GameObject {
28
- constructor(game, options = {}) {
29
- // Gauntlet mode uses larger scale - must determine before super()
30
- const isGauntlet = options.isGauntlet || false;
31
- const scale = isGauntlet ? GAUNTLET_BOSS_SCALE : BOSS_SCALE;
32
-
33
- const width = ALIEN_WIDTH * scale;
34
- const height = ALIEN_HEIGHT * scale;
35
-
36
- super(game, {
37
- width: width,
38
- height: height,
39
- ...options,
40
- });
41
-
42
- this.isGauntlet = isGauntlet;
43
- this.scale = scale;
44
-
45
- // Boss type determines which alien row shape to use AND difficulty scaling
46
- // 0 = octopus (row 3), 1 = squid (row 0), 2 = crab (row 1)
47
- this.bossType = options.bossType || 0;
48
-
49
- // Scale difficulty based on boss type (0, 1, 2)
50
- const difficultyScale = 1 + this.bossType * 0.5; // 1.0, 1.5, 2.0
51
-
52
- // Gauntlet bosses have extra health
53
- const gauntletMultiplier = this.isGauntlet ? GAUNTLET_BOSS_HEALTH_MULTIPLIER : 1;
54
-
55
- // Health scales up: 30, 45, 60 (or 45, 68, 90 in gauntlet)
56
- this.health = Math.floor(BOSS_BASE_HEALTH * difficultyScale * gauntletMultiplier);
57
- this.maxHealth = this.health;
58
-
59
- // Points scale up: 1000, 2000, 3000 (doubled in gauntlet)
60
- this.points = BOSS_BASE_POINTS * (this.bossType + 1) * (this.isGauntlet ? 2 : 1);
61
-
62
- // Animation
63
- this.animTime = 0;
64
- this.hitFlashTime = 0;
65
- this.isFlashing = false;
66
-
67
- // Movement - faster for harder bosses
68
- this.moveDirection = 1;
69
- this.moveSpeed = BOSS_BASE_MOVE_SPEED * (1 + this.bossType * 0.3); // 35, 45.5, 56
70
-
71
- // Attack intervals - shorter for harder bosses
72
- // Non-signature abilities are 20% slower to reduce spam
73
- // Signature: Boss 0 = missiles, Boss 1 = lasers, Boss 2 = lightning
74
- let baseMissileInterval = BOSS_BASE_MISSILE_INTERVAL / difficultyScale;
75
- if (this.bossType >= 1) {
76
- // Missiles are non-signature for bosses 1 & 2, slow down 20%
77
- baseMissileInterval *= 1.2;
78
- }
79
- this.missileInterval = baseMissileInterval;
80
-
81
- this.minionInterval = BOSS_BASE_MINION_INTERVAL / difficultyScale;
82
- this.maxMinions = BOSS_BASE_MAX_MINIONS + this.bossType * 2; // 2, 4, 6
83
-
84
- // Boss type 1+ (Octopus, Crab) use lasers
85
- this.usesLasers = this.bossType >= 1;
86
- if (this.bossType === 1) {
87
- // Boss 1: Lasers are signature - tuned down 10% from 1.8 to 2.0
88
- this.laserInterval = 2.0;
89
- } else if (this.bossType === 2) {
90
- // Boss 2: Lasers are non-signature - 20% slower
91
- this.laserInterval = 2.2;
92
- }
93
-
94
- // Boss type 2 (Crab/final) uses lightning as signature move
95
- this.usesLightning = this.bossType === 2;
96
- this.lightningInterval = 2.5;
97
-
98
- // Attack timers
99
- this.missileTimer = 0;
100
- this.minionTimer = 0;
101
- this.laserTimer = 0;
102
- this.lightningTimer = 0;
103
- this.minionCount = 0; // Track active minions
104
-
105
- // Entry animation
106
- this.entering = true;
107
- this.entryProgress = 0;
108
- this.targetY = options.targetY || 150;
109
- this.startY = -height;
110
-
111
- // Create shape using composition - instantiate an Alien and reuse its shape
112
- this.shape = this.createShape();
113
-
114
- // Health bar
115
- this.healthBarBg = new Rectangle({
116
- width: width,
117
- height: 8,
118
- color: "#333333",
119
- });
120
- this.healthBarFg = new Rectangle({
121
- width: width,
122
- height: 8,
123
- color: "#ff0000",
124
- });
125
- }
126
-
127
- createShape() {
128
- // Map boss type to the appropriate alien row
129
- // Type 0 (Level 3) = Squid (pink) -> row 0
130
- // Type 1 (Level 6) = Octopus (green) -> row 3
131
- // Type 2 (Level 9) = Crab (cyan) -> row 1 (final boss!)
132
- const rowMapping = [0, 3, 1];
133
- const alienRow = rowMapping[this.bossType] ?? 0;
134
-
135
- // Create a temporary alien to get its shape
136
- const tempAlien = new Alien(this.game, { row: alienRow });
137
- const shape = tempAlien.shape;
138
-
139
- // Disable caching since boss scales up (would cause pixelation if cached at small size)
140
- shape.cacheRendering = false;
141
-
142
- // Apply scale transform (using instance scale which differs in gauntlet mode)
143
- shape.transform.scale(this.scale);
144
-
145
- // In gauntlet mode, recolor the shape with custom gauntlet colors
146
- if (this.isGauntlet) {
147
- const colors = GAUNTLET_BOSS_COLORS[this.bossType];
148
- this.recolorShape(shape, colors);
149
- }
150
-
151
- return shape;
152
- }
153
-
154
- /**
155
- * Recursively recolor all shapes in a group with gauntlet colors
156
- */
157
- recolorShape(shape, colors) {
158
- if (shape.children) {
159
- // It's a group - recursively recolor children
160
- for (const child of shape.children) {
161
- this.recolorShape(child, colors);
162
- }
163
- } else if (shape.color) {
164
- // It's a shape with a color - determine which tier based on brightness
165
- const hex = shape.color.toLowerCase();
166
- // Check if it's a dark color (eyes, etc) - keep them dark
167
- if (hex.includes("00") && !hex.includes("ff") && !hex.includes("dd") && !hex.includes("cc") && !hex.includes("aa") && !hex.includes("88")) {
168
- shape.color = colors.dark;
169
- } else if (hex.includes("cc") || hex.includes("aa") || hex.includes("88") || hex.includes("66")) {
170
- // Secondary/darker accent colors
171
- shape.color = colors.secondary;
172
- } else {
173
- // Primary bright colors
174
- shape.color = colors.primary;
175
- }
176
- }
177
- }
178
-
179
- update(dt) {
180
- super.update(dt);
181
- this.animTime += dt;
182
-
183
- // Entry animation - descend from top
184
- if (this.entering) {
185
- this.entryProgress += dt * 0.5; // 2 seconds to enter
186
- if (this.entryProgress >= 1) {
187
- this.entryProgress = 1;
188
- this.entering = false;
189
- }
190
- // Ease out cubic
191
- const eased = 1 - Math.pow(1 - this.entryProgress, 3);
192
- this.y = this.startY + (this.targetY - this.startY) * eased;
193
- return; // Don't attack while entering
194
- }
195
-
196
- // Horizontal movement - drift back and forth
197
- this.x += this.moveSpeed * this.moveDirection * dt;
198
-
199
- // Bounce off screen edges
200
- const halfWidth = this.width / 2;
201
- if (this.x < halfWidth + 20) {
202
- this.x = halfWidth + 20;
203
- this.moveDirection = 1;
204
- } else if (this.x > this.game.width - halfWidth - 20) {
205
- this.x = this.game.width - halfWidth - 20;
206
- this.moveDirection = -1;
207
- }
208
-
209
- // Attack timers
210
- this.missileTimer += dt;
211
- this.minionTimer += dt;
212
- if (this.usesLasers) {
213
- this.laserTimer += dt;
214
- }
215
- if (this.usesLightning) {
216
- this.lightningTimer += dt;
217
- }
218
-
219
- // Fire missiles at player
220
- if (this.missileTimer >= this.missileInterval) {
221
- this.missileTimer = 0;
222
- this.fireMissile();
223
- }
224
-
225
- // Fire lasers (boss type 1 special attack)
226
- if (this.usesLasers && this.laserTimer >= this.laserInterval) {
227
- this.laserTimer = 0;
228
- this.fireLaser();
229
- }
230
-
231
- // Fire lightning (boss type 2 special attack)
232
- if (this.usesLightning && this.lightningTimer >= this.lightningInterval) {
233
- this.lightningTimer = 0;
234
- this.fireLightning();
235
- }
236
-
237
- // Spawn minions
238
- if (this.minionTimer >= this.minionInterval && this.minionCount < this.maxMinions) {
239
- this.minionTimer = 0;
240
- this.spawnMinion();
241
- }
242
-
243
- // Hit flash effect
244
- if (this.isFlashing) {
245
- this.hitFlashTime -= dt;
246
- if (this.hitFlashTime <= 0) {
247
- this.isFlashing = false;
248
- }
249
- }
250
- }
251
-
252
- fireMissile() {
253
- // Fire a missile from boss position toward player
254
- if (this.game.spawnBossMissile) {
255
- this.game.spawnBossMissile(this.x, this.y + this.height / 2);
256
- }
257
- }
258
-
259
- fireLaser() {
260
- // Fire a laser beam directly at player's current position - forces them to move
261
- if (this.game.spawnLaserBeam) {
262
- this.game.spawnLaserBeam(this.game.player.x);
263
- }
264
- }
265
-
266
- fireLightning() {
267
- // Fire lightning - the ultimate "pay attention" move
268
- if (this.game.spawnLightning) {
269
- this.game.spawnLightning();
270
- }
271
- }
272
-
273
- spawnMinion() {
274
- // Spawn a minion that will float to a position
275
- if (this.game.spawnBossMinion) {
276
- const targetX = 100 + Math.random() * (this.game.width - 200);
277
- const targetY = 200 + Math.random() * 150;
278
-
279
- this.game.spawnBossMinion(this.x, this.y, targetX, targetY, this.bossType);
280
- this.minionCount++;
281
- }
282
- }
283
-
284
- onMinionDestroyed() {
285
- this.minionCount = Math.max(0, this.minionCount - 1);
286
- }
287
-
288
- takeDamage() {
289
- this.health--;
290
- this.isFlashing = true;
291
- this.hitFlashTime = 0.1;
292
-
293
- if (this.health <= 0) {
294
- this.destroy();
295
- return true; // Boss defeated
296
- }
297
- return false;
298
- }
299
-
300
- draw() {
301
- if (!this.visible) return;
302
- super.draw();
303
-
304
- // Wobble animation
305
- const wobble = Math.sin(this.animTime * 3) * 3;
306
-
307
- // Flash white when hit
308
- if (this.isFlashing) {
309
- this.shape.opacity = 0.5;
310
- } else {
311
- this.shape.opacity = 1;
312
- }
313
-
314
- // Render boss shape
315
- this.shape.x = 0;
316
- this.shape.y = wobble;
317
- this.shape.render();
318
-
319
- // Render health bar above boss (further up to avoid overlap with shape)
320
- const healthPercent = this.health / this.maxHealth;
321
- this.healthBarBg.x = 0;
322
- this.healthBarBg.y = -this.height / 2 - 40;
323
- this.healthBarBg.render();
324
-
325
- this.healthBarFg.width = this.width * healthPercent;
326
- this.healthBarFg.x = -(this.width * (1 - healthPercent)) / 2;
327
- this.healthBarFg.y = -this.height / 2 - 40;
328
-
329
- // Color based on health
330
- if (healthPercent > 0.5) {
331
- this.healthBarFg.color = "#00ff00";
332
- } else if (healthPercent > 0.25) {
333
- this.healthBarFg.color = "#ffff00";
334
- } else {
335
- this.healthBarFg.color = "#ff0000";
336
- }
337
- this.healthBarFg.render();
338
- }
339
-
340
- destroy() {
341
- this.active = false;
342
- this.visible = false;
343
- }
344
-
345
- getBounds() {
346
- return {
347
- x: this.x - this.width / 2,
348
- y: this.y - this.height / 2,
349
- width: this.width,
350
- height: this.height,
351
- };
352
- }
353
- }
@@ -1,73 +0,0 @@
1
- import { GameObject, Circle } from "../../../src/index.js";
2
-
3
- export class AbsorbEffect extends GameObject {
4
- constructor(game, options = {}) {
5
- super(game, options);
6
-
7
- this.particles = [];
8
- this.lifetime = 0.4; // Shorter lifetime for better performance
9
- this.age = 0;
10
- this.targetX = options.targetX || this.x;
11
- this.targetY = options.targetY || this.y;
12
- this.color = options.color || "#98fb98";
13
-
14
- // Create particles that will fly toward target (optimized count)
15
- const particleCount = 8;
16
- for (let i = 0; i < particleCount; i++) {
17
- const angle = (i / particleCount) * Math.PI * 2;
18
- const distance = 25 + Math.random() * 15;
19
- const size = 3 + Math.random() * 3;
20
-
21
- this.particles.push({
22
- x: Math.cos(angle) * distance,
23
- y: Math.sin(angle) * distance,
24
- size: size,
25
- shape: new Circle(size, {
26
- color: this.color,
27
- }),
28
- });
29
- }
30
- }
31
-
32
- update(dt) {
33
- super.update(dt);
34
- this.age += dt;
35
-
36
- if (this.age >= this.lifetime) {
37
- this.active = false;
38
- this.visible = false;
39
- return;
40
- }
41
-
42
- // Update target to follow player
43
- if (this.game.player) {
44
- this.targetX = this.game.player.x;
45
- this.targetY = this.game.player.y;
46
- }
47
-
48
- // Move particles toward target (relative to effect origin)
49
- const progress = this.age / this.lifetime;
50
- const targetRelX = this.targetX - this.x;
51
- const targetRelY = this.targetY - this.y;
52
-
53
- for (const p of this.particles) {
54
- // Lerp toward target
55
- p.x += (targetRelX - p.x) * dt * 5;
56
- p.y += (targetRelY - p.y) * dt * 5;
57
-
58
- // Shrink and fade
59
- p.shape.opacity = 1 - progress;
60
- }
61
- }
62
-
63
- draw() {
64
- if (!this.visible) return;
65
- super.draw();
66
-
67
- for (const p of this.particles) {
68
- p.shape.x = p.x;
69
- p.shape.y = p.y;
70
- p.shape.render();
71
- }
72
- }
73
- }