frigame3 0.0.0-stage → 3.0.0

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 (111) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/LICENSE +373 -0
  3. package/README.md +80 -2
  4. package/biome.json +93 -0
  5. package/demo/package-lock.json +515 -0
  6. package/demo/package.json +19 -0
  7. package/demo/snake/index.html +16 -0
  8. package/demo/snake/index.ts +110 -0
  9. package/demo/tetris/index.html +16 -0
  10. package/demo/tetris/index.ts +536 -0
  11. package/demo/tsconfig.json +53 -0
  12. package/frigame.css +12 -0
  13. package/package.json +50 -4
  14. package/src/Animation.ts +266 -0
  15. package/src/BaseSprite.ts +682 -0
  16. package/src/Gradient.ts +120 -0
  17. package/src/Playground.ts +247 -0
  18. package/src/Rect.ts +237 -0
  19. package/src/Rectangle.ts +108 -0
  20. package/src/Renderer.ts +28 -0
  21. package/src/ResourceManager.ts +145 -0
  22. package/src/Sprite.ts +484 -0
  23. package/src/SpriteGroup.ts +258 -0
  24. package/src/canvasRenderer/renderGroup.ts +194 -0
  25. package/src/canvasRenderer/renderPlayground.ts +103 -0
  26. package/src/canvasRenderer/renderRectangle.ts +421 -0
  27. package/src/canvasRenderer/renderSprite.ts +148 -0
  28. package/src/canvasRenderer.ts +38 -0
  29. package/src/dummyRenderer.ts +62 -0
  30. package/src/plugins/GamepadTracker.ts +97 -0
  31. package/src/plugins/Tilemap.ts +123 -0
  32. package/src/plugins/Vec2.ts +420 -0
  33. package/src/plugins/fx/Shaker.ts +293 -0
  34. package/src/plugins/fx/Tweener.ts +252 -0
  35. package/src/plugins/fx/easing.ts +276 -0
  36. package/src/plugins/isometric/ISOMixin.ts +444 -0
  37. package/src/plugins/isometric/ISORectangle.ts +183 -0
  38. package/src/plugins/isometric/ISOSprite.ts +228 -0
  39. package/src/plugins/isometric/ISOSpriteGroup.ts +155 -0
  40. package/src/plugins/isometric/ISOTilemap.ts +122 -0
  41. package/src/plugins/isometric/utils.ts +19 -0
  42. package/src/plugins/keyTracker.ts +31 -0
  43. package/src/plugins/mixer.ts +523 -0
  44. package/src/plugins/sorted/SortedAnimation.ts +53 -0
  45. package/src/plugins/sorted/SortedGroup.ts +94 -0
  46. package/src/plugins/sorted/SortedMixin.ts +203 -0
  47. package/src/plugins/sorted/SortedRectangle.ts +35 -0
  48. package/src/plugins/sorted/SortedSprite.ts +56 -0
  49. package/src/utils.ts +53 -0
  50. package/test/animation/index.html +20 -0
  51. package/test/animation/index.ts +253 -0
  52. package/test/animation/mh.png +0 -0
  53. package/test/animation/moh.png +0 -0
  54. package/test/animation/mov.png +0 -0
  55. package/test/animation/mv.png +0 -0
  56. package/test/animation/rebound.png +0 -0
  57. package/test/animation/reboundm.png +0 -0
  58. package/test/animation/sh.png +0 -0
  59. package/test/animation/soh.png +0 -0
  60. package/test/animation/sov.png +0 -0
  61. package/test/animation/sv.png +0 -0
  62. package/test/isometric1/beach.png +0 -0
  63. package/test/isometric1/foglie.png +0 -0
  64. package/test/isometric1/grass.png +0 -0
  65. package/test/isometric1/index.html +17 -0
  66. package/test/isometric1/index.ts +68 -0
  67. package/test/isometric1/tronco.png +0 -0
  68. package/test/isometric1/untitled.tmx +25 -0
  69. package/test/isometric1/water.png +0 -0
  70. package/test/isometric2/banner.png +0 -0
  71. package/test/isometric2/books.png +0 -0
  72. package/test/isometric2/candlestick.png +0 -0
  73. package/test/isometric2/ice.png +0 -0
  74. package/test/isometric2/index.html +16 -0
  75. package/test/isometric2/index.ts +129 -0
  76. package/test/isometric2/knight_se.png +0 -0
  77. package/test/isometric2/tile.png +0 -0
  78. package/test/isometric2/untitled.tmx +36 -0
  79. package/test/isometric2/wall.png +0 -0
  80. package/test/layers/boy.png +0 -0
  81. package/test/layers/catgirl.png +0 -0
  82. package/test/layers/fri1.svg +8 -0
  83. package/test/layers/grassblock.png +0 -0
  84. package/test/layers/horngirl.png +0 -0
  85. package/test/layers/index.html +17 -0
  86. package/test/layers/index.ts +191 -0
  87. package/test/layers/pinkgirl.png +0 -0
  88. package/test/layers/render_ruler.py +57 -0
  89. package/test/layers/ruler.png +0 -0
  90. package/test/layers/sh.png +0 -0
  91. package/test/mixer/dieci.opus +0 -0
  92. package/test/mixer/dieci.wav +0 -0
  93. package/test/mixer/index.html +33 -0
  94. package/test/mixer/index.ts +206 -0
  95. package/test/mixer/news_intro.mp3 +0 -0
  96. package/test/mixer/news_intro.ogg +0 -0
  97. package/test/mixer/prova.mp3 +0 -0
  98. package/test/mixer/prova.ogg +0 -0
  99. package/test/package-lock.json +515 -0
  100. package/test/package.json +19 -0
  101. package/test/sorted/Brown Block.png +0 -0
  102. package/test/sorted/index.html +16 -0
  103. package/test/sorted/index.ts +38 -0
  104. package/test/transformation1/index.html +17 -0
  105. package/test/transformation1/index.ts +51 -0
  106. package/test/transformation1/sh.png +0 -0
  107. package/test/transformation2/index.html +20 -0
  108. package/test/transformation2/index.ts +71 -0
  109. package/test/transformation2/sh.png +0 -0
  110. package/test/tsconfig.json +53 -0
  111. package/tsconfig.json +51 -0
@@ -0,0 +1,71 @@
1
+ import { Animation } from "frigame3/dist/Animation.js";
2
+ import { canvasRenderer } from "frigame3/dist/canvasRenderer.js";
3
+ import { Playground } from "frigame3/dist/Playground.js";
4
+ import { ResourceManager } from "frigame3/dist/ResourceManager.js";
5
+ import { Sprite } from "frigame3/dist/Sprite.js";
6
+
7
+ void (async (): Promise<void> => {
8
+ const rm = new ResourceManager();
9
+
10
+ const animation = rm.addResource(
11
+ new Animation({
12
+ imageURL: "sh.png",
13
+ type: "horizontal",
14
+ numberOfFrame: 4,
15
+ rate: 300,
16
+ }),
17
+ );
18
+
19
+ await rm.preload();
20
+
21
+ const playground = new Playground(canvasRenderer);
22
+ const sg = playground.scenegraph;
23
+
24
+ let angle = 45;
25
+ let angle_rad = (angle * Math.PI) / 180;
26
+
27
+ const aRotateScale = sg.addChild(
28
+ new Sprite({
29
+ animation: animation,
30
+ left: 16,
31
+ top: 16,
32
+ }),
33
+ );
34
+ const scaleARotate = sg.addChild(
35
+ new Sprite({
36
+ animation: animation,
37
+ left: 80,
38
+ top: 16,
39
+ }),
40
+ );
41
+ const rotateAScale = sg.addChild(
42
+ new Sprite({
43
+ animation: animation,
44
+ left: 180,
45
+ top: 16,
46
+ }),
47
+ );
48
+ const aScaleRotate = sg.addChild(
49
+ new Sprite({
50
+ animation: animation,
51
+ left: 240,
52
+ top: 16,
53
+ }),
54
+ );
55
+
56
+ playground.registerCallback(() => {
57
+ aRotateScale.angle = angle_rad;
58
+ aRotateScale.scale = 2;
59
+ scaleARotate.scale = 2;
60
+ scaleARotate.angle = -angle_rad;
61
+ rotateAScale.angle = Math.PI / 4;
62
+ rotateAScale.scale = Math.cos(angle_rad) * 2;
63
+ aScaleRotate.scale = -Math.cos(angle_rad) * 2;
64
+ aScaleRotate.angle = Math.PI / 4;
65
+ angle -= 1;
66
+ if (angle < -180) {
67
+ angle = 180;
68
+ }
69
+ angle_rad = (angle * Math.PI) / 180;
70
+ }, 30);
71
+ })();
Binary file
@@ -0,0 +1,53 @@
1
+ {
2
+ // Visit https://aka.ms/tsconfig to read more about this file
3
+ "compilerOptions": {
4
+ // File Layout
5
+ // "rootDir": "./src",
6
+ // "outDir": "./dist",
7
+
8
+ // Environment Settings
9
+ // See also https://aka.ms/tsconfig/module
10
+ "module": "nodenext",
11
+ "target": "esnext",
12
+ "types": [],
13
+ // For nodejs:
14
+ // "lib": ["esnext"],
15
+ // "types": ["node"],
16
+ // and npm install -D @types/node
17
+
18
+ // Other Outputs
19
+ // "sourceMap": true,
20
+ // "declaration": true,
21
+ // "declarationMap": true,
22
+ "noEmit": true,
23
+
24
+ // Stricter Typechecking Options
25
+ "noUncheckedIndexedAccess": true,
26
+ "exactOptionalPropertyTypes": true,
27
+
28
+ // Style Options
29
+ "noImplicitReturns": true,
30
+ "noImplicitOverride": true,
31
+ "noUnusedLocals": true,
32
+ "noUnusedParameters": true,
33
+ "noFallthroughCasesInSwitch": true,
34
+ "noPropertyAccessFromIndexSignature": true,
35
+
36
+ // Recommended Options
37
+ "strict": true,
38
+ "jsx": "react-jsx",
39
+ "verbatimModuleSyntax": true,
40
+ "isolatedModules": true,
41
+ "noUncheckedSideEffectImports": true,
42
+ "moduleDetection": "force",
43
+ "skipLibCheck": true,
44
+
45
+ // Customizations
46
+ "allowUnreachableCode": false,
47
+ "allowUnusedLabels": false,
48
+ "erasableSyntaxOnly": true,
49
+ // "isolatedDeclarations": true,
50
+ },
51
+ "include": ["./**/*"],
52
+ "exclude": ["node_modules"]
53
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,51 @@
1
+ {
2
+ // Visit https://aka.ms/tsconfig to read more about this file
3
+ "compilerOptions": {
4
+ // File Layout
5
+ "rootDir": "./src",
6
+ "outDir": "./dist",
7
+
8
+ // Environment Settings
9
+ // See also https://aka.ms/tsconfig/module
10
+ "module": "nodenext",
11
+ "target": "esnext",
12
+ "types": [],
13
+ // For nodejs:
14
+ // "lib": ["esnext"],
15
+ // "types": ["node"],
16
+ // and npm install -D @types/node
17
+
18
+ // Other Outputs
19
+ // "sourceMap": true,
20
+ "declaration": true,
21
+ // "declarationMap": true,
22
+
23
+ // Stricter Typechecking Options
24
+ "noUncheckedIndexedAccess": true,
25
+ "exactOptionalPropertyTypes": true,
26
+
27
+ // Style Options
28
+ "noImplicitReturns": true,
29
+ "noImplicitOverride": true,
30
+ "noUnusedLocals": true,
31
+ "noUnusedParameters": true,
32
+ "noFallthroughCasesInSwitch": true,
33
+ "noPropertyAccessFromIndexSignature": true,
34
+
35
+ // Recommended Options
36
+ "strict": true,
37
+ "jsx": "react-jsx",
38
+ "verbatimModuleSyntax": true,
39
+ "isolatedModules": true,
40
+ "noUncheckedSideEffectImports": true,
41
+ "moduleDetection": "force",
42
+ "skipLibCheck": true,
43
+
44
+ // Customizations
45
+ "allowUnreachableCode": false,
46
+ "allowUnusedLabels": false,
47
+ "erasableSyntaxOnly": true
48
+ // "isolatedDeclarations": true,
49
+ },
50
+ "include": ["src/**/*"]
51
+ }