action-engine-js 1.0.0
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/LICENSE +45 -0
- package/README.md +348 -0
- package/actionengine/3rdparty/goblin/goblin.js +9609 -0
- package/actionengine/3rdparty/goblin/goblin.min.js +5 -0
- package/actionengine/camera/actioncamera.js +90 -0
- package/actionengine/camera/cameracollisionhandler.js +69 -0
- package/actionengine/character/actioncharacter.js +360 -0
- package/actionengine/character/actioncharacter3D.js +61 -0
- package/actionengine/core/app.js +430 -0
- package/actionengine/debug/basedebugpanel.js +858 -0
- package/actionengine/display/canvasmanager.js +75 -0
- package/actionengine/display/gl/programmanager.js +570 -0
- package/actionengine/display/gl/shaders/lineshader.js +118 -0
- package/actionengine/display/gl/shaders/objectshader.js +1756 -0
- package/actionengine/display/gl/shaders/particleshader.js +43 -0
- package/actionengine/display/gl/shaders/shadowshader.js +319 -0
- package/actionengine/display/gl/shaders/spriteshader.js +100 -0
- package/actionengine/display/gl/shaders/watershader.js +67 -0
- package/actionengine/display/graphics/actionmodel3D.js +191 -0
- package/actionengine/display/graphics/actionsprite3D.js +230 -0
- package/actionengine/display/graphics/lighting/actiondirectionalshadowlight.js +864 -0
- package/actionengine/display/graphics/lighting/actionlight.js +211 -0
- package/actionengine/display/graphics/lighting/actionomnidirectionalshadowlight.js +862 -0
- package/actionengine/display/graphics/lighting/lightingconstants.js +263 -0
- package/actionengine/display/graphics/lighting/lightmanager.js +789 -0
- package/actionengine/display/graphics/renderableobject.js +44 -0
- package/actionengine/display/graphics/renderers/actionrenderer2D.js +341 -0
- package/actionengine/display/graphics/renderers/actionrenderer3D/actionrenderer3D.js +655 -0
- package/actionengine/display/graphics/renderers/actionrenderer3D/canvasmanager3D.js +82 -0
- package/actionengine/display/graphics/renderers/actionrenderer3D/debugrenderer3D.js +493 -0
- package/actionengine/display/graphics/renderers/actionrenderer3D/objectrenderer3D.js +790 -0
- package/actionengine/display/graphics/renderers/actionrenderer3D/spriteRenderer3D.js +266 -0
- package/actionengine/display/graphics/renderers/actionrenderer3D/sunrenderer3D.js +140 -0
- package/actionengine/display/graphics/renderers/actionrenderer3D/waterrenderer3D.js +173 -0
- package/actionengine/display/graphics/renderers/actionrenderer3D/weatherrenderer3D.js +87 -0
- package/actionengine/display/graphics/texture/proceduraltexture.js +192 -0
- package/actionengine/display/graphics/texture/texturemanager.js +242 -0
- package/actionengine/display/graphics/texture/textureregistry.js +177 -0
- package/actionengine/input/actionscrollablearea.js +1405 -0
- package/actionengine/input/inputhandler.js +1647 -0
- package/actionengine/math/geometry/geometrybuilder.js +161 -0
- package/actionengine/math/geometry/glbexporter.js +364 -0
- package/actionengine/math/geometry/glbloader.js +722 -0
- package/actionengine/math/geometry/modelcodegenerator.js +97 -0
- package/actionengine/math/geometry/triangle.js +33 -0
- package/actionengine/math/geometry/triangleutils.js +34 -0
- package/actionengine/math/mathutils.js +25 -0
- package/actionengine/math/matrix4.js +785 -0
- package/actionengine/math/physics/actionphysics.js +108 -0
- package/actionengine/math/physics/actionphysicsobject3D.js +164 -0
- package/actionengine/math/physics/actionphysicsworld3D.js +238 -0
- package/actionengine/math/physics/actionraycast.js +129 -0
- package/actionengine/math/physics/shapes/actionphysicsbox3D.js +158 -0
- package/actionengine/math/physics/shapes/actionphysicscapsule3D.js +200 -0
- package/actionengine/math/physics/shapes/actionphysicscompoundshape3D.js +147 -0
- package/actionengine/math/physics/shapes/actionphysicscone3D.js +126 -0
- package/actionengine/math/physics/shapes/actionphysicsconvexshape3D.js +72 -0
- package/actionengine/math/physics/shapes/actionphysicscylinder3D.js +117 -0
- package/actionengine/math/physics/shapes/actionphysicsmesh3D.js +74 -0
- package/actionengine/math/physics/shapes/actionphysicsplane3D.js +100 -0
- package/actionengine/math/physics/shapes/actionphysicssphere3D.js +95 -0
- package/actionengine/math/quaternion.js +61 -0
- package/actionengine/math/vector2.js +277 -0
- package/actionengine/math/vector3.js +318 -0
- package/actionengine/math/viewfrustum.js +136 -0
- package/actionengine/network/ACTIONNETREADME.md +810 -0
- package/actionengine/network/client/ActionNetManager.js +802 -0
- package/actionengine/network/client/ActionNetManagerGUI.js +1709 -0
- package/actionengine/network/client/ActionNetManagerP2P.js +1537 -0
- package/actionengine/network/client/SyncSystem.js +422 -0
- package/actionengine/network/p2p/ActionNetPeer.js +142 -0
- package/actionengine/network/p2p/ActionNetTrackerClient.js +623 -0
- package/actionengine/network/p2p/DataConnection.js +282 -0
- package/actionengine/network/p2p/README.md +510 -0
- package/actionengine/network/p2p/example.html +502 -0
- package/actionengine/network/server/ActionNetServer.js +577 -0
- package/actionengine/network/server/ActionNetServerSSL.js +579 -0
- package/actionengine/network/server/ActionNetServerUtils.js +458 -0
- package/actionengine/network/server/SERVERREADME.md +314 -0
- package/actionengine/network/server/package-lock.json +35 -0
- package/actionengine/network/server/package.json +13 -0
- package/actionengine/network/server/start.bat +27 -0
- package/actionengine/network/server/start.sh +25 -0
- package/actionengine/network/server/startwss.bat +27 -0
- package/actionengine/sound/audiomanager.js +1589 -0
- package/actionengine/sound/soundfont/ACTIONSOUNDFONT_README.md +205 -0
- package/actionengine/sound/soundfont/actionparser.js +718 -0
- package/actionengine/sound/soundfont/actionreverb.js +252 -0
- package/actionengine/sound/soundfont/actionsoundfont.js +543 -0
- package/actionengine/sound/soundfont/sf2playerlicence.txt +29 -0
- package/actionengine/sound/soundfont/soundfont.js +2 -0
- package/dist/action-engine.min.js +328 -0
- package/package.json +35 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Tomobobo710
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
This project includes GoblinPhysics, licensed under the Zlib License:
|
|
26
|
+
|
|
27
|
+
Copyright (c) 2012 Chandler Prall
|
|
28
|
+
|
|
29
|
+
This software is provided 'as-is', without any express or implied
|
|
30
|
+
warranty. In no event will the authors be held liable for any damages
|
|
31
|
+
arising from the use of this software.
|
|
32
|
+
|
|
33
|
+
Permission is granted to anyone to use this software for any purpose,
|
|
34
|
+
including commercial applications, and to alter it and redistribute it
|
|
35
|
+
freely, subject to the following restrictions:
|
|
36
|
+
|
|
37
|
+
1. The origin of this software must not be misrepresented; you must not
|
|
38
|
+
claim that you wrote the original software. If you use this software
|
|
39
|
+
in a product, an acknowledgment in the product documentation would be
|
|
40
|
+
appreciated but is not required.
|
|
41
|
+
2. Altered source versions must be plainly marked as such, and must not be
|
|
42
|
+
misrepresented as being the original software.
|
|
43
|
+
3. This notice may not be removed or altered from any source distribution.
|
|
44
|
+
|
|
45
|
+
Repository: https://github.com/chandlerprall/GoblinPhysics
|
package/README.md
ADDED
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
# Action Engine JS
|
|
2
|
+
|
|
3
|
+
A comprehensive JavaScript game framework that abstracts away the complexity of game development boilerplate, letting you focus on building your game.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
Action Engine simplifies game creation by handling all the tedious infrastructure—input systems, audio, rendering, physics, and multi-layer canvas management—so you can focus on game logic.
|
|
8
|
+
|
|
9
|
+
### Core Features
|
|
10
|
+
|
|
11
|
+
- **Multi-Layer Canvas System**: Separate game, UI, and debug rendering layers
|
|
12
|
+
- **Built-in Input System**: Keyboard, mouse, and touch input handling
|
|
13
|
+
- **Advanced Audio Engine**: MIDI instruments, FM synthesis, noise generation, reverb, echo, and more
|
|
14
|
+
- **3D Physics & Rendering**: WebGL-based 3D rendering with rigid body physics
|
|
15
|
+
- **Math Utilities**: Vector2, Vector3, and Matrix4 classes
|
|
16
|
+
- **Procedural Geometry**: GeometryBuilder for creating complex 3D objects with automatic triangle winding
|
|
17
|
+
- **Character System**: Ready-to-use character controller with animation states
|
|
18
|
+
- **P2P Networking**: Peer-to-peer multiplayer support with signaling
|
|
19
|
+
|
|
20
|
+
## Quick Start
|
|
21
|
+
|
|
22
|
+
### Create a Game Class
|
|
23
|
+
|
|
24
|
+
```javascript
|
|
25
|
+
class Game {
|
|
26
|
+
static get WIDTH() { return 800; }
|
|
27
|
+
static get HEIGHT() { return 600; }
|
|
28
|
+
|
|
29
|
+
constructor(canvases, input, audio) {
|
|
30
|
+
this.gameCanvas = canvases.gameCanvas;
|
|
31
|
+
this.guiCtx = canvases.guiCtx;
|
|
32
|
+
this.debugCtx = canvases.debugCtx;
|
|
33
|
+
this.input = input;
|
|
34
|
+
this.audio = audio;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
action_update(deltaTime) {
|
|
38
|
+
// Update game logic
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
action_draw() {
|
|
42
|
+
// Render your game
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Canvas Layers
|
|
48
|
+
|
|
49
|
+
Action Engine provides three canvas layers:
|
|
50
|
+
|
|
51
|
+
| Layer | Type | Purpose |
|
|
52
|
+
|-------|------|---------|
|
|
53
|
+
| **gameCanvas** | 2D or WebGL | Main game world (3D physics demo uses WebGL) |
|
|
54
|
+
| **guiCanvas** | 2D | UI overlays (menus, HUD, buttons) |
|
|
55
|
+
| **debugCanvas** | 2D | Debug visualization (toggle with F9) |
|
|
56
|
+
|
|
57
|
+
All canvases use a fixed 800×600 coordinate system with automatic scaling.
|
|
58
|
+
|
|
59
|
+
## Core Systems
|
|
60
|
+
|
|
61
|
+
### Input System
|
|
62
|
+
|
|
63
|
+
```javascript
|
|
64
|
+
// Keyboard
|
|
65
|
+
this.input.isKeyPressed("DirUp") // Arrow keys
|
|
66
|
+
this.input.isKeyPressed("Action1") // Space bar
|
|
67
|
+
this.input.isKeyPressed("F9") // Toggle debug
|
|
68
|
+
|
|
69
|
+
// Mouse
|
|
70
|
+
this.input.getMouseX()
|
|
71
|
+
this.input.getMouseY()
|
|
72
|
+
|
|
73
|
+
// Element detection
|
|
74
|
+
this.input.isElementHovered("debugButton", "debug")
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Audio System
|
|
78
|
+
|
|
79
|
+
#### MIDI Instruments
|
|
80
|
+
|
|
81
|
+
```javascript
|
|
82
|
+
this.audio.createMIDISound("kick", {
|
|
83
|
+
instrument: "acoustic_bass_drum",
|
|
84
|
+
note: 36,
|
|
85
|
+
duration: 0.5,
|
|
86
|
+
velocity: 100
|
|
87
|
+
});
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
#### FM Synthesis
|
|
91
|
+
|
|
92
|
+
```javascript
|
|
93
|
+
this.audio.createFMSound("synthPad", {
|
|
94
|
+
carrierFreq: 440,
|
|
95
|
+
modulatorFreq: 220,
|
|
96
|
+
modulationIndex: 50,
|
|
97
|
+
duration: 1.0,
|
|
98
|
+
envelope: { attack: 0.2, decay: 0.3, sustain: 0.6, release: 0.5 }
|
|
99
|
+
});
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
#### Noise & Effects
|
|
103
|
+
|
|
104
|
+
```javascript
|
|
105
|
+
this.audio.createNoiseSound("wind", {
|
|
106
|
+
noiseType: "pink",
|
|
107
|
+
duration: 2.0,
|
|
108
|
+
filterOptions: { frequency: 800, type: "lowpass" }
|
|
109
|
+
});
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### 3D Physics & Rendering
|
|
113
|
+
|
|
114
|
+
#### Setting Up
|
|
115
|
+
|
|
116
|
+
```javascript
|
|
117
|
+
this.renderer3D = new ActionRenderer3D(this.gameCanvas);
|
|
118
|
+
this.physicsWorld = new ActionPhysicsWorld3D();
|
|
119
|
+
this.camera = new ActionCamera();
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
#### Creating Physics Objects
|
|
123
|
+
|
|
124
|
+
```javascript
|
|
125
|
+
// Box
|
|
126
|
+
const box = this.createBox(5, 5, 5, 1, new Vector3(0, 15, 0), "#FF6B6B");
|
|
127
|
+
|
|
128
|
+
// Sphere
|
|
129
|
+
const sphere = this.createSphere(3, 1, new Vector3(8, 20, 0));
|
|
130
|
+
|
|
131
|
+
// Capsule (height must be > 2 × radius)
|
|
132
|
+
const capsule = this.createCapsule(1.5, 8, 1, new Vector3(-8, 18, 0));
|
|
133
|
+
|
|
134
|
+
// Cone
|
|
135
|
+
const cone = this.createCone(2, 10, 1, new Vector3(0, 15, 0));
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
**Colors**: Pass hex strings like `"#FF6B6B"` or `null` for defaults (box: green, sphere: white, capsule: red, cone: orange).
|
|
139
|
+
|
|
140
|
+
### Procedural Geometry with GeometryBuilder
|
|
141
|
+
|
|
142
|
+
GeometryBuilder automatically handles triangle winding orientation, making complex 3D objects easy to create:
|
|
143
|
+
|
|
144
|
+
```javascript
|
|
145
|
+
const builder = new GeometryBuilder();
|
|
146
|
+
const vertices = [];
|
|
147
|
+
const normals = [];
|
|
148
|
+
const colors = [];
|
|
149
|
+
const indices = [];
|
|
150
|
+
|
|
151
|
+
// Set reference point at geometry center for automatic winding
|
|
152
|
+
builder.setReferencePoint({ x: 0, y: 1, z: 0 });
|
|
153
|
+
|
|
154
|
+
// Add vertices
|
|
155
|
+
vertices.push(0, 0, 0, 1, 1, 1, -1, 1, 0); // x,y,z for each vertex
|
|
156
|
+
|
|
157
|
+
// Create triangles
|
|
158
|
+
builder.createTriangle(indices, vertices, 0, 1, 2);
|
|
159
|
+
builder.createQuad(indices, vertices, 0, 1, 3, 2);
|
|
160
|
+
|
|
161
|
+
// Convert to physics object
|
|
162
|
+
const mesh = builder.createPhysicsObject(
|
|
163
|
+
this.physicsWorld,
|
|
164
|
+
vertices,
|
|
165
|
+
normals,
|
|
166
|
+
colors,
|
|
167
|
+
indices,
|
|
168
|
+
mass,
|
|
169
|
+
position
|
|
170
|
+
);
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
**Key Point**: Set `setReferencePoint()` to the actual center of your geometry for correct automatic winding.
|
|
174
|
+
|
|
175
|
+
### Character System
|
|
176
|
+
|
|
177
|
+
Spawn a playable character with built-in state management:
|
|
178
|
+
|
|
179
|
+
```javascript
|
|
180
|
+
const player = this.spawnCharacter(new Vector3(0, 10, 0));
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
Character has predefined states (idle, walking, jumping, falling) and handles input automatically. Access debug info:
|
|
184
|
+
|
|
185
|
+
```javascript
|
|
186
|
+
console.log(player.debugInfo.state.current); // Current state
|
|
187
|
+
console.log(player.debugInfo.physics.position); // Position vector
|
|
188
|
+
console.log(player.debugInfo.physics.velocity); // Velocity vector
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
### Math Classes
|
|
192
|
+
|
|
193
|
+
```javascript
|
|
194
|
+
// Vector2
|
|
195
|
+
const v = Vector2.create(10, 20);
|
|
196
|
+
const normalized = Vector2.normalize(v);
|
|
197
|
+
const distance = Vector2.distance(v1, v2);
|
|
198
|
+
|
|
199
|
+
// Vector3
|
|
200
|
+
const pos = new Vector3(1, 2, 3);
|
|
201
|
+
const dir = Vector3.normalize(pos);
|
|
202
|
+
|
|
203
|
+
// Matrix4
|
|
204
|
+
const transform = new Matrix4();
|
|
205
|
+
transform.translate(x, y, z);
|
|
206
|
+
transform.rotateX(angle);
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
## Directory Structure
|
|
210
|
+
|
|
211
|
+
```
|
|
212
|
+
ActionEngineJS/
|
|
213
|
+
├── actionengine/ # Core engine code
|
|
214
|
+
│ ├── 3rdparty/ # Third-party libraries
|
|
215
|
+
│ ├── camera/ # Camera system
|
|
216
|
+
│ ├── character/ # Character controller & animations
|
|
217
|
+
│ ├── core/ # Main application loop
|
|
218
|
+
│ ├── debug/ # Debug utilities
|
|
219
|
+
│ ├── display/ # Rendering systems (2D/3D)
|
|
220
|
+
│ ├── input/ # Input handler
|
|
221
|
+
│ ├── math/ # Vector, Matrix utilities
|
|
222
|
+
│ ├── network/ # Networking (client, server, P2P)
|
|
223
|
+
│ └── sound/ # Audio engine
|
|
224
|
+
├── demos/ # Example games
|
|
225
|
+
│ ├── audio/ # Audio synthesis demo (Breakout game)
|
|
226
|
+
│ ├── input/ # Input handling demo (Asteroids game)
|
|
227
|
+
│ └── p2p/ # P2P networking example
|
|
228
|
+
├── docs/ # Documentation
|
|
229
|
+
├── demo.js # Main demo game
|
|
230
|
+
├── game.js # Minimal game template
|
|
231
|
+
├── index.html # Entry point
|
|
232
|
+
└── demo.html # Demo entry point
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
## Networking
|
|
236
|
+
|
|
237
|
+
### P2P (Peer-to-Peer)
|
|
238
|
+
|
|
239
|
+
Connect games directly without a server:
|
|
240
|
+
|
|
241
|
+
```javascript
|
|
242
|
+
const peer = new ActionNetPeer(peerId, trackerUrl);
|
|
243
|
+
peer.connect(otherPeerId);
|
|
244
|
+
peer.on("data", (data) => {
|
|
245
|
+
console.log("Received:", data);
|
|
246
|
+
});
|
|
247
|
+
peer.send(data);
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
### Server-Based
|
|
251
|
+
|
|
252
|
+
Host a central server for client connections:
|
|
253
|
+
|
|
254
|
+
```javascript
|
|
255
|
+
const server = new ActionNetServer(port);
|
|
256
|
+
server.on("client-connect", (client) => {
|
|
257
|
+
client.send({ type: "welcome" });
|
|
258
|
+
});
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
## Common Patterns
|
|
262
|
+
|
|
263
|
+
### Drawing to GUI Layer
|
|
264
|
+
|
|
265
|
+
```javascript
|
|
266
|
+
action_draw() {
|
|
267
|
+
// Draw game world
|
|
268
|
+
this.renderer3D.render({
|
|
269
|
+
renderableObjects: Array.from(this.physicsWorld.objects),
|
|
270
|
+
camera: this.camera
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
// Draw UI on GUI layer
|
|
274
|
+
this.guiCtx.fillStyle = "#fff";
|
|
275
|
+
this.guiCtx.font = "20px Arial";
|
|
276
|
+
this.guiCtx.fillText("Score: 100", 10, 30);
|
|
277
|
+
}
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
### Debug Overlay with F9
|
|
281
|
+
|
|
282
|
+
```javascript
|
|
283
|
+
if (this.showDebug) {
|
|
284
|
+
this.drawDebugLayer();
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
// Toggle with F9 key (handled by input system)
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
### Handling Input
|
|
291
|
+
|
|
292
|
+
```javascript
|
|
293
|
+
action_update(deltaTime) {
|
|
294
|
+
if (this.input.isKeyPressed("DirUp")) {
|
|
295
|
+
// Move up
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
if (this.input.isKeyPressed("Action1")) {
|
|
299
|
+
this.player.jump();
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
### Playing Sounds
|
|
305
|
+
|
|
306
|
+
```javascript
|
|
307
|
+
this.audio.playSound("kick", {
|
|
308
|
+
volume: 0.8,
|
|
309
|
+
repeat: false,
|
|
310
|
+
onComplete: () => {
|
|
311
|
+
console.log("Sound finished");
|
|
312
|
+
}
|
|
313
|
+
});
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
## Tips & Gotchas
|
|
317
|
+
|
|
318
|
+
1. **Fixed Canvas Size**: Always use `Game.WIDTH` and `Game.HEIGHT` (800×600) for positioning—scaling is automatic
|
|
319
|
+
2. **Capsule Height**: Ensure capsule `height > 2 × radius` or physics will error
|
|
320
|
+
3. **Reference Points in GeometryBuilder**: Set the reference point to your geometry's actual center for correct winding
|
|
321
|
+
4. **Color Handling**: Pass `null` to use shape defaults, or use hex strings like `"#FF6B6B"`
|
|
322
|
+
5. **Audio Envelopes**: Use subtle attack/release times (0.01s+) for smooth audio
|
|
323
|
+
6. **Debug Layer Performance**: Toggle debug mode sparingly in production; it adds overhead
|
|
324
|
+
|
|
325
|
+
## Files to Start With
|
|
326
|
+
|
|
327
|
+
- **game.js** - Minimal template for your own game
|
|
328
|
+
- **demo.js** - Full-featured demo showcasing all systems
|
|
329
|
+
- **actionengine/core/app.js** - Main application loop
|
|
330
|
+
- **actionengine/character/** - Character controller implementation
|
|
331
|
+
- **actionengine/display/** - 3D rendering and geometry builders
|
|
332
|
+
|
|
333
|
+
## What's Included
|
|
334
|
+
|
|
335
|
+
- ✅ Fully-featured game loop with fixed/regular updates
|
|
336
|
+
- ✅ Multi-layer canvas rendering
|
|
337
|
+
- ✅ Comprehensive input handling
|
|
338
|
+
- ✅ Advanced audio with synthesis and effects
|
|
339
|
+
- ✅ 3D physics and WebGL rendering
|
|
340
|
+
- ✅ Procedural geometry builder
|
|
341
|
+
- ✅ Character controller with states
|
|
342
|
+
- ✅ P2P and server networking
|
|
343
|
+
- ✅ Math utilities (vectors, matrices)
|
|
344
|
+
- ✅ Debug visualization tools
|
|
345
|
+
|
|
346
|
+
---
|
|
347
|
+
|
|
348
|
+
**Ready to build?** Start with `game.js` as your template, reference `demo.js` for examples, and check the demo app running in your browser!
|