minimojs 1.0.0-alpha.26 → 1.0.0-alpha.28
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/dist/internal/InputSystem.js +5 -12
- package/dist/minimo-cards.d.ts +4 -0
- package/dist/minimo-cards.js +12 -5
- package/dist/minimo.d.ts +7 -0
- package/dist/minimo.js +7 -0
- package/package.json +3 -2
|
@@ -85,6 +85,8 @@ export class InputSystem {
|
|
|
85
85
|
y: p.y,
|
|
86
86
|
pressed: true,
|
|
87
87
|
});
|
|
88
|
+
// A finger that touches while none is followed becomes the pointer,
|
|
89
|
+
// even when other fingers are still down.
|
|
88
90
|
if (this._primaryTouchId === null) {
|
|
89
91
|
this._primaryTouchId = touch.identifier;
|
|
90
92
|
}
|
|
@@ -277,18 +279,9 @@ export class InputSystem {
|
|
|
277
279
|
}
|
|
278
280
|
this._primaryTouchId = null;
|
|
279
281
|
}
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
const [touchId, touch] = firstTouchEntry;
|
|
284
|
-
this._primaryTouchId = touchId;
|
|
285
|
-
this._pointerX = touch.x;
|
|
286
|
-
this._pointerY = touch.y;
|
|
287
|
-
this._pointerDown = true;
|
|
288
|
-
this._pointerPressed = touch.pressed;
|
|
289
|
-
return;
|
|
290
|
-
}
|
|
291
|
-
}
|
|
282
|
+
// No finger is followed. Fingers still down are not adopted: the pointer
|
|
283
|
+
// reports the followed finger's release, and the next finger to touch
|
|
284
|
+
// is followed instead.
|
|
292
285
|
this._primaryTouchId = null;
|
|
293
286
|
const released = this._releasedTouch;
|
|
294
287
|
this._pointerX = released ? released.x : this._mouseX;
|
package/dist/minimo-cards.d.ts
CHANGED
|
@@ -242,6 +242,10 @@ export declare class CardPile {
|
|
|
242
242
|
*
|
|
243
243
|
* Call {@link update} once per frame.
|
|
244
244
|
*
|
|
245
|
+
* Piles and cards live in world space and scroll with the game. The table
|
|
246
|
+
* reads the pointer itself and adds `game.scrollX` and `game.scrollY`, so a
|
|
247
|
+
* scrolled board needs no conversion from the game.
|
|
248
|
+
*
|
|
245
249
|
* @example
|
|
246
250
|
* ```ts
|
|
247
251
|
* const table = new CardTable(game, {
|
package/dist/minimo-cards.js
CHANGED
|
@@ -187,6 +187,10 @@ let nextTableId = 1;
|
|
|
187
187
|
*
|
|
188
188
|
* Call {@link update} once per frame.
|
|
189
189
|
*
|
|
190
|
+
* Piles and cards live in world space and scroll with the game. The table
|
|
191
|
+
* reads the pointer itself and adds `game.scrollX` and `game.scrollY`, so a
|
|
192
|
+
* scrolled board needs no conversion from the game.
|
|
193
|
+
*
|
|
190
194
|
* @example
|
|
191
195
|
* ```ts
|
|
192
196
|
* const table = new CardTable(game, {
|
|
@@ -638,12 +642,15 @@ export class CardTable {
|
|
|
638
642
|
this.cancelDrag();
|
|
639
643
|
return;
|
|
640
644
|
}
|
|
645
|
+
// The pointer is in screen space and the piles and cards are in world space.
|
|
641
646
|
const x = game.pointerX;
|
|
642
647
|
const y = game.pointerY;
|
|
648
|
+
const worldX = x + game.scrollX;
|
|
649
|
+
const worldY = y + game.scrollY;
|
|
643
650
|
if (game.isPointerPressed()) {
|
|
644
651
|
this.cancelDrag();
|
|
645
|
-
const hit = this.hitTest(
|
|
646
|
-
this._press = hit ? { x, y, card: hit.card, pile: hit.pile, dragTried: false } : null;
|
|
652
|
+
const hit = this.hitTest(worldX, worldY);
|
|
653
|
+
this._press = hit ? { x, y, worldX, worldY, card: hit.card, pile: hit.pile, dragTried: false } : null;
|
|
647
654
|
return;
|
|
648
655
|
}
|
|
649
656
|
const press = this._press;
|
|
@@ -654,7 +661,7 @@ export class CardTable {
|
|
|
654
661
|
this.startDrag(press);
|
|
655
662
|
}
|
|
656
663
|
if (this._drag)
|
|
657
|
-
this.followPointer(
|
|
664
|
+
this.followPointer(worldX, worldY);
|
|
658
665
|
return;
|
|
659
666
|
}
|
|
660
667
|
this._press = null;
|
|
@@ -718,8 +725,8 @@ export class CardTable {
|
|
|
718
725
|
view.moving = false;
|
|
719
726
|
view.waitMs = 0;
|
|
720
727
|
view.dragging = true;
|
|
721
|
-
view.grabX = press.
|
|
722
|
-
view.grabY = press.
|
|
728
|
+
view.grabX = press.worldX - view.sprite.x;
|
|
729
|
+
view.grabY = press.worldY - view.sprite.y;
|
|
723
730
|
view.sprite.layer = this.layer + 1000 + i * 0.01;
|
|
724
731
|
this.applyScale(view);
|
|
725
732
|
});
|
package/dist/minimo.d.ts
CHANGED
|
@@ -1316,6 +1316,11 @@ export declare class Game {
|
|
|
1316
1316
|
* in pixels. Updated every `mousemove` / `touchmove` event.
|
|
1317
1317
|
* `(0, 0)` is the top-left corner of the canvas.
|
|
1318
1318
|
* To convert to world space: `worldX = game.pointerX + game.scrollX`.
|
|
1319
|
+
*
|
|
1320
|
+
* On a touch screen the pointer is one finger: the first to touch while no
|
|
1321
|
+
* finger is followed. Other fingers never move it, and when the followed
|
|
1322
|
+
* finger lifts, the pointer stays where it left the screen even if others
|
|
1323
|
+
* are still down. Use {@link Game.getPointers} to follow several fingers.
|
|
1319
1324
|
*/
|
|
1320
1325
|
get pointerX(): number;
|
|
1321
1326
|
/**
|
|
@@ -1616,6 +1621,8 @@ export declare class Game {
|
|
|
1616
1621
|
* Use this for continuous pointer actions.
|
|
1617
1622
|
*
|
|
1618
1623
|
* **Hold behavior:** returns `true` every frame from press until release.
|
|
1624
|
+
* On a touch screen it follows one finger, as {@link Game.pointerX} does,
|
|
1625
|
+
* so it turns `false` when that finger lifts, even if another is down.
|
|
1619
1626
|
*
|
|
1620
1627
|
* @returns `true` if the pointer is currently pressed.
|
|
1621
1628
|
*
|
package/dist/minimo.js
CHANGED
|
@@ -1429,6 +1429,11 @@ export class Game {
|
|
|
1429
1429
|
* in pixels. Updated every `mousemove` / `touchmove` event.
|
|
1430
1430
|
* `(0, 0)` is the top-left corner of the canvas.
|
|
1431
1431
|
* To convert to world space: `worldX = game.pointerX + game.scrollX`.
|
|
1432
|
+
*
|
|
1433
|
+
* On a touch screen the pointer is one finger: the first to touch while no
|
|
1434
|
+
* finger is followed. Other fingers never move it, and when the followed
|
|
1435
|
+
* finger lifts, the pointer stays where it left the screen even if others
|
|
1436
|
+
* are still down. Use {@link Game.getPointers} to follow several fingers.
|
|
1432
1437
|
*/
|
|
1433
1438
|
get pointerX() {
|
|
1434
1439
|
return this._inputSystem.pointerX;
|
|
@@ -1788,6 +1793,8 @@ export class Game {
|
|
|
1788
1793
|
* Use this for continuous pointer actions.
|
|
1789
1794
|
*
|
|
1790
1795
|
* **Hold behavior:** returns `true` every frame from press until release.
|
|
1796
|
+
* On a touch screen it follows one finger, as {@link Game.pointerX} does,
|
|
1797
|
+
* so it turns `false` when that finger lifts, even if another is down.
|
|
1791
1798
|
*
|
|
1792
1799
|
* @returns `true` if the pointer is currently pressed.
|
|
1793
1800
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "minimojs",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.28",
|
|
4
4
|
"description": "MinimoJS v1 — ultra-minimal, flat, deterministic 2D web game engine. Image-first sprites with emoji as a zero-asset alternative, rAF loop, TypeScript-first, LLM-friendly.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/minimo.js",
|
|
@@ -21,7 +21,8 @@
|
|
|
21
21
|
"clean": "rm -rf dist",
|
|
22
22
|
"rebuild": "npm run clean && npm run build",
|
|
23
23
|
"prepack": "npm run build",
|
|
24
|
-
"pack:check": "npm pack --dry-run"
|
|
24
|
+
"pack:check": "npm pack --dry-run",
|
|
25
|
+
"test": "npm run build && node --test \"test/*.test.mjs\""
|
|
25
26
|
},
|
|
26
27
|
"keywords": [
|
|
27
28
|
"game",
|