littlejsengine 1.9.0 → 1.9.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 +7 -7
- package/{build → dist}/littlejs.d.ts +84 -77
- package/{build → dist}/littlejs.esm.js +245 -143
- package/dist/littlejs.esm.min.js +1 -0
- package/{build → dist}/littlejs.js +245 -143
- package/dist/littlejs.min.js +1 -0
- package/{build → dist}/littlejs.release.js +239 -141
- package/examples/breakout/game.js +2 -2
- package/examples/breakout/gameObjects.js +3 -3
- package/examples/breakout/index.html +3 -3
- package/examples/breakoutTutorial/index.html +2 -2
- package/examples/electron/build.js +1 -1
- package/examples/electron/game.js +49 -38
- package/examples/electron/index.html +2 -2
- package/examples/electron/tiles.png +0 -0
- package/examples/empty/index.html +1 -1
- package/examples/js13k/build.js +2 -2
- package/examples/js13k/game.js +10 -9
- package/examples/js13k/index.html +13 -13
- package/examples/js13k/tiles.png +0 -0
- package/examples/module/game.js +45 -41
- package/examples/module/index.html +1 -1
- package/examples/module/tiles.png +0 -0
- package/examples/particles/index.html +1 -1
- package/examples/platformer/data/gameTileData.tmx +143 -0
- package/examples/platformer/data/gameTileData.tsx +4 -0
- package/examples/platformer/game.js +0 -1
- package/examples/platformer/gameCharacter.js +1 -1
- package/examples/platformer/gameEffects.js +42 -110
- package/examples/platformer/gameLevel.js +149 -183
- package/examples/platformer/gameObjects.js +61 -16
- package/examples/platformer/gamePlayer.js +3 -2
- package/examples/platformer/gameTileData.js +181 -0
- package/examples/platformer/index.html +8 -7
- package/examples/platformer/tiles.png +0 -0
- package/examples/platformer/tilesLevel.png +0 -0
- package/examples/puzzle/game.js +12 -12
- package/examples/puzzle/index.html +2 -2
- package/examples/starter/build.js +2 -2
- package/examples/starter/game.js +6 -6
- package/examples/starter/index.html +13 -13
- package/examples/starter/tiles.png +0 -0
- package/examples/stress/index.html +2 -2
- package/examples/typescript/build.bat +4 -1
- package/examples/typescript/game.js +34 -31
- package/examples/typescript/game.ts +40 -36
- package/examples/typescript/index.html +1 -1
- package/examples/typescript/tiles.png +0 -0
- package/package.json +3 -3
- package/src/engine.js +1 -1
- package/src/engineAudio.js +4 -10
- package/src/engineBuild.js +9 -2
- package/src/engineDebug.js +6 -2
- package/src/engineDraw.js +27 -27
- package/src/engineInput.js +7 -7
- package/src/engineMedals.js +2 -2
- package/src/engineObject.js +7 -7
- package/src/engineParticles.js +9 -9
- package/src/engineTileLayer.js +38 -33
- package/src/engineUtilities.js +136 -35
- package/src/engineWebGL.js +8 -10
- package/build/littlejs.esm.min.js +0 -1
- package/build/littlejs.min.js +0 -1
|
@@ -62,8 +62,8 @@ function gameUpdatePost()
|
|
|
62
62
|
function gameRender()
|
|
63
63
|
{
|
|
64
64
|
// draw a the background
|
|
65
|
-
drawRect(cameraPos, levelSize.scale(2),
|
|
66
|
-
drawRect(cameraPos, levelSize,
|
|
65
|
+
drawRect(cameraPos, levelSize.scale(2), hsl(0,0,.5));
|
|
66
|
+
drawRect(cameraPos, levelSize, hsl(0,0,.02));
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
///////////////////////////////////////////////////////////////////////////////
|
|
@@ -13,7 +13,7 @@ class Wall extends EngineObject
|
|
|
13
13
|
|
|
14
14
|
this.mass = 0; // make object have static physics
|
|
15
15
|
this.setCollision(); // make object collide
|
|
16
|
-
this.color =
|
|
16
|
+
this.color = hsl(0,0,0,0); // make object invisible
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
|
|
@@ -60,7 +60,7 @@ class Brick extends EngineObject
|
|
|
60
60
|
|
|
61
61
|
// make explosion effect
|
|
62
62
|
const color1 = this.color;
|
|
63
|
-
const color2 = color1.lerp(
|
|
63
|
+
const color2 = color1.lerp(hsl(), .5);
|
|
64
64
|
new ParticleEmitter(
|
|
65
65
|
this.pos, 0, // pos, angle
|
|
66
66
|
this.size, .1, 200, PI, // emitSize, emitTime, emitRate, emiteCone
|
|
@@ -76,7 +76,7 @@ class Brick extends EngineObject
|
|
|
76
76
|
if (o.trailEffect)
|
|
77
77
|
{
|
|
78
78
|
o.trailEffect.colorStartA = this.color;
|
|
79
|
-
o.trailEffect.colorStartB = this.color.lerp(
|
|
79
|
+
o.trailEffect.colorStartB = this.color.lerp(hsl(), .5);
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
return 1;
|
|
@@ -5,6 +5,6 @@
|
|
|
5
5
|
<link rel=icon type=image/png href=../favicon.png>
|
|
6
6
|
</head><body>
|
|
7
7
|
|
|
8
|
-
<script src=../../
|
|
9
|
-
<script src=gameObjects.js?
|
|
10
|
-
<script src=game.js?
|
|
8
|
+
<script src=../../dist/littlejs.js?192></script>
|
|
9
|
+
<script src=gameObjects.js?192></script>
|
|
10
|
+
<script src=game.js?192></script>
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Little JS Electron
|
|
3
|
-
- A simple starter project
|
|
4
|
-
-
|
|
2
|
+
Little JS Electron Starter Project
|
|
3
|
+
- A simple starter project for LittleJS
|
|
4
|
+
- Demos all the main engine features
|
|
5
|
+
- Builds to an Electron app
|
|
5
6
|
*/
|
|
6
7
|
|
|
7
8
|
'use strict';
|
|
8
9
|
|
|
10
|
+
// show the LittleJS splash screen
|
|
11
|
+
setShowSplashScreen(true);
|
|
12
|
+
|
|
9
13
|
// sound effects
|
|
10
14
|
const sound_click = new Sound([1,.5]);
|
|
11
15
|
|
|
@@ -14,59 +18,61 @@ const medal_example = new Medal(0, 'Example Medal', 'Welcome to LittleJS!');
|
|
|
14
18
|
medalsInit('Hello World');
|
|
15
19
|
|
|
16
20
|
// game variables
|
|
17
|
-
let
|
|
18
|
-
|
|
19
|
-
// show the LittleJS splash screen
|
|
20
|
-
setShowSplashScreen(true);
|
|
21
|
+
let particleEmitter;
|
|
21
22
|
|
|
22
23
|
///////////////////////////////////////////////////////////////////////////////
|
|
23
24
|
function gameInit()
|
|
24
25
|
{
|
|
25
26
|
// create tile collision and visible tile layer
|
|
26
|
-
initTileCollision(vec2(32,
|
|
27
|
+
initTileCollision(vec2(32,16));
|
|
27
28
|
const pos = vec2();
|
|
28
29
|
const tileLayer = new TileLayer(pos, tileCollisionSize);
|
|
29
30
|
|
|
30
31
|
// get level data from the tiles image
|
|
31
|
-
const imageLevelDataRow = 1;
|
|
32
32
|
const tileImage = textureInfos[0].image;
|
|
33
|
-
mainContext.drawImage(tileImage,
|
|
33
|
+
mainContext.drawImage(tileImage,0,0);
|
|
34
|
+
const imageData = mainContext.getImageData(0,0,tileImage.width,tileImage.height).data;
|
|
34
35
|
for (pos.x = tileCollisionSize.x; pos.x--;)
|
|
35
36
|
for (pos.y = tileCollisionSize.y; pos.y--;)
|
|
36
37
|
{
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
38
|
+
// check if this pixel is set
|
|
39
|
+
const i = pos.x + tileImage.width*(15 + tileCollisionSize.y - pos.y);
|
|
40
|
+
if (!imageData[4*i])
|
|
41
|
+
continue;
|
|
42
|
+
|
|
43
|
+
// set tile data
|
|
44
|
+
const tileIndex = 1;
|
|
45
|
+
const direction = randInt(4)
|
|
46
|
+
const mirror = randInt(2);
|
|
47
|
+
const color = randColor();
|
|
48
|
+
const data = new TileLayerData(tileIndex, direction, mirror, color);
|
|
49
|
+
tileLayer.setData(pos, data);
|
|
50
|
+
setTileCollisionData(pos, 1);
|
|
48
51
|
}
|
|
52
|
+
|
|
53
|
+
// draw tile layer with new data
|
|
49
54
|
tileLayer.redraw();
|
|
50
55
|
|
|
51
|
-
//
|
|
52
|
-
cameraPos =
|
|
56
|
+
// setup camera
|
|
57
|
+
cameraPos = vec2(16,8);
|
|
58
|
+
cameraScale = 48;
|
|
53
59
|
|
|
54
60
|
// enable gravity
|
|
55
61
|
gravity = -.01;
|
|
56
62
|
|
|
57
63
|
// create particle emitter
|
|
58
|
-
|
|
59
|
-
vec2(16), 0,
|
|
60
|
-
1, 0, 500, PI,
|
|
61
|
-
tile(0, 16),
|
|
62
|
-
|
|
63
|
-
|
|
64
|
+
particleEmitter = new ParticleEmitter(
|
|
65
|
+
vec2(16,9), 0, // emitPos, emitAngle
|
|
66
|
+
1, 0, 500, PI, // emitSize, emitTime, emitRate, emiteCone
|
|
67
|
+
tile(0, 16), // tileIndex, tileSize
|
|
68
|
+
hsl(1,1,1), hsl(0,0,0), // colorStartA, colorStartB
|
|
69
|
+
hsl(0,0,0,0), hsl(0,0,0,0), // colorEndA, colorEndB
|
|
64
70
|
2, .2, .2, .1, .05, // time, sizeStart, sizeEnd, speed, angleSpeed
|
|
65
71
|
.99, 1, 1, PI, // damping, angleDamping, gravityScale, cone
|
|
66
72
|
.05, .5, 1, 1 // fadeRate, randomness, collide, additive
|
|
67
73
|
);
|
|
68
|
-
|
|
69
|
-
|
|
74
|
+
particleEmitter.elasticity = .3; // bounce when it collides
|
|
75
|
+
particleEmitter.trailScale = 2; // stretch in direction of motion
|
|
70
76
|
}
|
|
71
77
|
|
|
72
78
|
///////////////////////////////////////////////////////////////////////////////
|
|
@@ -78,10 +84,10 @@ function gameUpdate()
|
|
|
78
84
|
sound_click.play(mousePos);
|
|
79
85
|
|
|
80
86
|
// change particle color and set to fade out
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
87
|
+
particleEmitter.colorStartA = hsl();
|
|
88
|
+
particleEmitter.colorStartB = randColor();
|
|
89
|
+
particleEmitter.colorEndA = particleEmitter.colorStartA.scale(1,0);
|
|
90
|
+
particleEmitter.colorEndB = particleEmitter.colorStartB.scale(1,0);
|
|
85
91
|
|
|
86
92
|
// unlock medals
|
|
87
93
|
medal_example.unlock();
|
|
@@ -89,7 +95,7 @@ function gameUpdate()
|
|
|
89
95
|
|
|
90
96
|
// move particles to mouse location if on screen
|
|
91
97
|
if (mousePosScreen.x)
|
|
92
|
-
|
|
98
|
+
particleEmitter.pos = mousePos;
|
|
93
99
|
}
|
|
94
100
|
|
|
95
101
|
///////////////////////////////////////////////////////////////////////////////
|
|
@@ -102,14 +108,19 @@ function gameUpdatePost()
|
|
|
102
108
|
function gameRender()
|
|
103
109
|
{
|
|
104
110
|
// draw a grey square in the background without using webgl
|
|
105
|
-
drawRect(
|
|
111
|
+
drawRect(vec2(16,8), vec2(20,14), hsl(0,0,.6), 0, 0);
|
|
112
|
+
|
|
113
|
+
// draw the logo as a tile
|
|
114
|
+
drawTile(vec2(21,5), vec2(4.5), tile(3,128));
|
|
106
115
|
}
|
|
107
116
|
|
|
108
117
|
///////////////////////////////////////////////////////////////////////////////
|
|
109
118
|
function gameRenderPost()
|
|
110
119
|
{
|
|
111
120
|
// draw to overlay canvas for hud rendering
|
|
112
|
-
drawTextScreen('LittleJS Electron Demo',
|
|
121
|
+
drawTextScreen('LittleJS Electron Demo',
|
|
122
|
+
vec2(mainCanvasSize.x/2, 70), 80, // position, size
|
|
123
|
+
hsl(0,0,1), 6, hsl(0,0,0)); // color, outline size and color
|
|
113
124
|
}
|
|
114
125
|
|
|
115
126
|
///////////////////////////////////////////////////////////////////////////////
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
</head><body>
|
|
7
7
|
|
|
8
8
|
<!-- LittleJS Engine -->
|
|
9
|
-
<script src=../../
|
|
9
|
+
<script src=../../dist/littlejs.js?192></script>
|
|
10
10
|
|
|
11
11
|
<!-- Add your game scripts here -->
|
|
12
|
-
<script src=game.js?
|
|
12
|
+
<script src=game.js?192></script>
|
|
Binary file
|
package/examples/js13k/build.js
CHANGED
|
@@ -10,7 +10,7 @@ const PROGRAM_NAME = 'game';
|
|
|
10
10
|
const BUILD_FOLDER = 'build';
|
|
11
11
|
const sourceFiles =
|
|
12
12
|
[
|
|
13
|
-
'../../
|
|
13
|
+
'../../dist/littlejs.release.js',
|
|
14
14
|
'game.js',
|
|
15
15
|
// add your game's files here
|
|
16
16
|
];
|
|
@@ -26,7 +26,7 @@ const fs = require('node:fs');
|
|
|
26
26
|
const child_process = require('node:child_process');
|
|
27
27
|
|
|
28
28
|
// rebuild engine
|
|
29
|
-
child_process.execSync(`npm run build`, { stdio: 'inherit' });
|
|
29
|
+
//child_process.execSync(`npm run build`, { stdio: 'inherit' });
|
|
30
30
|
|
|
31
31
|
// remove old files and setup build folder
|
|
32
32
|
fs.rmSync(BUILD_FOLDER, { recursive: true, force: true });
|
package/examples/js13k/game.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
LittleJS JS13K Starter Game
|
|
3
3
|
- For size limited projects
|
|
4
|
+
- Includes all core engine features
|
|
4
5
|
- Builds to 7kb zip file
|
|
5
6
|
*/
|
|
6
7
|
|
|
@@ -19,7 +20,7 @@ let particleEmitter;
|
|
|
19
20
|
function gameInit()
|
|
20
21
|
{
|
|
21
22
|
// create tile collision and visible tile layer
|
|
22
|
-
initTileCollision(vec2(32,
|
|
23
|
+
initTileCollision(vec2(32,16));
|
|
23
24
|
const pos = vec2();
|
|
24
25
|
const tileLayer = new TileLayer(pos, tileCollisionSize);
|
|
25
26
|
|
|
@@ -48,19 +49,19 @@ function gameInit()
|
|
|
48
49
|
// draw tile layer with new data
|
|
49
50
|
tileLayer.redraw();
|
|
50
51
|
|
|
51
|
-
//
|
|
52
|
-
cameraPos =
|
|
52
|
+
// setup camera
|
|
53
|
+
cameraPos = vec2(16,8);
|
|
53
54
|
|
|
54
55
|
// enable gravity
|
|
55
56
|
gravity = -.01;
|
|
56
57
|
|
|
57
58
|
// create particle emitter
|
|
58
59
|
particleEmitter = new ParticleEmitter(
|
|
59
|
-
vec2(16), 0,
|
|
60
|
-
1, 0, 500, PI,
|
|
61
|
-
tile(0, 16),
|
|
60
|
+
vec2(16,9), 0, // emitPos, emitAngle
|
|
61
|
+
1, 0, 500, PI, // emitSize, emitTime, emitRate, emiteCone
|
|
62
|
+
tile(0, 16), // tileIndex, tileSize
|
|
62
63
|
new Color(1,1,1), new Color(0,0,0), // colorStartA, colorStartB
|
|
63
|
-
new Color(
|
|
64
|
+
new Color(0,0,0,0), new Color(0,0,0,0), // colorEndA, colorEndB
|
|
64
65
|
2, .2, .2, .1, .05, // time, sizeStart, sizeEnd, speed, angleSpeed
|
|
65
66
|
.99, 1, 1, PI, // damping, angleDamping, gravityScale, cone
|
|
66
67
|
.05, .5, 1, 1 // fadeRate, randomness, collide, additive
|
|
@@ -99,14 +100,14 @@ function gameUpdatePost()
|
|
|
99
100
|
function gameRender()
|
|
100
101
|
{
|
|
101
102
|
// draw a grey square in the background without using webgl
|
|
102
|
-
drawRect(
|
|
103
|
+
drawRect(vec2(16,8), vec2(20,14), new Color(.6,.6,.6), 0, 0);
|
|
103
104
|
}
|
|
104
105
|
|
|
105
106
|
///////////////////////////////////////////////////////////////////////////////
|
|
106
107
|
function gameRenderPost()
|
|
107
108
|
{
|
|
108
109
|
// draw to overlay canvas for hud rendering
|
|
109
|
-
drawTextScreen('LittleJS JS13K
|
|
110
|
+
drawTextScreen('LittleJS JS13K Demo', vec2(mainCanvasSize.x/2, 70), 80);
|
|
110
111
|
}
|
|
111
112
|
|
|
112
113
|
///////////////////////////////////////////////////////////////////////////////
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
<head><title>LittleJS JS13K Project</title></head><body>
|
|
2
2
|
|
|
3
3
|
<!-- LittleJS Engine -->
|
|
4
|
-
<script src=../../src/engineDebug.js?
|
|
5
|
-
<script src=../../src/engineUtilities.js?
|
|
6
|
-
<script src=../../src/engineSettings.js?
|
|
7
|
-
<script src=../../src/engineObject.js?
|
|
8
|
-
<script src=../../src/engineDraw.js?
|
|
9
|
-
<script src=../../src/engineInput.js?
|
|
10
|
-
<script src=../../src/engineAudio.js?
|
|
11
|
-
<script src=../../src/engineTileLayer.js?
|
|
12
|
-
<script src=../../src/engineParticles.js?
|
|
13
|
-
<script src=../../src/engineMedals.js?
|
|
14
|
-
<script src=../../src/engineWebGL.js?
|
|
15
|
-
<script src=../../src/engine.js?
|
|
4
|
+
<script src=../../src/engineDebug.js?192></script>
|
|
5
|
+
<script src=../../src/engineUtilities.js?192></script>
|
|
6
|
+
<script src=../../src/engineSettings.js?192></script>
|
|
7
|
+
<script src=../../src/engineObject.js?192></script>
|
|
8
|
+
<script src=../../src/engineDraw.js?192></script>
|
|
9
|
+
<script src=../../src/engineInput.js?192></script>
|
|
10
|
+
<script src=../../src/engineAudio.js?192></script>
|
|
11
|
+
<script src=../../src/engineTileLayer.js?192></script>
|
|
12
|
+
<script src=../../src/engineParticles.js?192></script>
|
|
13
|
+
<script src=../../src/engineMedals.js?192></script>
|
|
14
|
+
<script src=../../src/engineWebGL.js?192></script>
|
|
15
|
+
<script src=../../src/engine.js?192></script>
|
|
16
16
|
|
|
17
17
|
<!-- Add your game scripts here -->
|
|
18
|
-
<script src=game.js?
|
|
18
|
+
<script src=game.js?192></script>
|
package/examples/js13k/tiles.png
CHANGED
|
Binary file
|
package/examples/module/game.js
CHANGED
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
'use strict';
|
|
8
8
|
|
|
9
9
|
// import module
|
|
10
|
-
import * as LittleJS from '../../
|
|
11
|
-
const {Vector2, Color, Timer, vec2,
|
|
10
|
+
import * as LittleJS from '../../dist/littlejs.esm.js';
|
|
11
|
+
const {Vector2, Color, Timer, tile, vec2, hsl, rgb} = LittleJS;
|
|
12
12
|
|
|
13
13
|
// show the LittleJS splash screen
|
|
14
14
|
LittleJS.setShowSplashScreen(true);
|
|
@@ -21,62 +21,63 @@ const medal_example = new LittleJS.Medal(0, 'Example Medal', 'Welcome to LittleJ
|
|
|
21
21
|
LittleJS.medalsInit('Hello World');
|
|
22
22
|
|
|
23
23
|
// game variables
|
|
24
|
-
let
|
|
24
|
+
let particleEmitter;
|
|
25
25
|
|
|
26
26
|
///////////////////////////////////////////////////////////////////////////////
|
|
27
27
|
function gameInit()
|
|
28
28
|
{
|
|
29
29
|
// create tile collision and visible tile layer
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
const
|
|
30
|
+
const tileCollisionSize = vec2(32, 16);
|
|
31
|
+
LittleJS.initTileCollision(tileCollisionSize);
|
|
32
|
+
const pos = vec2();
|
|
33
|
+
const tileLayer = new LittleJS.TileLayer(pos, tileCollisionSize);
|
|
33
34
|
|
|
34
35
|
// get level data from the tiles image
|
|
35
|
-
const imageLevelDataRow = 1;
|
|
36
36
|
const mainContext = LittleJS.mainContext;
|
|
37
37
|
const tileImage = LittleJS.textureInfos[0].image;
|
|
38
38
|
mainContext.drawImage(tileImage, 0, 0);
|
|
39
|
-
|
|
40
|
-
for (pos.
|
|
39
|
+
const imageData = mainContext.getImageData(0,0,tileImage.width,tileImage.height).data;
|
|
40
|
+
for (pos.x = tileCollisionSize.x; pos.x--;)
|
|
41
|
+
for (pos.y = tileCollisionSize.y; pos.y--;)
|
|
41
42
|
{
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
43
|
+
// check if this pixel is set
|
|
44
|
+
const i = pos.x + tileImage.width*(15 + tileCollisionSize.y - pos.y);
|
|
45
|
+
if (!imageData[4*i])
|
|
46
|
+
continue;
|
|
47
|
+
|
|
48
|
+
// set tile data
|
|
49
|
+
const tileIndex = 1;
|
|
50
|
+
const direction = LittleJS.randInt(4)
|
|
51
|
+
const mirror = !LittleJS.randInt(2);
|
|
52
|
+
const color = LittleJS.randColor();
|
|
53
|
+
const data = new LittleJS.TileLayerData(tileIndex, direction, mirror, color);
|
|
54
|
+
tileLayer.setData(pos, data);
|
|
55
|
+
LittleJS.setTileCollisionData(pos, 1);
|
|
53
56
|
}
|
|
57
|
+
|
|
58
|
+
// draw tile layer with new data
|
|
54
59
|
tileLayer.redraw();
|
|
55
60
|
|
|
56
61
|
// move camera to center of collision
|
|
57
|
-
LittleJS.setCameraPos(
|
|
62
|
+
LittleJS.setCameraPos(tileCollisionSize.scale(.5));
|
|
63
|
+
LittleJS.setCameraScale(48);
|
|
58
64
|
|
|
59
65
|
// enable gravity
|
|
60
66
|
LittleJS.setGravity(-.01);
|
|
61
67
|
|
|
62
68
|
// create particle emitter
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
new Color(1,1,1,0), new Color(0,0,0,0), // colorEndA, colorEndB
|
|
69
|
+
particleEmitter = new LittleJS.ParticleEmitter(
|
|
70
|
+
vec2(16,9), 0, // emitPos, emitAngle
|
|
71
|
+
1, 0, 500, Math.PI, // emitSize, emitTime, emitRate, emiteCone
|
|
72
|
+
tile(0, 16), // tileIndex, tileSize
|
|
73
|
+
hsl(1,1,1), hsl(0,0,0), // colorStartA, colorStartB
|
|
74
|
+
hsl(0,0,0,0), hsl(0,0,0,0), // colorEndA, colorEndB
|
|
70
75
|
2, .2, .2, .1, .05, // time, sizeStart, sizeEnd, speed, angleSpeed
|
|
71
76
|
.99, 1, 1, Math.PI, // damping, angleDamping, gravityScale, cone
|
|
72
|
-
.05, .5,
|
|
77
|
+
.05, .5, true, true // fadeRate, randomness, collide, additive
|
|
73
78
|
);
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
// start the game timer
|
|
78
|
-
gameTimer = new Timer;
|
|
79
|
-
gameTimer.set();
|
|
79
|
+
particleEmitter.elasticity = .3; // bounce when it collides
|
|
80
|
+
particleEmitter.trailScale = 2; // stretch in direction of motion
|
|
80
81
|
}
|
|
81
82
|
|
|
82
83
|
///////////////////////////////////////////////////////////////////////////////
|
|
@@ -88,10 +89,10 @@ function gameUpdate()
|
|
|
88
89
|
sound_click.play(LittleJS.mousePos);
|
|
89
90
|
|
|
90
91
|
// change particle color and set to fade out
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
92
|
+
particleEmitter.colorStartA = hsl();
|
|
93
|
+
particleEmitter.colorStartB = LittleJS.randColor();
|
|
94
|
+
particleEmitter.colorEndA = particleEmitter.colorStartA.scale(1,0);
|
|
95
|
+
particleEmitter.colorEndB = particleEmitter.colorStartB.scale(1,0);
|
|
95
96
|
|
|
96
97
|
// unlock medals
|
|
97
98
|
medal_example.unlock();
|
|
@@ -99,7 +100,7 @@ function gameUpdate()
|
|
|
99
100
|
|
|
100
101
|
// move particles to mouse location if on screen
|
|
101
102
|
if (LittleJS.mousePosScreen.x)
|
|
102
|
-
|
|
103
|
+
particleEmitter.pos = LittleJS.mousePos;
|
|
103
104
|
}
|
|
104
105
|
|
|
105
106
|
///////////////////////////////////////////////////////////////////////////////
|
|
@@ -112,7 +113,10 @@ function gameUpdatePost()
|
|
|
112
113
|
function gameRender()
|
|
113
114
|
{
|
|
114
115
|
// draw a grey square in the background without using webgl
|
|
115
|
-
LittleJS.drawRect(
|
|
116
|
+
LittleJS.drawRect(vec2(16,8), vec2(20,14), hsl(0,0,.6), 0, false);
|
|
117
|
+
|
|
118
|
+
// draw the logo as a tile
|
|
119
|
+
LittleJS.drawTile(vec2(21,5), vec2(4.5), tile(3,128));
|
|
116
120
|
}
|
|
117
121
|
|
|
118
122
|
///////////////////////////////////////////////////////////////////////////////
|
|
Binary file
|