littlejsengine 1.11.13 → 1.12.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 (79) hide show
  1. package/dist/littlejs.d.ts +1418 -109
  2. package/dist/littlejs.esm.js +3495 -581
  3. package/dist/littlejs.esm.min.js +1 -1
  4. package/dist/littlejs.js +3258 -399
  5. package/dist/littlejs.min.js +1 -1
  6. package/dist/littlejs.release.js +3147 -379
  7. package/examples/box2d/game.js +73 -45
  8. package/examples/box2d/gameObjects.js +96 -92
  9. package/examples/box2d/index.html +2 -7
  10. package/examples/box2d/scenes.js +82 -92
  11. package/examples/breakout/game.js +62 -30
  12. package/examples/breakout/gameObjects.js +45 -47
  13. package/examples/breakout/index.html +1 -5
  14. package/examples/breakoutTutorial/game.js +36 -29
  15. package/examples/breakoutTutorial/index.html +1 -3
  16. package/examples/empty/game.js +5 -2
  17. package/examples/empty/index.html +1 -3
  18. package/examples/htmlMenu/game.js +25 -19
  19. package/examples/htmlMenu/index.html +5 -7
  20. package/examples/index.html +2 -3
  21. package/examples/module/game.js +32 -34
  22. package/examples/module/index.html +1 -1
  23. package/examples/particles/index.html +27 -22
  24. package/examples/platformer/game.js +71 -48
  25. package/examples/platformer/gameCharacter.js +42 -34
  26. package/examples/platformer/gameEffects.js +82 -75
  27. package/examples/platformer/gameLevel.js +67 -38
  28. package/examples/platformer/{gameLevelData.js → gameLevelData.json} +1 -11
  29. package/examples/platformer/gameObjects.js +70 -64
  30. package/examples/platformer/gamePlayer.js +12 -7
  31. package/examples/platformer/index.html +1 -9
  32. package/examples/puzzle/game.js +58 -42
  33. package/examples/puzzle/index.html +1 -3
  34. package/examples/shorts/base.html +2 -2
  35. package/examples/shorts/particles.js +1 -1
  36. package/examples/shorts/platformer.js +1 -1
  37. package/examples/shorts/tileLayer.js +5 -6
  38. package/examples/shorts/tiles.png +0 -0
  39. package/examples/starter/build.js +4 -4
  40. package/examples/starter/game.js +9 -12
  41. package/examples/starter/index.html +13 -13
  42. package/examples/stress/index.html +44 -43
  43. package/examples/typescript/build.js +17 -18
  44. package/examples/typescript/game.js +32 -34
  45. package/examples/typescript/game.ts +32 -34
  46. package/examples/typescript/index.html +1 -1
  47. package/examples/uiSystem/game.js +33 -36
  48. package/examples/uiSystem/index.html +1 -5
  49. package/package.json +3 -3
  50. package/plugins/box2d.js +1556 -640
  51. package/plugins/{Box2D_v2.3.1_min.wasm.js → box2d.wasm.js} +1 -1
  52. package/plugins/newgrounds.js +7 -8
  53. package/plugins/pluginExport.js +50 -0
  54. package/plugins/postProcess.js +94 -93
  55. package/plugins/uiSystem.js +145 -161
  56. package/plugins/zzfxm.js +163 -0
  57. package/reference.md +29 -27
  58. package/src/engine.js +15 -20
  59. package/src/engineAudio.js +74 -204
  60. package/src/engineBuild.js +29 -4
  61. package/src/engineDebug.js +105 -9
  62. package/src/engineDraw.js +27 -14
  63. package/src/engineExport.js +12 -8
  64. package/src/engineInput.js +3 -1
  65. package/src/engineObject.js +18 -14
  66. package/src/engineParticles.js +6 -1
  67. package/src/engineRelease.js +6 -1
  68. package/src/engineSettings.js +8 -8
  69. package/src/engineTileLayer.js +179 -96
  70. package/src/engineUtilities.js +5 -11
  71. package/src/engineWebGL.js +19 -7
  72. package/examples/starter/build/index.html +0 -2
  73. package/examples/starter/build/index.js +0 -1
  74. package/examples/starter/build/tiles.png +0 -0
  75. package/examples/starter/game.zip +0 -0
  76. package/examples/typescript/build/dist/littlejs.esm.js +0 -4834
  77. package/examples/typescript/build/examples/typescript/build.js +0 -24
  78. package/examples/typescript/build/examples/typescript/game.js +0 -102
  79. /package/plugins/{Box2D_v2.3.1_min.wasm.wasm → box2d.wasm.wasm} +0 -0
@@ -1,24 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * LittleJS Build System
4
- */
5
- 'use strict';
6
- const PROGRAM_NAME = 'game';
7
- const BUILD_FOLDER = 'build';
8
- const ROOT_FOLDER = 'examples/typescript';
9
- const sourceFiles = [
10
- 'game.js',
11
- // add your game's scripts here
12
- ];
13
- console.log(`Building TypeScript for ${PROGRAM_NAME}...`);
14
- const startTime = Date.now();
15
- const fs = require('node:fs');
16
- const child_process = require('node:child_process');
17
- console.log(`Removing old build filder...`);
18
- fs.rmSync(BUILD_FOLDER, { recursive: true, force: true });
19
- console.log(`Compiling TypeScript...`);
20
- child_process.execSync(`npx tsc --outDir "./${BUILD_FOLDER}"`, { stdio: 'inherit' });
21
- console.log(`Moving js files to root...`);
22
- for (const file of sourceFiles)
23
- fs.copyFileSync(`${BUILD_FOLDER}/${ROOT_FOLDER}/${file}`, `${file}`);
24
- console.log(`TypeScript built in ${((Date.now() - startTime) / 1e3).toFixed(2)} seconds!`);
@@ -1,102 +0,0 @@
1
- /*
2
- Little JS TypeScript Demo
3
- - A simple starter project
4
- - Shows how to use LittleJS with modules
5
- */
6
- 'use strict';
7
- // import module
8
- import * as LittleJS from '../../dist/littlejs.esm.js';
9
- const { tile, vec2, hsl } = LittleJS;
10
- // show the LittleJS splash screen
11
- LittleJS.setShowSplashScreen(true);
12
- // fix texture bleeding by shrinking tile slightly
13
- LittleJS.setTileFixBleedScale(.5);
14
- // sound effects
15
- const sound_click = new LittleJS.Sound([1, .5]);
16
- // medals
17
- const medal_example = new LittleJS.Medal(0, 'Example Medal', 'Welcome to LittleJS!');
18
- LittleJS.medalsInit('Hello World');
19
- // game variables
20
- let particleEmitter;
21
- ///////////////////////////////////////////////////////////////////////////////
22
- function gameInit() {
23
- // create tile collision and visible tile layer
24
- const tileCollisionSize = vec2(32, 16);
25
- LittleJS.initTileCollision(tileCollisionSize);
26
- const pos = vec2();
27
- const tileLayer = new LittleJS.TileLayer(pos, tileCollisionSize);
28
- // get level data from the tiles image
29
- const mainContext = LittleJS.mainContext;
30
- const tileImage = LittleJS.textureInfos[0].image;
31
- mainContext.drawImage(tileImage, 0, 0);
32
- const imageData = mainContext.getImageData(0, 0, tileImage.width, tileImage.height).data;
33
- for (pos.x = tileCollisionSize.x; pos.x--;)
34
- for (pos.y = tileCollisionSize.y; pos.y--;) {
35
- // check if this pixel is set
36
- const i = pos.x + tileImage.width * (15 + tileCollisionSize.y - pos.y);
37
- if (!imageData[4 * i])
38
- continue;
39
- // set tile data
40
- const tileIndex = 1;
41
- const direction = LittleJS.randInt(4);
42
- const mirror = !LittleJS.randInt(2);
43
- const color = LittleJS.randColor();
44
- const data = new LittleJS.TileLayerData(tileIndex, direction, mirror, color);
45
- tileLayer.setData(pos, data);
46
- LittleJS.setTileCollisionData(pos, 1);
47
- }
48
- // draw tile layer with new data
49
- tileLayer.redraw();
50
- // move camera to center of collision
51
- LittleJS.setCameraPos(tileCollisionSize.scale(.5));
52
- LittleJS.setCameraScale(32);
53
- // enable gravity
54
- LittleJS.setGravity(-.01);
55
- // create particle emitter
56
- particleEmitter = new LittleJS.ParticleEmitter(vec2(16, 9), 0, // emitPos, emitAngle
57
- 1, 0, 500, Math.PI, // emitSize, emitTime, emitRate, emitCone
58
- tile(0, 16), // tileIndex, tileSize
59
- hsl(1, 1, 1), hsl(0, 0, 0), // colorStartA, colorStartB
60
- hsl(0, 0, 0, 0), hsl(0, 0, 0, 0), // colorEndA, colorEndB
61
- 2, .2, .2, .1, .05, // time, sizeStart, sizeEnd, speed, angleSpeed
62
- .99, 1, 1, Math.PI, // damping, angleDamping, gravityScale, cone
63
- .05, .5, true, true // fadeRate, randomness, collide, additive
64
- );
65
- particleEmitter.elasticity = .3; // bounce when it collides
66
- particleEmitter.trailScale = 2; // stretch in direction of motion
67
- }
68
- ///////////////////////////////////////////////////////////////////////////////
69
- function gameUpdate() {
70
- if (LittleJS.mouseWasPressed(0)) {
71
- // play sound when mouse is pressed
72
- sound_click.play(LittleJS.mousePos);
73
- // change particle color and set to fade out
74
- particleEmitter.colorStartA = hsl();
75
- particleEmitter.colorStartB = LittleJS.randColor();
76
- particleEmitter.colorEndA = particleEmitter.colorStartA.scale(1, 0);
77
- particleEmitter.colorEndB = particleEmitter.colorStartB.scale(1, 0);
78
- // unlock medals
79
- medal_example.unlock();
80
- }
81
- // move particles to mouse location if on screen
82
- if (LittleJS.mousePosScreen.x)
83
- particleEmitter.pos = LittleJS.mousePos;
84
- }
85
- ///////////////////////////////////////////////////////////////////////////////
86
- function gameUpdatePost() {
87
- }
88
- ///////////////////////////////////////////////////////////////////////////////
89
- function gameRender() {
90
- // draw a grey square in the background without using webgl
91
- LittleJS.drawRect(vec2(16, 8), vec2(20, 14), hsl(0, 0, .6), 0, false);
92
- // draw the logo as a tile
93
- LittleJS.drawTile(vec2(21, 5), vec2(4.5), tile(3, 128));
94
- }
95
- ///////////////////////////////////////////////////////////////////////////////
96
- function gameRenderPost() {
97
- // draw to overlay canvas for hud rendering
98
- LittleJS.drawTextScreen('LittleJS with TypeScript', vec2(LittleJS.mainCanvasSize.x / 2, 80), 80);
99
- }
100
- ///////////////////////////////////////////////////////////////////////////////
101
- // Startup LittleJS Engine
102
- LittleJS.engineInit(gameInit, gameUpdate, gameUpdatePost, gameRender, gameRenderPost, ['tiles.png']);