littlejsengine 1.18.4 → 1.18.8

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 (176) hide show
  1. package/COPYRIGHT.txt +38 -0
  2. package/FAQ.md +633 -0
  3. package/README.md +19 -1
  4. package/dist/littlejs.d.ts +354 -55
  5. package/dist/littlejs.esm.js +1531 -489
  6. package/dist/littlejs.esm.min.js +1 -1
  7. package/dist/littlejs.js +1499 -476
  8. package/dist/littlejs.min.js +1 -1
  9. package/dist/littlejs.release.js +1493 -470
  10. package/package.json +8 -1
  11. package/plugins/box2d.js +32 -7
  12. package/{src/engineMedals.js → plugins/medalSystem.js} +248 -196
  13. package/plugins/pathFinder.js +758 -0
  14. package/plugins/pluginExport.js +19 -0
  15. package/plugins/{tween.js → tweenSystem.js} +7 -7
  16. package/plugins/uiSystem.js +186 -25
  17. package/src/engine.js +2 -141
  18. package/src/engineAudio.js +3 -3
  19. package/src/engineBuild.mjs +4 -2
  20. package/src/engineDebug.js +7 -7
  21. package/src/engineDraw.js +26 -8
  22. package/src/engineExport.js +13 -13
  23. package/src/engineInput.js +8 -8
  24. package/src/engineLogo.js +146 -0
  25. package/src/engineMath.js +15 -6
  26. package/src/engineObject.js +11 -5
  27. package/src/engineParticles.js +6 -3
  28. package/src/engineRelease.js +1 -1
  29. package/src/engineSettings.js +0 -47
  30. package/src/engineUtilities.js +13 -8
  31. package/src/engineWebGL.js +34 -7
  32. package/src/jsconfig.json +3 -1
  33. package/.github/workflows/test.yml +0 -17
  34. package/AI.md +0 -173
  35. package/CLAUDE.md +0 -1
  36. package/examples/box2d/game.js +0 -192
  37. package/examples/box2d/gameObjects.js +0 -564
  38. package/examples/box2d/index.html +0 -9
  39. package/examples/box2d/scenes.js +0 -194
  40. package/examples/box2d/tiles.png +0 -0
  41. package/examples/breakout/game.js +0 -175
  42. package/examples/breakout/gameObjects.js +0 -147
  43. package/examples/breakout/index.html +0 -8
  44. package/examples/breakout/tiles.png +0 -0
  45. package/examples/breakoutTutorial/README.md +0 -521
  46. package/examples/breakoutTutorial/game.js +0 -191
  47. package/examples/breakoutTutorial/images/1.png +0 -0
  48. package/examples/breakoutTutorial/images/10.png +0 -0
  49. package/examples/breakoutTutorial/images/11.png +0 -0
  50. package/examples/breakoutTutorial/images/2.png +0 -0
  51. package/examples/breakoutTutorial/images/3.png +0 -0
  52. package/examples/breakoutTutorial/images/4.png +0 -0
  53. package/examples/breakoutTutorial/images/5.png +0 -0
  54. package/examples/breakoutTutorial/images/6.png +0 -0
  55. package/examples/breakoutTutorial/images/7.png +0 -0
  56. package/examples/breakoutTutorial/images/8.png +0 -0
  57. package/examples/breakoutTutorial/images/9.png +0 -0
  58. package/examples/breakoutTutorial/index.html +0 -8
  59. package/examples/electron/build.mjs +0 -127
  60. package/examples/electron/electron.js +0 -35
  61. package/examples/electron/game.js +0 -54
  62. package/examples/electron/index.html +0 -13
  63. package/examples/electron/package.json +0 -5
  64. package/examples/electron/tiles.png +0 -0
  65. package/examples/empty/game.js +0 -51
  66. package/examples/empty/index.html +0 -5
  67. package/examples/empty/tiles.png +0 -0
  68. package/examples/favicon.png +0 -0
  69. package/examples/games.jpg +0 -0
  70. package/examples/htmlMenu/game.js +0 -82
  71. package/examples/htmlMenu/index.html +0 -45
  72. package/examples/htmlMenu/tiles.png +0 -0
  73. package/examples/index.html +0 -62
  74. package/examples/logo.png +0 -0
  75. package/examples/logo2.png +0 -0
  76. package/examples/module/build.mjs +0 -124
  77. package/examples/module/game.js +0 -132
  78. package/examples/module/index.html +0 -10
  79. package/examples/module/tiles.png +0 -0
  80. package/examples/particles/index.html +0 -426
  81. package/examples/particles/tiles.png +0 -0
  82. package/examples/platformer/data/gameLevelData.tmx +0 -143
  83. package/examples/platformer/data/gameLevelData.tsx +0 -4
  84. package/examples/platformer/game.js +0 -147
  85. package/examples/platformer/gameCharacter.js +0 -309
  86. package/examples/platformer/gameEffects.js +0 -278
  87. package/examples/platformer/gameLevel.js +0 -205
  88. package/examples/platformer/gameLevelData.json +0 -171
  89. package/examples/platformer/gameObjects.js +0 -378
  90. package/examples/platformer/gamePlayer.js +0 -35
  91. package/examples/platformer/index.html +0 -9
  92. package/examples/platformer/tiles.png +0 -0
  93. package/examples/platformer/tilesLevel.png +0 -0
  94. package/examples/puzzle/game.js +0 -331
  95. package/examples/puzzle/index.html +0 -8
  96. package/examples/puzzle/tiles.png +0 -0
  97. package/examples/screenshot.jpg +0 -0
  98. package/examples/shorts/animation.js +0 -18
  99. package/examples/shorts/base.html +0 -54
  100. package/examples/shorts/blending.js +0 -14
  101. package/examples/shorts/box2d.js +0 -51
  102. package/examples/shorts/box2dCar.js +0 -59
  103. package/examples/shorts/box2dPool.js +0 -107
  104. package/examples/shorts/box2dTileLayer.js +0 -48
  105. package/examples/shorts/cameraDrag.js +0 -22
  106. package/examples/shorts/clock.js +0 -21
  107. package/examples/shorts/colors.js +0 -25
  108. package/examples/shorts/debugDraw.js +0 -37
  109. package/examples/shorts/empty.js +0 -30
  110. package/examples/shorts/flappyGame.js +0 -55
  111. package/examples/shorts/fontImage.js +0 -17
  112. package/examples/shorts/fps.js +0 -90
  113. package/examples/shorts/helloWorld.js +0 -11
  114. package/examples/shorts/hillGlideGame.js +0 -63
  115. package/examples/shorts/input.js +0 -64
  116. package/examples/shorts/landerGame.js +0 -57
  117. package/examples/shorts/maze.js +0 -48
  118. package/examples/shorts/medals.js +0 -51
  119. package/examples/shorts/music.js +0 -78
  120. package/examples/shorts/musicPlayer.js +0 -137
  121. package/examples/shorts/nineSlice.js +0 -40
  122. package/examples/shorts/parallax.js +0 -72
  123. package/examples/shorts/particles.js +0 -28
  124. package/examples/shorts/piano.js +0 -44
  125. package/examples/shorts/platformer.js +0 -45
  126. package/examples/shorts/pongGame.js +0 -41
  127. package/examples/shorts/postProcess.js +0 -62
  128. package/examples/shorts/sequencer.js +0 -124
  129. package/examples/shorts/shader.js +0 -29
  130. package/examples/shorts/shapes.js +0 -21
  131. package/examples/shorts/slidingPuzzle.js +0 -52
  132. package/examples/shorts/song.mp3 +0 -0
  133. package/examples/shorts/sound.js +0 -36
  134. package/examples/shorts/spaceGame.js +0 -58
  135. package/examples/shorts/spriteAtlas.js +0 -31
  136. package/examples/shorts/starfield.js +0 -15
  137. package/examples/shorts/texture.js +0 -16
  138. package/examples/shorts/textureWrapped.js +0 -12
  139. package/examples/shorts/tileLayer.js +0 -48
  140. package/examples/shorts/tileRaycast.js +0 -39
  141. package/examples/shorts/tiles.png +0 -0
  142. package/examples/shorts/tiltedView.js +0 -63
  143. package/examples/shorts/timers.js +0 -53
  144. package/examples/shorts/topDown.js +0 -38
  145. package/examples/shorts/tween.js +0 -24
  146. package/examples/shorts/uiSystem.js +0 -61
  147. package/examples/shorts/video.webm +0 -0
  148. package/examples/shorts/videoPlayer.js +0 -34
  149. package/examples/shorts.js +0 -743
  150. package/examples/starter/build.bat +0 -7
  151. package/examples/starter/build.mjs +0 -126
  152. package/examples/starter/game.js +0 -137
  153. package/examples/starter/index.html +0 -35
  154. package/examples/starter/tiles.png +0 -0
  155. package/examples/stress/index.html +0 -173
  156. package/examples/style.css +0 -150
  157. package/examples/tweenSystem/game.js +0 -171
  158. package/examples/tweenSystem/index.html +0 -10
  159. package/examples/tweenSystem/tiles.png +0 -0
  160. package/examples/typescript/build.mjs +0 -60
  161. package/examples/typescript/game.js +0 -100
  162. package/examples/typescript/game.ts +0 -132
  163. package/examples/typescript/index.html +0 -10
  164. package/examples/typescript/tiles.png +0 -0
  165. package/examples/typescript/tsconfig.json +0 -17
  166. package/examples/uiSystem/game.js +0 -139
  167. package/examples/uiSystem/index.html +0 -10
  168. package/examples/uiSystem/tiles.png +0 -0
  169. package/jsconfig.json +0 -12
  170. package/plugins/desktop.ini +0 -2
  171. package/reference.md +0 -448
  172. package/test/math.test.mjs +0 -774
  173. package/test/setup.mjs +0 -22
  174. package/test/smoke.test.mjs +0 -274
  175. package/test/tween.test.mjs +0 -576
  176. package/test/util.test.mjs +0 -80
@@ -1,45 +0,0 @@
1
- <!DOCTYPE html><head>
2
- <title>LittleJS HTML Menu Example</title>
3
- <meta charset=utf-8>
4
- <meta name=apple-mobile-web-app-capable content=yes>
5
- <meta name=mobile-web-app-capable content=yes>
6
- <link rel=icon type=image/png href=../favicon.png>
7
- <style>
8
- .topDiv
9
- {
10
- position: absolute;
11
- z-index: 1;
12
- width: 100%;
13
- height: 100%;
14
- display: flex;
15
- align-items: center;
16
- justify-content: center;
17
- }
18
- .menuDiv
19
- {
20
- gap: 20px;
21
- padding: 30px;
22
- display: flex;
23
- align-items: center;
24
- flex-direction: column;
25
- border: 3px solid black;
26
- background-color: white;
27
- visibility: hidden;
28
- }
29
- </style>
30
- </head><body>
31
-
32
- <!-- setup html menu system -->
33
- <div class=topDiv>
34
- <div id=menu class=menuDiv>
35
- <b style=font-size:50px>Test Menu</b>
36
- This is an example menu using html elements.
37
- <input id=input_test value='Test Input'>
38
- <input id=input_rangeTest type=range>
39
- <button id=button_test>Test Button</button>
40
- <button id=button_exitMenu>Exit Menu</button>
41
- </div>
42
- </div>
43
-
44
- <!-- Add your game scripts here -->
45
- <script src=game.js type=module></script>
Binary file
@@ -1,62 +0,0 @@
1
- <!DOCTYPE html><head>
2
- <title>LittleJS Example Browser</title>
3
- <link rel=icon type=image/png href=favicon.png>
4
- <link rel=stylesheet href=style.css?9>
5
- <meta charset=utf-8>
6
- <meta name='viewport' content='width=device-width, initial-scale=1.0'>
7
- <!-- meta tags for social media -->
8
- <meta name='twitter:title' content='LittleJS Example Browser'>
9
- <meta property='og:title' content='LittleJS Example Browser'>
10
- <meta name='description' content='Tiny fast HTML5 game engine!'>
11
- <meta name='twitter:description' content='Tiny fast HTML5 game engine!'>
12
- <meta property='og:description' content='Tiny fast HTML5 game engine!'>
13
- <meta name='twitter:image' content='https://3d2k.com/images/LittleJSExamples.png'>
14
- <meta property='og:image' content='https://3d2k.com/images/LittleJSExamples.png'>
15
- <meta name='keywords' content='JavaScript, HTML5, Game, Engine'>
16
- <meta name='twitter:creator' content='@KilledByAPixel'>
17
- <meta name='twitter:card' content='summary_large_image'>
18
- </head><body>
19
- <div id=container1>
20
- <div id=container3>
21
- <p id=titleInfo>LittleJS Example Browser</p>
22
- <p id=exampleInfo></p>
23
- <a id=exampleLink target='_blank'></a>
24
- <div id=divCodeOptions>
25
- <hr>
26
- Theme:
27
- <select style=width:120px id=selectTheme></select>
28
- <select style=width:40px id=selectFontSize>
29
- <option value=10px>XS</option>
30
- <option value=13px>S</option>
31
- <option value=16px selected>M</option>
32
- <option value=20px>L</option>
33
- <option value=24px>XL</option>
34
- </select>
35
- <span class=nowrap><input type=checkbox id=checkboxLiveEdit checked>Live Edit</span>
36
- </div>
37
- <div id=divTextareas>
38
- <textarea id=textareaCode spellcheck=false></textarea>
39
- <textarea id=textareaError readonly spellcheck=false></textarea>
40
- <textarea id=textareaConsole readonly spellcheck=false></textarea>
41
- </div>
42
- </div>
43
- <div id=container2>
44
- <div style='display:flex;justify-content:center'>
45
- <div id=iframeContainer></div>
46
- </div>
47
- <div>
48
- <input id=inputSearch placeholder='Search examples...'>
49
- <button id=buttonRestart>Restart</button>
50
- <span id=container4>
51
- <button id=buttonPause>Pause</button>
52
- <button id=buttonFullscreen>Fullscreen</button>
53
- <button id=buttonScreenshot>Screenshot</button>
54
- <span class=nowrap><input type=checkbox id=checkboxWebGL checked>WebGL</span>
55
- </span>
56
- </div>
57
- <span id=selectExampleText class=nowrap>Select an example...</span>
58
- <select id=selectExample size=2></select>
59
- </div>
60
- </div>
61
- <a href="https://github.com/KilledByAPixel/LittleJS" class="github-corner" aria-label="View source on GitHub"><svg width="80" height="80" viewBox="0 0 250 250" style="fill:#70B7FD; color:#fff; position: absolute; top: 0; border: 0; left: 0; transform: scale(-1, 1);" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"/><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"/><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"/></svg></a><style>.github-corner:hover .octo-arm{animation:octocat-wave 560ms ease-in-out}@keyframes octocat-wave{0%,100%{transform:rotate(0)}20%,60%{transform:rotate(-25deg)}40%,80%{transform:rotate(10deg)}}@media (max-width:500px){.github-corner:hover .octo-arm{animation:none}.github-corner .octo-arm{animation:octocat-wave 560ms ease-in-out}}</style>
62
- <script type=module src=shorts.js></script>
package/examples/logo.png DELETED
Binary file
Binary file
@@ -1,124 +0,0 @@
1
- /**
2
- * LittleJS Build System
3
- */
4
-
5
- 'use strict';
6
-
7
- import { fileURLToPath } from 'node:url';
8
- import { dirname, join } from 'node:path';
9
- import fs from 'node:fs';
10
- import { execSync } from 'node:child_process';
11
-
12
- const __dirname = dirname(fileURLToPath(import.meta.url));
13
-
14
- const PROGRAM_TITLE = 'Little JS Starter Project';
15
- const PROGRAM_NAME = 'game';
16
- const BUILD_FOLDER = join(__dirname, 'build');
17
- const sourceFiles =
18
- [
19
- 'game.js',
20
- // add your game's source files here
21
- ];
22
- const engineFile = join(__dirname, '../../dist/littlejs.esm.min.js'); // Use the minified ES module
23
- const dataFiles =
24
- [
25
- 'tiles.png',
26
- // add your game's data files here
27
- ];
28
-
29
- console.log(`Building ${PROGRAM_NAME}...`);
30
- const startTime = Date.now();
31
-
32
- // rebuild engine
33
- //execSync(`npm run build`, { stdio: 'inherit' });
34
-
35
- // remove old files and setup build folder
36
- fs.rmSync(BUILD_FOLDER, { recursive: true, force: true });
37
- fs.rmSync(join(__dirname, `${PROGRAM_NAME}.zip`), { force: true });
38
- fs.mkdirSync(BUILD_FOLDER);
39
-
40
- // copy data files
41
- for (const file of dataFiles)
42
- fs.copyFileSync(join(__dirname, file), join(BUILD_FOLDER, file));
43
-
44
- // copy engine module
45
- fs.copyFileSync(engineFile, join(BUILD_FOLDER, 'littlejs.esm.min.js'));
46
-
47
- Build
48
- (
49
- sourceFiles,
50
- [htmlBuildStep, zipBuildStep]
51
- );
52
-
53
- console.log('');
54
- console.log(`Build Completed in ${((Date.now() - startTime)/1e3).toFixed(2)} seconds!`);
55
-
56
- ///////////////////////////////////////////////////////////////////////////////
57
-
58
- // A single build with its own source files, build steps, and output file
59
- // - each build step is a callback that accepts a single filename
60
- function Build(files=[], buildSteps=[])
61
- {
62
- // process each source file separately (don't concatenate modules!)
63
- for (const file of files)
64
- {
65
- const outputFile = join(BUILD_FOLDER, file);
66
- fs.copyFileSync(join(__dirname, file), outputFile);
67
- moduleFixStep(outputFile);
68
- uglifyBuildStep(outputFile);
69
- }
70
-
71
- // execute build steps in order
72
- for (const buildStep of buildSteps)
73
- buildStep();
74
- }
75
-
76
- function moduleFixStep(filename)
77
- {
78
- console.log(`Fixing module imports in ${filename}...`);
79
-
80
- let code = fs.readFileSync(filename, 'utf8');
81
-
82
- // update the import path to use the local minified version
83
- code = code.replace(/import \* as LJS from ['"].*littlejs\.esm(?:\.min)?\.js['"];?/g,
84
- "import * as LJS from './littlejs.esm.min.js';");
85
-
86
- // also fix relative imports to other game modules
87
- code = code.replace(/from ['"]\.\.\//g, "from './");
88
-
89
- fs.writeFileSync(filename, code);
90
- }
91
-
92
- function uglifyBuildStep(filename)
93
- {
94
- console.log('Running uglify...');
95
- execSync(`npx uglifyjs ${filename} -c -m -o ${filename}`, {stdio: 'inherit'});
96
- }
97
-
98
- function htmlBuildStep()
99
- {
100
- console.log('Building html...');
101
-
102
- // create html file with module script tag pointing to main game file
103
- let buffer = ''
104
- buffer += '<!DOCTYPE html>';
105
- buffer += '<head>';
106
- buffer += `<title>${PROGRAM_TITLE}</title>`;
107
- buffer += '<meta charset=utf-8>';
108
- buffer += '</head>';
109
- buffer += '<body>';
110
- buffer += '<script src="game.js" type="module"></script>';
111
- buffer += '</body>';
112
-
113
- // output html file
114
- fs.writeFileSync(join(BUILD_FOLDER, 'index.html'), buffer, {flag: 'w+'});
115
- }
116
-
117
- function zipBuildStep()
118
- {
119
- console.log('Zipping...');
120
- const sources = ['index.html', 'littlejs.esm.min.js', ...sourceFiles, ...dataFiles];
121
- const sourceList = sources.join(' ');
122
- execSync(`npx bestzip ../${PROGRAM_NAME}.zip ${sourceList}`, {cwd:BUILD_FOLDER, stdio: 'inherit'});
123
- console.log(`Size of ${PROGRAM_NAME}.zip: ${fs.statSync(join(__dirname, `${PROGRAM_NAME}.zip`)).size} bytes`);
124
- }
@@ -1,132 +0,0 @@
1
- /*
2
- Little JS Module Demo
3
- - A simple starter project
4
- - Shows how to use LittleJS with modules
5
- */
6
-
7
- 'use strict';
8
-
9
- // import LittleJS module
10
- import * as LJS from '../../dist/littlejs.esm.js';
11
- const {tile, vec2, hsl} = LJS;
12
-
13
- // show the LittleJS splash screen
14
- LJS.setShowSplashScreen(true);
15
-
16
- // fix texture bleeding by shrinking tile slightly
17
- LJS.setTileDefaultBleed(.5);
18
-
19
- // sound effects
20
- const sound_click = new LJS.Sound([1,.5]);
21
-
22
- // medals
23
- const medal_example = new LJS.Medal(0, 'Example Medal', 'Welcome to LittleJS!');
24
- LJS.medalsInit('Hello World');
25
-
26
- // game variables
27
- let particleEmitter;
28
-
29
- ///////////////////////////////////////////////////////////////////////////////
30
- function gameInit()
31
- {
32
- // create tile collision and visible tile layer
33
- const pos = vec2();
34
- const tileLayer = new LJS.TileCollisionLayer(pos, vec2(32,16));
35
-
36
- // get level data from the tiles image
37
- const mainContext = LJS.mainContext;
38
- const tileImage = LJS.textureInfos[0].image;
39
- mainContext.drawImage(tileImage, 0, 0);
40
- const imageData = mainContext.getImageData(0,0,tileImage.width,tileImage.height).data;
41
- for (pos.x = tileLayer.size.x; pos.x--;)
42
- for (pos.y = tileLayer.size.y; pos.y--;)
43
- {
44
- // check if this pixel is set
45
- const i = pos.x + tileImage.width*(15 + tileLayer.size.y - pos.y);
46
- if (!imageData[4*i])
47
- continue;
48
-
49
- // set tile data
50
- const tileIndex = 1;
51
- const direction = LJS.randInt(4)
52
- const mirror = !LJS.randInt(2);
53
- const color = LJS.randColor();
54
- const data = new LJS.TileLayerData(tileIndex, direction, mirror, color);
55
- tileLayer.setData(pos, data);
56
- tileLayer.setCollisionData(pos);
57
- }
58
-
59
- // draw tile layer with new data
60
- tileLayer.redraw();
61
-
62
- // move camera to center of collision
63
- LJS.setCameraPos(tileLayer.size.scale(.5));
64
- LJS.setCameraScale(32);
65
-
66
- // enable gravity
67
- LJS.setGravity(vec2(0,-.01));
68
-
69
- // create particle emitter
70
- particleEmitter = new LJS.ParticleEmitter(
71
- vec2(16,9), 0, // emitPos, emitAngle
72
- 0, 0, 500, 3.14, // emitSize, emitTime, rate, cone
73
- tile(0, 16), // tileIndex, tileSize
74
- hsl(1,1,1), hsl(0,0,0), // colorStartA, colorStartB
75
- hsl(0,0,0,0), hsl(0,0,0,0), // colorEndA, colorEndB
76
- 1, .2, .2, .1, .05, // time, sizeStart, sizeEnd, speed, angleSpeed
77
- .99, 1, 1, 3.14, // damping, angleDamping, gravityScale, cone
78
- .05, .5, true, true // fadeRate, randomness, collide, additive
79
- );
80
- particleEmitter.restitution = .3; // bounce when it collides
81
- particleEmitter.trailScale = 2; // stretch as it moves
82
- particleEmitter.velocityInheritance = .3; // inherit emitter velocity
83
- }
84
-
85
- ///////////////////////////////////////////////////////////////////////////////
86
- function gameUpdate()
87
- {
88
- if (LJS.mouseWasPressed(0))
89
- {
90
- // play sound when mouse is pressed
91
- sound_click.play(LJS.mousePos);
92
-
93
- // change particle color and set to fade out
94
- particleEmitter.colorStartA = LJS.randColor();
95
- particleEmitter.colorStartB = LJS.randColor();
96
- particleEmitter.colorEndA = particleEmitter.colorStartA.scale(1,0);
97
- particleEmitter.colorEndB = particleEmitter.colorStartB.scale(1,0);
98
-
99
- // unlock medals
100
- medal_example.unlock();
101
- }
102
-
103
- // move particles to mouse location if on screen
104
- if (LJS.mousePosScreen.x)
105
- particleEmitter.pos = LJS.mousePos;
106
- }
107
-
108
- ///////////////////////////////////////////////////////////////////////////////
109
- function gameUpdatePost()
110
- {
111
-
112
- }
113
-
114
- ///////////////////////////////////////////////////////////////////////////////
115
- function gameRender()
116
- {
117
- // draw a grey square in the background
118
- LJS.drawRect(vec2(16,8), vec2(20,14), hsl(0,0,.6));
119
-
120
- // draw the logo as a tile
121
- LJS.drawTile(vec2(21,5), vec2(4.5), tile(3,128));
122
- }
123
-
124
- ///////////////////////////////////////////////////////////////////////////////
125
- function gameRenderPost()
126
- {
127
- LJS.drawTextScreen('LittleJS with Modules', vec2(LJS.mainCanvasSize.x/2, 80), 80);
128
- }
129
-
130
- ///////////////////////////////////////////////////////////////////////////////
131
- // Startup LittleJS Engine
132
- LJS.engineInit(gameInit, gameUpdate, gameUpdatePost, gameRender, gameRenderPost, ['tiles.png']);
@@ -1,10 +0,0 @@
1
- <!DOCTYPE html><head>
2
- <title>LittleJS Module Demo</title>
3
- <meta charset=utf-8>
4
- <meta name=apple-mobile-web-app-capable content=yes>
5
- <meta name=mobile-web-app-capable content=yes>
6
- <link rel=icon type=image/png href=../favicon.png>
7
- </head><body>
8
-
9
- <!-- Add your game scripts here -->
10
- <script src=game.js type=module></script>
Binary file