Skip to content

Commit

Permalink
update engine
Browse files Browse the repository at this point in the history
  • Loading branch information
luizbills committed May 7, 2024
1 parent a06453a commit 9cf4bdb
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 14 deletions.
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 25 additions & 2 deletions public/about.html
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ <h1>LITECANVAS</h1>
<a href="#settings">Configuration</a> | <a href="#drawing">Drawing</a> |
<a href="#sound">Sound</a> | <a href="#math">Math</a> |
<a href="#globals">Globals</a> |
<a href="#plugin-api">Plugin API</a> |
<a href="#advanced">Advanced</a>
</nav>

Expand Down Expand Up @@ -346,13 +347,17 @@ <h2><a id="math">Math</a></h2>
chance(p: number): boolean

// Choose a random item from a Array
choose(arr: Array): any
choose(arr: Array<T>): T

// Calculates a linear (interpolation) value over `t`.
// example: lerp(0, 50, 0.5) returns 25
// learn more: https://gamedev.net/tutorials/programming/general-and-gameplay-programming/a-brief-introduction-to-lerp-r4954/
lerp(a: number, b: number, t: number): number

// Interpolate between 2 values.
// Optionally, takes a custom periodic function (default = `Math.sin`).
wave(lower, higher, t, fn = Math.sin): number

// Convert degrees to radians
deg2rad(n: number): number

Expand Down Expand Up @@ -445,7 +450,7 @@ <h2><a id="math">Math</a></h2>
// all arguments are required and must be numbers
colcirc(x1, y1, r1, x2, y2, r2): boolean</code></pre>

<h2><a id="globals">Globals Variables</a></h2>
<h2><a id="globals">Variables</a></h2>

<pre><code class="language-typescript">// the game canvas
CANVAS: HTMLCanvasElement
Expand All @@ -465,6 +470,9 @@ <h2><a id="globals">Globals Variables</a></h2>
// the FPS meter
FPS: number

// the fixed delta time
DT: number

// the amount of time since the game started
ELAPSED: number

Expand All @@ -487,6 +495,21 @@ <h2><a id="globals">Globals Variables</a></h2>

HALF_PI: number // approximately 1.57079 radians (90º)</code></pre>

<h2><a id="plugin-api">Plugin API</a></h2>

<pre><code class="language-typescript">// create or update variables
setvar(name: string, value: any): void

// get the color value
getcolor(index: number): string

// add a game loop listener
// returns a function that removes the listener
listen(event: string, callback: function, highPriority = false): function

// call all listeners of a specific game loop event
emit(event, ...args): void</code></pre>

<h2><a id="advanced">Advanced Features</a></h2>

<pre><code class="language-typescript">// the plugin "Asset Loader" is automatically loaded into the playground
Expand Down
2 changes: 1 addition & 1 deletion public/app.js

Large diffs are not rendered by default.

Loading

0 comments on commit 9cf4bdb

Please sign in to comment.