littlejsengine 1.11.2 → 1.11.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.
- package/.vscode/launch.json +14 -0
- package/README.md +14 -20
- package/dist/littlejs.d.ts +41 -30
- package/dist/littlejs.esm.js +145 -141
- package/dist/littlejs.esm.min.js +1 -1
- package/dist/littlejs.js +141 -140
- package/dist/littlejs.min.js +1 -1
- package/dist/littlejs.release.js +138 -133
- package/examples/box2d/gameObjects.js +4 -4
- package/examples/box2d/scenes.js +2 -2
- package/examples/breakout/gameObjects.js +2 -2
- package/examples/breakoutTutorial/game.js +1 -1
- package/examples/index.html +1 -7
- package/examples/logo.png +0 -0
- package/examples/module/game.js +1 -1
- package/examples/platformer/game.js +2 -2
- package/examples/platformer/gameCharacter.js +5 -5
- package/examples/platformer/gameEffects.js +4 -4
- package/examples/platformer/gameObjects.js +2 -2
- package/examples/puzzle/game.js +2 -2
- package/examples/starter/game.js +10 -44
- package/examples/starter/tiles.png +0 -0
- package/jsconfig.json +1 -0
- package/package.json +1 -1
- package/plugins/box2d.js +10 -10
- package/plugins/newgrounds.js +1 -1
- package/src/engine.js +5 -3
- package/src/engineAudio.js +4 -4
- package/src/engineDebug.js +3 -7
- package/src/engineDraw.js +50 -25
- package/src/engineExport.js +4 -1
- package/src/engineInput.js +1 -1
- package/src/engineObject.js +8 -8
- package/src/engineParticles.js +6 -6
- package/src/engineSettings.js +5 -5
- package/src/engineTileLayer.js +2 -2
- package/src/engineUtilities.js +5 -5
- package/src/engineWebGL.js +52 -74
- package/examples/electron/build.js +0 -107
- package/examples/electron/electron.js +0 -43
- package/examples/electron/game.js +0 -131
- package/examples/electron/index.html +0 -13
- package/examples/electron/package.json +0 -22
- package/examples/electron/tiles.png +0 -0
- package/examples/js13k/build.bat +0 -2
- package/examples/js13k/build.js +0 -131
- package/examples/js13k/game.js +0 -118
- package/examples/js13k/index.html +0 -21
- package/examples/js13k/tiles.png +0 -0
- package/examples/typescript/build.bat +0 -5
- package/examples/typescript/build.js +0 -33
- package/examples/typescript/game.js +0 -102
- package/examples/typescript/game.ts +0 -134
- package/examples/typescript/index.html +0 -10
- package/examples/typescript/tiles.png +0 -0
- package/examples/typescript/tsconfig.json +0 -8
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Little JS TypeScript Demo
|
|
3
|
-
- A simple starter project
|
|
4
|
-
- Shows how to use LittleJS with TypeScript
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
'use strict';
|
|
8
|
-
|
|
9
|
-
// import module
|
|
10
|
-
import * as LittleJS from '../../dist/littlejs.esm.js';
|
|
11
|
-
const {tile, vec2, hsl} = LittleJS;
|
|
12
|
-
|
|
13
|
-
// show the LittleJS splash screen
|
|
14
|
-
LittleJS.setShowSplashScreen(true);
|
|
15
|
-
|
|
16
|
-
// fix texture bleeding by shrinking tile slightly
|
|
17
|
-
LittleJS.setTileFixBleedScale(.5);
|
|
18
|
-
|
|
19
|
-
// sound effects
|
|
20
|
-
const sound_click = new LittleJS.Sound([1,.5]);
|
|
21
|
-
|
|
22
|
-
// medals
|
|
23
|
-
const medal_example = new LittleJS.Medal(0, 'Example Medal', 'Welcome to LittleJS!');
|
|
24
|
-
LittleJS.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 tileCollisionSize = vec2(32, 16);
|
|
34
|
-
LittleJS.initTileCollision(tileCollisionSize);
|
|
35
|
-
const pos = vec2();
|
|
36
|
-
const tileLayer = new LittleJS.TileLayer(pos, tileCollisionSize);
|
|
37
|
-
|
|
38
|
-
// get level data from the tiles image
|
|
39
|
-
const mainContext = LittleJS.mainContext;
|
|
40
|
-
const tileImage = LittleJS.textureInfos[0].image;
|
|
41
|
-
mainContext.drawImage(tileImage, 0, 0);
|
|
42
|
-
const imageData = mainContext.getImageData(0,0,tileImage.width,tileImage.height).data;
|
|
43
|
-
for (pos.x = tileCollisionSize.x; pos.x--;)
|
|
44
|
-
for (pos.y = tileCollisionSize.y; pos.y--;)
|
|
45
|
-
{
|
|
46
|
-
// check if this pixel is set
|
|
47
|
-
const i = pos.x + tileImage.width*(15 + tileCollisionSize.y - pos.y);
|
|
48
|
-
if (!imageData[4*i])
|
|
49
|
-
continue;
|
|
50
|
-
|
|
51
|
-
// set tile data
|
|
52
|
-
const tileIndex = 1;
|
|
53
|
-
const direction = LittleJS.randInt(4)
|
|
54
|
-
const mirror = !LittleJS.randInt(2);
|
|
55
|
-
const color = LittleJS.randColor();
|
|
56
|
-
const data = new LittleJS.TileLayerData(tileIndex, direction, mirror, color);
|
|
57
|
-
tileLayer.setData(pos, data);
|
|
58
|
-
LittleJS.setTileCollisionData(pos, 1);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// draw tile layer with new data
|
|
62
|
-
tileLayer.redraw();
|
|
63
|
-
|
|
64
|
-
// move camera to center of collision
|
|
65
|
-
LittleJS.setCameraPos(tileCollisionSize.scale(.5));
|
|
66
|
-
LittleJS.setCameraScale(48);
|
|
67
|
-
|
|
68
|
-
// enable gravity
|
|
69
|
-
LittleJS.setGravity(-.01);
|
|
70
|
-
|
|
71
|
-
// create particle emitter
|
|
72
|
-
particleEmitter = new LittleJS.ParticleEmitter(
|
|
73
|
-
vec2(16,9), 0, // emitPos, emitAngle
|
|
74
|
-
1, 0, 500, Math.PI, // emitSize, emitTime, emitRate, emiteCone
|
|
75
|
-
tile(0, 16), // tileIndex, tileSize
|
|
76
|
-
hsl(1,1,1), hsl(0,0,0), // colorStartA, colorStartB
|
|
77
|
-
hsl(0,0,0,0), hsl(0,0,0,0), // colorEndA, colorEndB
|
|
78
|
-
2, .2, .2, .1, .05, // time, sizeStart, sizeEnd, speed, angleSpeed
|
|
79
|
-
.99, 1, 1, Math.PI, // damping, angleDamping, gravityScale, cone
|
|
80
|
-
.05, .5, true, true // fadeRate, randomness, collide, additive
|
|
81
|
-
);
|
|
82
|
-
particleEmitter.elasticity = .3; // bounce when it collides
|
|
83
|
-
particleEmitter.trailScale = 2; // stretch in direction of motion
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
87
|
-
function gameUpdate()
|
|
88
|
-
{
|
|
89
|
-
if (LittleJS.mouseWasPressed(0))
|
|
90
|
-
{
|
|
91
|
-
// play sound when mouse is pressed
|
|
92
|
-
sound_click.play(LittleJS.mousePos);
|
|
93
|
-
|
|
94
|
-
// change particle color and set to fade out
|
|
95
|
-
particleEmitter.colorStartA = hsl();
|
|
96
|
-
particleEmitter.colorStartB = LittleJS.randColor();
|
|
97
|
-
particleEmitter.colorEndA = particleEmitter.colorStartA.scale(1,0);
|
|
98
|
-
particleEmitter.colorEndB = particleEmitter.colorStartB.scale(1,0);
|
|
99
|
-
|
|
100
|
-
// unlock medals
|
|
101
|
-
medal_example.unlock();
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
// move particles to mouse location if on screen
|
|
105
|
-
if (LittleJS.mousePosScreen.x)
|
|
106
|
-
particleEmitter.pos = LittleJS.mousePos;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
110
|
-
function gameUpdatePost()
|
|
111
|
-
{
|
|
112
|
-
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
116
|
-
function gameRender()
|
|
117
|
-
{
|
|
118
|
-
// draw a grey square in the background without using webgl
|
|
119
|
-
LittleJS.drawRect(vec2(16,8), vec2(20,14), hsl(0,0,.6), 0, false);
|
|
120
|
-
|
|
121
|
-
// draw the logo as a tile
|
|
122
|
-
LittleJS.drawTile(vec2(21,5), vec2(4.5), tile(3,128));
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
126
|
-
function gameRenderPost()
|
|
127
|
-
{
|
|
128
|
-
// draw to overlay canvas for hud rendering
|
|
129
|
-
LittleJS.drawTextScreen('LittleJS with TypeScript', vec2(LittleJS.mainCanvasSize.x/2, 80), 80);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
133
|
-
// Startup LittleJS Engine
|
|
134
|
-
LittleJS.engineInit(gameInit, gameUpdate, gameUpdatePost, gameRender, gameRenderPost, ['tiles.png']);
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html><head>
|
|
2
|
-
<title>LittleJS TypeScript 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?1105 type=module></script>
|
|
Binary file
|