littlejsengine 1.13.1 → 1.14.2
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/README.md +15 -11
- package/copyToGithub.bat +28 -0
- package/dist/littlejs.d.ts +430 -304
- package/dist/littlejs.esm.js +1745 -982
- package/dist/littlejs.esm.min.js +1 -1
- package/dist/littlejs.js +1716 -965
- package/dist/littlejs.min.js +1 -1
- package/dist/littlejs.release.js +1673 -922
- package/examples/box2d/game.js +2 -2
- package/examples/box2d/gameObjects.js +2 -2
- package/examples/box2d/scenes.js +1 -1
- package/examples/breakout/game.js +30 -25
- package/examples/breakoutTutorial/README.md +44 -41
- package/examples/breakoutTutorial/game.js +2 -2
- package/examples/electron/build.bat +7 -0
- package/examples/electron/build.js +124 -0
- package/examples/electron/electron.js +35 -0
- package/examples/electron/game.js +140 -0
- package/examples/electron/index.html +13 -0
- package/examples/electron/package.json +12 -0
- package/examples/electron/tiles.png +0 -0
- package/examples/empty/game.js +1 -0
- package/examples/htmlMenu/game.js +1 -1
- package/examples/index.html +332 -160
- package/examples/module/game.js +5 -2
- package/examples/particles/index.html +12 -3
- package/examples/platformer/gameEffects.js +20 -19
- package/examples/platformer/gameLevel.js +6 -1
- package/examples/shorts/base.html +1 -1
- package/examples/shorts/blending.js +9 -5
- package/examples/shorts/box2d.js +1 -1
- package/examples/shorts/box2dCar.js +1 -1
- package/examples/shorts/clock.js +1 -1
- package/examples/shorts/colors.js +2 -2
- package/examples/shorts/flappyGame.js +2 -1
- package/examples/shorts/helloWorld.js +1 -1
- package/examples/shorts/maze.js +1 -1
- package/examples/shorts/music.js +106 -0
- package/examples/shorts/nineSlice.js +9 -9
- package/examples/shorts/parallax.js +71 -0
- package/examples/shorts/piano.js +9 -10
- package/examples/shorts/postProcess.js +25 -8
- package/examples/shorts/raycasting.js +2 -2
- package/examples/shorts/shapes.js +7 -15
- package/examples/shorts/slidingPuzzle.js +2 -2
- package/examples/shorts/song.mp3 +0 -0
- package/examples/shorts/starfield.js +5 -7
- package/examples/shorts/systemFont.js +1 -1
- package/examples/shorts/uiSystem.js +16 -8
- package/examples/starter/build.js +9 -8
- package/examples/starter/game.js +5 -2
- package/examples/starter/index.html +2 -2
- package/examples/stress/index.html +13 -8
- package/examples/style.css +19 -6
- package/examples/typescript/build.js +1 -1
- package/examples/typescript/game.js +2 -2
- package/examples/typescript/game.ts +5 -2
- package/examples/uiSystem/game.js +13 -12
- package/package.json +2 -2
- package/plugins/box2d.js +24 -97
- package/plugins/drawUtilities.js +29 -23
- package/plugins/newgrounds.js +6 -6
- package/plugins/pluginExport.js +1 -1
- package/plugins/postProcess.js +7 -0
- package/plugins/uiSystem.js +106 -82
- package/plugins/zzfxm.js +10 -10
- package/reference.md +90 -54
- package/src/engine.js +28 -23
- package/src/engineAudio.js +285 -110
- package/src/engineBuild.js +9 -9
- package/src/engineDebug.js +28 -28
- package/src/engineDraw.js +346 -202
- package/src/engineExport.js +28 -16
- package/src/engineInput.js +58 -68
- package/src/engineMedals.js +29 -29
- package/src/engineObject.js +28 -25
- package/src/engineParticles.js +67 -60
- package/src/engineRelease.js +1 -1
- package/src/engineSettings.js +70 -16
- package/src/engineTileLayer.js +34 -34
- package/src/engineUtilities.js +69 -62
- package/src/engineWebGL.js +467 -65
- /package/examples/shorts/{playSound.js → sound.js} +0 -0
|
@@ -33,8 +33,8 @@ class PuzzlePiece extends EngineObject
|
|
|
33
33
|
function gameInit()
|
|
34
34
|
{
|
|
35
35
|
// create puzzle pieces
|
|
36
|
-
for(let x=gridSize.x; x--;)
|
|
37
|
-
for(let y=gridSize.y; y--;)
|
|
36
|
+
for (let x=gridSize.x; x--;)
|
|
37
|
+
for (let y=gridSize.y; y--;)
|
|
38
38
|
(x||y) && new PuzzlePiece(vec2(x,y), pieceSize);
|
|
39
39
|
|
|
40
40
|
// center camera on grid
|
|
Binary file
|
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
function gameRender()
|
|
2
2
|
{
|
|
3
|
-
setBlendMode(1);
|
|
4
3
|
// precreate variables to avoid overhead
|
|
5
4
|
const pos = vec2(), size = vec2(), color = WHITE;
|
|
6
|
-
for(let i=2e3; i--;)
|
|
5
|
+
for (let i=2e3; i--;)
|
|
7
6
|
{
|
|
8
7
|
// use math to generate random star positions
|
|
9
8
|
const offset = time*(9+i**2.1%15) + i**2.3;
|
|
10
|
-
pos.x = offset%70-35;
|
|
11
|
-
pos.y = i/
|
|
12
|
-
size.x = size.y = i%.11
|
|
13
|
-
color.
|
|
9
|
+
pos.x = offset%70 - 35;
|
|
10
|
+
pos.y = i/110 - 9;
|
|
11
|
+
size.x = size.y = i%.11 + .07;
|
|
12
|
+
color.set(1,1,1,Math.sin(i)**4);
|
|
14
13
|
drawRect(pos, size, color);
|
|
15
14
|
}
|
|
16
|
-
setBlendMode(0);
|
|
17
15
|
}
|
|
@@ -8,28 +8,36 @@ function gameInit()
|
|
|
8
8
|
new UISystemPlugin;
|
|
9
9
|
uiSystem.defaultSoundPress = new Sound([1,0,220]);
|
|
10
10
|
uiSystem.defaultSoundClick = new Sound([1,0,440]);
|
|
11
|
+
uiSystem.defaultCornerRadius = 8;
|
|
11
12
|
|
|
12
13
|
// setup example menu
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
uiMenu
|
|
14
|
+
uiBackground = new UIObject(mainCanvasSize.scale(.5), vec2(1e5));
|
|
15
|
+
uiBackground.color = hsl(0,0,.8);
|
|
16
|
+
const uiMenu = new UIObject(vec2(), vec2(450));
|
|
17
|
+
uiBackground.addChild(uiMenu);
|
|
16
18
|
|
|
17
19
|
// example text
|
|
18
|
-
const textTitle = new UIText(vec2(0,-
|
|
20
|
+
const textTitle = new UIText(vec2(0,-120), vec2(400, 60), 'LittleJS UI\nSystem Demo');
|
|
19
21
|
uiMenu.addChild(textTitle);
|
|
20
22
|
|
|
21
23
|
// example button
|
|
22
|
-
const button1 = new UIButton(vec2(70,
|
|
23
|
-
button1.textHeight =
|
|
24
|
+
const button1 = new UIButton(vec2(70,0), vec2(140, 80), 'Test');
|
|
25
|
+
button1.textHeight = 60;
|
|
24
26
|
uiMenu.addChild(button1);
|
|
25
27
|
button1.onClick = ()=> uiBackground.color = randColor();
|
|
26
28
|
|
|
27
29
|
// example checkbox
|
|
28
|
-
const checkbox = new UICheckbox(vec2(-70,
|
|
30
|
+
const checkbox = new UICheckbox(vec2(-70,0), vec2(50));
|
|
31
|
+
checkbox.onChange = ()=> button1.disabled = checkbox.checked;
|
|
29
32
|
uiMenu.addChild(checkbox);
|
|
30
33
|
|
|
34
|
+
// example scrollbar
|
|
35
|
+
const scrollbar = new UIScrollbar(vec2(0,90), vec2(300, 50), soundVolume, 'Volume');
|
|
36
|
+
uiMenu.addChild(scrollbar);
|
|
37
|
+
scrollbar.onChange = ()=> setSoundVolume(scrollbar.value);
|
|
38
|
+
|
|
31
39
|
// exit button
|
|
32
|
-
const button2 = new UIButton(vec2(0,
|
|
40
|
+
const button2 = new UIButton(vec2(0,170), vec2(300, 50), 'Exit Menu');
|
|
33
41
|
button2.textHeight = 40;
|
|
34
42
|
uiMenu.addChild(button2);
|
|
35
43
|
button2.onClick = ()=> uiMenu.visible = false;
|
|
@@ -36,7 +36,7 @@ fs.rmSync(`${PROGRAM_NAME}.zip`, { force: true });
|
|
|
36
36
|
fs.mkdirSync(BUILD_FOLDER);
|
|
37
37
|
|
|
38
38
|
// copy data files
|
|
39
|
-
for(const file of dataFiles)
|
|
39
|
+
for (const file of dataFiles)
|
|
40
40
|
fs.copyFileSync(file, `${BUILD_FOLDER}/${file}`);
|
|
41
41
|
|
|
42
42
|
Build
|
|
@@ -50,7 +50,6 @@ Build
|
|
|
50
50
|
|
|
51
51
|
console.log('');
|
|
52
52
|
console.log(`Build Completed in ${((Date.now() - startTime)/1e3).toFixed(2)} seconds!`);
|
|
53
|
-
console.log(`Size of ${PROGRAM_NAME}.zip: ${fs.statSync(`${PROGRAM_NAME}.zip`).size} bytes`);
|
|
54
53
|
|
|
55
54
|
///////////////////////////////////////////////////////////////////////////////
|
|
56
55
|
|
|
@@ -73,7 +72,7 @@ function Build(outputFile, files=[], buildSteps=[])
|
|
|
73
72
|
|
|
74
73
|
function closureCompilerStep(filename)
|
|
75
74
|
{
|
|
76
|
-
console.log(
|
|
75
|
+
console.log('Running closure compiler...');
|
|
77
76
|
|
|
78
77
|
// use closer compiler to minify the code
|
|
79
78
|
const filenameTemp = filename + '.tmp';
|
|
@@ -84,22 +83,23 @@ function closureCompilerStep(filename)
|
|
|
84
83
|
|
|
85
84
|
function uglifyBuildStep(filename)
|
|
86
85
|
{
|
|
87
|
-
console.log(
|
|
86
|
+
console.log('Running uglify...');
|
|
88
87
|
child_process.execSync(`npx uglifyjs ${filename} -c -m -o ${filename}`, {stdio: 'inherit'});
|
|
89
88
|
};
|
|
90
89
|
|
|
91
90
|
function roadrollerBuildStep(filename)
|
|
92
91
|
{
|
|
93
|
-
console.log(
|
|
92
|
+
console.log('Running roadroller...');
|
|
94
93
|
child_process.execSync(`npx roadroller ${filename} -o ${filename}`, {stdio: 'inherit'});
|
|
95
94
|
};
|
|
96
95
|
|
|
97
96
|
function htmlBuildStep(filename)
|
|
98
97
|
{
|
|
99
|
-
console.log(
|
|
98
|
+
console.log('Building html...');
|
|
100
99
|
|
|
101
100
|
// create html file
|
|
102
|
-
let buffer = '
|
|
101
|
+
let buffer = ''
|
|
102
|
+
buffer += '<!DOCTYPE html>';
|
|
103
103
|
buffer += '<head>';
|
|
104
104
|
buffer += `<title>${PROGRAM_TITLE}</title>`;
|
|
105
105
|
buffer += '<meta charset=utf-8>';
|
|
@@ -115,8 +115,9 @@ function htmlBuildStep(filename)
|
|
|
115
115
|
|
|
116
116
|
function zipBuildStep(filename)
|
|
117
117
|
{
|
|
118
|
-
console.log(
|
|
118
|
+
console.log('Zipping...');
|
|
119
119
|
const sources = ['index.html', ...dataFiles];
|
|
120
120
|
const sourceList = sources.join(' ');
|
|
121
121
|
child_process.execSync(`npx bestzip ../${PROGRAM_NAME}.zip ${sourceList}`, {cwd:BUILD_FOLDER, stdio: 'inherit'});
|
|
122
|
+
console.log(`Size of ${PROGRAM_NAME}.zip: ${fs.statSync(`${PROGRAM_NAME}.zip`).size} bytes`);
|
|
122
123
|
};
|
package/examples/starter/game.js
CHANGED
|
@@ -104,7 +104,10 @@ function gameUpdate()
|
|
|
104
104
|
|
|
105
105
|
// move particles to mouse location if on screen
|
|
106
106
|
if (mousePosScreen.x)
|
|
107
|
+
{
|
|
107
108
|
particleEmitter.pos = mousePos;
|
|
109
|
+
particleEmitter.velocity = mouseDelta.scale(.3*timeDelta);
|
|
110
|
+
}
|
|
108
111
|
}
|
|
109
112
|
|
|
110
113
|
///////////////////////////////////////////////////////////////////////////////
|
|
@@ -116,8 +119,8 @@ function gameUpdatePost()
|
|
|
116
119
|
///////////////////////////////////////////////////////////////////////////////
|
|
117
120
|
function gameRender()
|
|
118
121
|
{
|
|
119
|
-
// draw a grey square in the background
|
|
120
|
-
drawRect(vec2(16,8), vec2(20,14), hsl(0,0,.6)
|
|
122
|
+
// draw a grey square in the background
|
|
123
|
+
drawRect(vec2(16,8), vec2(20,14), hsl(0,0,.6));
|
|
121
124
|
|
|
122
125
|
// draw the logo as a tile
|
|
123
126
|
drawTile(vec2(21,5), vec2(4.5), tile(3,128));
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
</head><body>
|
|
8
8
|
|
|
9
9
|
<!-- LittleJS Engine -->
|
|
10
|
-
<script src=../../dist/littlejs.js?
|
|
10
|
+
<script src=../../dist/littlejs.js?1136></script>
|
|
11
11
|
|
|
12
12
|
<!-- LittleJS Engine Source
|
|
13
13
|
<script src=../../src/engineDebug.js></script>
|
|
@@ -31,4 +31,4 @@
|
|
|
31
31
|
-->
|
|
32
32
|
|
|
33
33
|
<!-- Add your game scripts here -->
|
|
34
|
-
<script src=game.js?
|
|
34
|
+
<script src=game.js?1136></script>
|
|
@@ -21,7 +21,7 @@ import * as LJS from '../../dist/littlejs.esm.min.js';
|
|
|
21
21
|
const {vec2, rgb} = LJS;
|
|
22
22
|
|
|
23
23
|
// keep our own list of simple sprites and track fps
|
|
24
|
-
let sprites, tileLayer, timeMS, fpsDisplay, statsDisplay, spriteColor, spriteAdditiveColor;
|
|
24
|
+
let sprites, tileLayer, timeMS, fpsDisplay, statsDisplay, spriteColor, spriteAdditiveColor, musicInstance;
|
|
25
25
|
|
|
26
26
|
///////////////////////////////////////////////////////////////////////////////
|
|
27
27
|
|
|
@@ -59,8 +59,13 @@ function gameInit()
|
|
|
59
59
|
///////////////////////////////////////////////////////////////////////////////
|
|
60
60
|
function gameUpdate()
|
|
61
61
|
{
|
|
62
|
-
if (LJS.mouseWasPressed(0)
|
|
63
|
-
|
|
62
|
+
if (LJS.mouseWasPressed(0))
|
|
63
|
+
{
|
|
64
|
+
if (!musicInstance)
|
|
65
|
+
musicInstance = music.play();
|
|
66
|
+
else if (!musicInstance.isPlaying())
|
|
67
|
+
musicInstance.start();
|
|
68
|
+
}
|
|
64
69
|
|
|
65
70
|
// mouse click = change color
|
|
66
71
|
if (LJS.mouseWasPressed(0) || LJS.mouseIsDown(2))
|
|
@@ -123,23 +128,23 @@ function gameRender()
|
|
|
123
128
|
// update sprites
|
|
124
129
|
for (const sprite of sprites)
|
|
125
130
|
{
|
|
126
|
-
// keep sprites above 0
|
|
127
|
-
sprite.pos.y = LJS.max(sprite.pos.y, 0);
|
|
128
|
-
|
|
129
131
|
// apply velocity and gravity
|
|
130
132
|
sprite.pos.x += sprite.velocity.x;
|
|
131
133
|
sprite.pos.y += sprite.velocity.y += LJS.gravity.y;
|
|
132
134
|
|
|
133
135
|
// bounce
|
|
134
136
|
if (sprite.pos.y < 0)
|
|
137
|
+
{
|
|
138
|
+
sprite.pos.y = 0;
|
|
135
139
|
sprite.velocity.y = LJS.rand(.3,.8);
|
|
140
|
+
}
|
|
136
141
|
if (sprite.pos.x < 0)
|
|
137
142
|
sprite.pos.x = 0, sprite.velocity.x *= -1;
|
|
138
143
|
if (sprite.pos.x > tileLayer.size.x)
|
|
139
144
|
sprite.pos.x = tileLayer.size.x, sprite.velocity.x *= -1;
|
|
140
145
|
|
|
141
146
|
// rotate sprite
|
|
142
|
-
sprite.angle +=
|
|
147
|
+
sprite.angle += sprite.velocity.x > 0 ? .02 : -.02;
|
|
143
148
|
|
|
144
149
|
// draw the sprite directly using glDraw for extra speed
|
|
145
150
|
LJS.glDraw(sprite.pos.x, sprite.pos.y, 1, 1, sprite.angle, 0, 0, 1, 1,
|
|
@@ -162,5 +167,5 @@ LJS.engineInit(gameInit, gameUpdate, gameUpdatePost, gameRender, gameRenderPost,
|
|
|
162
167
|
|
|
163
168
|
///////////////////////////////////////////////////////////////////////////////
|
|
164
169
|
// music - Depp Loop
|
|
165
|
-
const music = new LJS.ZzFXMusic([[[.6,0,
|
|
170
|
+
const music = new LJS.ZzFXMusic([[[.6,0,43,,,1,1,.5,,,,,.1,,,.05,,.5,.4,.2],[,0,43,.01,,.2,2,,,,,,,,,,.01],[,0,170,.003,,.008,,.97,-35,53,,,,,,.1],[.8,0,270,,,.12,3,1.65,-2,,,,,4.5,,.02],[,0,86,,,.1,,.7,,,,.5,,6.7,1,.05],[,0,41,,.05,.4,2,0,,,9,.01,,,,.08,.02],[,0,2200,,,.04,3,2,,,800,.02,,4.8,,.01,.1],[.3,0,16,,,.3,3]],[[[1,-1,21,21,33,21,21,33,21,21,33,21,21,33,21,21,33,33,21,21,33,21,21,33,21,21,33,21,21,33,21,21,33,33,21,21,33,21,21,33,21,21,33,21,21,33,21,21,33,33,21,21,33,21,21,33,21,21,33,21,21,33,21,21,33,33],[3,1,22,,,,,,,,,,,,,,,,,,,,,,,,,,,,24,,,,24,,,,,,,,,,,,,,,,,,,,,,,,22,,22,,22,,,,],[5,-1,21,,,,,,,,,,,,,,,,,,,,,,,,,,,,24,,,,23,,,,,,,,,,,,,,,,,,,,,,,,24,,23,,21,,,,],[,1,21,,,,,,,,,,,,,,,,,,,,,,,,,,,,24,,,,23,,,,,,,,,,,,,,,,,,,,,,,,24,,23,,21,,,,]],[[1,-1,21,21,33,21,21,33,21,21,33,21,21,33,21,21,33,33,21,21,33,21,21,33,21,21,33,21,21,33,21,21,33,33,21,21,33,21,21,33,21,21,33,21,21,33,21,21,33,33,21,21,33,21,21,33,21,21,33,21,21,33,21,21,33,33],[3,1,24,,,,,,,,27,,,,,,,,,,,,,,,,27,,,,24,,,,24,,,,,,,,27,,,,,,,,,,,,,,,,24,,24,,24,,,,],[5,-1,21,,,,,,,,,,,,,,,,,,,,,,,,,,,,24,,,,23,,,,,,,,,,,,,,,,,,,,,,,,24,,23,,21,,,,],[,1,21,,,,,,,,,,,,,,,,,,,,,,,,,,,,24,,,,23,,,,,,,,,,,,,,,,,,,,,,,,24,,23,,21,,,,],[6,1,,,34,34,34,,,,,,34,34,,,,,34,,,,34,34,,,,,34,,,,34,,,,34,34,34,,,,,,34,,,,,,34,34,,,34,34,,,,,,,,,34,34],[4,1,,,,,,,24,,,,,,24,,24,,,,24,,,,24,,,,,,,,,,,,,,,,24,,,,,,24,,24,,,,24,,,,24,,,,,,,,,,]],[[1,-1,21,21,33,21,21,33,21,21,33,21,21,33,21,21,33,33,21,21,33,21,21,33,21,21,33,21,21,33,21,21,33,33,23,23,35,23,23,36,23,23,35,23,23,36,23,23,35,35,23,23,35,23,23,35,23,23,36,23,23,35,23,23,36,36],[5,-1,21,,,19,,,21,,,,,,,,,,21,,,19,,,17,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,],[3,1,24,,,24,,,24,,,,,,,,,,24,,,24,,,24,,,,24.75,24.5,24.26,24.01,24.01,24.01,,,,,25,,,,,,,,25,,,,,,,,25,,,,,,,,25,25,25,25],[4,-1,,,,,,,,,,,,,,,,,,,,,,,,,,,24.75,24.5,24.26,24.01,24.01,24.01,24.01,24,,24,24,,24,24,24,24,,24,24,,24,,24,24,,24,24,,24,24,24,24,,24,24,,24,24],[7,-1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,23,,21,23,,35,,23,,21,23,,35,,35,,23,,21,23,,35,,21,23,,35,,21,23,,,],[6,1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,34,36,34,,33,34,34,36,31,36,34,,31,34,32,,33,36,34,,31,34,34,36,33,36,33,,31,,,]],[[1,-1,21,21,33,21,21,33,21,21,33,21,21,33,21,21,33,33,21,21,33,21,21,33,21,21,33,21,21,33,21,21,33,33,17,17,29,17,17,29,17,17,29,17,17,29,17,17,29,29,17,17,29,17,17,29,17,17,29,17,17,29,17,17,29,29],[4,1,24,24,,24,24,,24,24,24,24,,24,24,,24,,24,24,,24,24,,24,24,24,24,,24,24,,24,24,24,24,,24,24,,24,24,24,,,24,24,,24,,24,24,,24,24,,24,24,24,24,,24,24,,24,24],[7,-1,21,,19,21,,33,,21,,19,21,,33,,33,,21,,19,21,,33,,21,,19,21,,33,,33,,17,,17,17,29,17,17,29,17,,17,17,29,17,17,29,17,,17,17,29,17,17,29,17,,17,17,29,17,17,29],[2,1,,34,34,34,,34,34,34,,34,34,34,,34,34,34,,34,34,34,,34,34,34,,34,34,34,,34,,,,34,34,34,,34,34,34,,34,34,34,,34,34,34,,34,34,34,,34,34,34,,34,34,34,,34,,,],[6,1,,,36,,,,,,36,,36,,,,,,,,36,,,,,,36,,36,,,,,,,,36,,,,,,,,,,,,,,,,36,,,,,,36,,36,,,,,,],[3,1,,,,,25,,,,,,,,25,,,,,,,,25,,,,,,,,25,25,25,25,,,,,25,,,,,25,,,25,,,,,,,,25,,,,,,,,25,25,25,25]],[[1,-1,14,14,26,14,14,26,14,14,26,14,14,26,14,14,26,26,14,14,26,14,14,26,14,14,26,14,14,26,14,14,26,26,17,17,29,17,17,29,17,17,29,17,17,29,17,17,29,29,19,19,31,19,19,31,19,19,31,19,19,31,19,19,31,31],[4,1,24,24,,24,24,,24,24,24,24,,24,24,,24,,24,24,,24,24,,24,24,24,24,,24,24,,24,24,24,24,,24,24,,24,24,24,24,,24,24,,36,,24,24,,24,24,,24,24,24,24,,24,24,,24,24],[7,-1,14,,14,14,26,14,14,26,14,,14,14,26,14,14,26,14,,14,14,26,14,14,26,14,,14,14,26,14,14,26,17,,17,17,29,17,17,29,17,,17,17,29,17,17,29,19,,19,19,31,19,19,31,19,,19,19,31,19,19,31],[2,1,,36,36,36,,36,36,36,,36,36,36,,36,36,36,,36,36,36,,36,36,36,,36,36,36,,36,,,,36,36,36,,36,36,36,,36,36,36,,36,36,36,,36,36,36,,36,36,36,,36,36,36,,36,,,],[3,1,,,,,25,,,,,,,,25,,,,,,,,25,,,,,,,,25,25,25,25,,,,,25,,,,,,,,25,,,,,,,,25,,,,,,,,25,25,25,25],[6,1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,34,,,,,,34,,34,,,,,,,,34,,,,,,34,,34,,,,,,]]],[0,1,1,2,3,4,4]]);
|
|
166
171
|
</script>
|
package/examples/style.css
CHANGED
|
@@ -30,22 +30,27 @@ iframe
|
|
|
30
30
|
#selectExample
|
|
31
31
|
{
|
|
32
32
|
flex-grow: 1;
|
|
33
|
+
min-height: 100px;
|
|
34
|
+
}
|
|
35
|
+
#divTextareas
|
|
36
|
+
{
|
|
37
|
+
flex-grow: 1;
|
|
38
|
+
display: flex;
|
|
39
|
+
flex-direction: column;
|
|
40
|
+
min-height: 300px;
|
|
33
41
|
}
|
|
34
42
|
.CodeMirror,
|
|
35
43
|
#textareaCode
|
|
36
44
|
{
|
|
37
45
|
flex-grow: 1;
|
|
38
|
-
padding: 5px;
|
|
39
46
|
resize: none;
|
|
40
47
|
color: #fff;
|
|
41
48
|
background: #000;
|
|
42
|
-
font-size: 20px;
|
|
43
49
|
}
|
|
44
50
|
#textareaConsole,
|
|
45
51
|
#textareaError
|
|
46
52
|
{
|
|
47
53
|
flex-grow: .3;
|
|
48
|
-
padding: 5px;
|
|
49
54
|
resize: none;
|
|
50
55
|
display: none;
|
|
51
56
|
color:#f22;
|
|
@@ -79,9 +84,10 @@ iframe
|
|
|
79
84
|
{
|
|
80
85
|
margin: 0px;
|
|
81
86
|
text-align: center;
|
|
82
|
-
font-size:
|
|
87
|
+
font-size: 15px;
|
|
83
88
|
display: inline-block;
|
|
84
89
|
align-self: center;
|
|
90
|
+
font-style: italic;
|
|
85
91
|
}
|
|
86
92
|
select
|
|
87
93
|
{
|
|
@@ -109,10 +115,17 @@ button:disabled
|
|
|
109
115
|
background-color: #666;
|
|
110
116
|
border-color: #666;
|
|
111
117
|
}
|
|
118
|
+
input[type='checkbox']:disabled
|
|
119
|
+
{
|
|
120
|
+
opacity: 0.5;
|
|
121
|
+
}
|
|
112
122
|
.error-line
|
|
113
123
|
{
|
|
114
|
-
background-color:
|
|
115
|
-
|
|
124
|
+
background-color: #f004 !important;
|
|
125
|
+
}
|
|
126
|
+
.nowrap
|
|
127
|
+
{
|
|
128
|
+
white-space:nowrap;
|
|
116
129
|
}
|
|
117
130
|
|
|
118
131
|
/* LittleJS CodeMirror Theme */
|
|
@@ -27,5 +27,5 @@ child_process.execSync(`npx tsc ${tsFiles} --outDir "./${BUILD_FOLDER}" --target
|
|
|
27
27
|
console.log(`TypeScript built in ${((Date.now() - startTime)/1e3).toFixed(2)} seconds!`);
|
|
28
28
|
|
|
29
29
|
console.log(`Moving js files back to root...`);
|
|
30
|
-
for(const file of jsSourceFiles)
|
|
30
|
+
for (const file of jsSourceFiles)
|
|
31
31
|
fs.copyFileSync(`${BUILD_FOLDER}/${file}`, file);
|
|
@@ -85,8 +85,8 @@ function gameUpdatePost() {
|
|
|
85
85
|
}
|
|
86
86
|
///////////////////////////////////////////////////////////////////////////////
|
|
87
87
|
function gameRender() {
|
|
88
|
-
// draw a grey square in the background
|
|
89
|
-
LJS.drawRect(vec2(16, 8), vec2(20, 14), hsl(0, 0, .6)
|
|
88
|
+
// draw a grey square in the background
|
|
89
|
+
LJS.drawRect(vec2(16, 8), vec2(20, 14), hsl(0, 0, .6));
|
|
90
90
|
// draw the logo as a tile
|
|
91
91
|
LJS.drawTile(vec2(21, 5), vec2(4.5), tile(3, 128));
|
|
92
92
|
}
|
|
@@ -101,7 +101,10 @@ function gameUpdate()
|
|
|
101
101
|
|
|
102
102
|
// move particles to mouse location if on screen
|
|
103
103
|
if (LJS.mousePosScreen.x)
|
|
104
|
+
{
|
|
104
105
|
particleEmitter.pos = LJS.mousePos;
|
|
106
|
+
particleEmitter.velocity = LJS.mouseDelta.scale(.3*LJS.timeDelta);
|
|
107
|
+
}
|
|
105
108
|
}
|
|
106
109
|
|
|
107
110
|
///////////////////////////////////////////////////////////////////////////////
|
|
@@ -113,8 +116,8 @@ function gameUpdatePost()
|
|
|
113
116
|
///////////////////////////////////////////////////////////////////////////////
|
|
114
117
|
function gameRender()
|
|
115
118
|
{
|
|
116
|
-
// draw a grey square in the background
|
|
117
|
-
LJS.drawRect(vec2(16,8), vec2(20,14), hsl(0,0,.6)
|
|
119
|
+
// draw a grey square in the background
|
|
120
|
+
LJS.drawRect(vec2(16,8), vec2(20,14), hsl(0,0,.6));
|
|
118
121
|
|
|
119
122
|
// draw the logo as a tile
|
|
120
123
|
LJS.drawTile(vec2(21,5), vec2(4.5), tile(3,128));
|
|
@@ -23,6 +23,7 @@ function createUI()
|
|
|
23
23
|
{
|
|
24
24
|
LJS.uiSystem.defaultSoundPress = new LJS.Sound([1,0,220]);
|
|
25
25
|
LJS.uiSystem.defaultSoundClick = new LJS.Sound([1,0,440]);
|
|
26
|
+
LJS.uiSystem.defaultCornerRadius = 8;
|
|
26
27
|
|
|
27
28
|
// setup root to attach all ui elements to
|
|
28
29
|
uiRoot = new LJS.UIObject;
|
|
@@ -53,26 +54,26 @@ function createUI()
|
|
|
53
54
|
// example tile image
|
|
54
55
|
const tileTest = new LJS.UITile(vec2(150,-130), vec2(110), tile(3,128))
|
|
55
56
|
uiMenu.addChild(tileTest);
|
|
56
|
-
|
|
57
|
-
// example checkbox
|
|
58
|
-
const checkbox = new LJS.UICheckbox(vec2(-140,-20), vec2(40));
|
|
59
|
-
uiMenu.addChild(checkbox);
|
|
60
|
-
checkbox.onChange = ()=> console.log('Checkbox clicked');
|
|
61
|
-
|
|
62
|
-
// text attached to checkbox
|
|
63
|
-
const checkboxText = new LJS.UIText(vec2(170,0), vec2(300, 40), 'Test Checkbox');
|
|
64
|
-
checkbox.addChild(checkboxText);
|
|
65
|
-
|
|
66
57
|
// example scrollbar
|
|
67
58
|
const scrollbar = new LJS.UIScrollbar(vec2(0,60), vec2(350, 50));
|
|
68
59
|
uiMenu.addChild(scrollbar);
|
|
69
|
-
scrollbar.onChange
|
|
60
|
+
scrollbar.onChange = ()=> scrollbar.text = scrollbar.value.toFixed(2)
|
|
61
|
+
scrollbar.onChange();
|
|
70
62
|
|
|
71
63
|
// example button
|
|
72
64
|
const button1 = new LJS.UIButton(vec2(0,140), vec2(350, 50), 'Test Button');
|
|
73
65
|
uiMenu.addChild(button1);
|
|
74
66
|
button1.onClick = ()=> console.log('Button 1 clicked');
|
|
75
67
|
|
|
68
|
+
// example checkbox
|
|
69
|
+
const checkbox = new LJS.UICheckbox(vec2(-140,-20), vec2(40));
|
|
70
|
+
uiMenu.addChild(checkbox);
|
|
71
|
+
checkbox.onChange = ()=> button1.disabled = checkbox.checked;
|
|
72
|
+
|
|
73
|
+
// text attached to checkbox
|
|
74
|
+
const checkboxText = new LJS.UIText(vec2(170,0), vec2(300, 40), 'Test Checkbox');
|
|
75
|
+
checkbox.addChild(checkboxText);
|
|
76
|
+
|
|
76
77
|
// exit button
|
|
77
78
|
const button2 = new LJS.UIButton(vec2(0,220), vec2(350, 50), 'Exit Menu');
|
|
78
79
|
uiMenu.addChild(button2);
|
|
@@ -110,7 +111,7 @@ function gameRender()
|
|
|
110
111
|
{
|
|
111
112
|
// test game rendering
|
|
112
113
|
LJS.drawRect(vec2(), vec2(1e3), hsl(0,0,.2));
|
|
113
|
-
for(let i=0; i<1e3; ++i)
|
|
114
|
+
for (let i=0; i<1e3; ++i)
|
|
114
115
|
{
|
|
115
116
|
const pos = vec2(30*Math.sin(i+LJS.time/9),20*Math.sin(i*i+LJS.time/9));
|
|
116
117
|
LJS.drawTile(pos, vec2(2), tile(3,128), hsl(i/9,1,.4), LJS.time+i, !(i%2), hsl(i/9,1,.1,0));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "littlejsengine",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.14.2",
|
|
4
4
|
"description": "LittleJS - Tiny and Fast HTML5 Game Engine",
|
|
5
5
|
"main": "dist/littlejs.esm.js",
|
|
6
6
|
"types": "dist/littlejs.d.ts",
|
|
@@ -39,4 +39,4 @@
|
|
|
39
39
|
"typescript": "~5.1.6",
|
|
40
40
|
"uglify-js": "~3.17.4"
|
|
41
41
|
}
|
|
42
|
-
}
|
|
42
|
+
}
|