Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: format all files and fix test #564

Merged
merged 1 commit into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 33 additions & 30 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -1,40 +1,41 @@
![KAPLAY](/kaplay.webp)

# KAPLAY Code of Conduct

Based on the [![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.0-4baaaa.svg)](https://www.contributor-covenant.org/version/2/0/code_of_conduct.html)
Based on the
[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.0-4baaaa.svg)](https://www.contributor-covenant.org/version/2/0/code_of_conduct.html)

## Our Pledge

We as members, contributors, and leaders pledge to make participation in our
community a harassment-free experience for everyone.

We pledge to act and interact in ways that contribute to an open,
welcoming, and healthy community.
We pledge to act and interact in ways that contribute to an open, welcoming, and
healthy community.

## Our Standards

Examples of behavior that contributes to a positive environment for our
community include:

* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes,
- Demonstrating empathy and kindness toward other people
- Being respectful of differing opinions, viewpoints, and experiences
- Giving and gracefully accepting constructive feedback
- Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
* Focusing on what is best not just for us as individuals, but for the
overall community
- Focusing on what is best not just for us as individuals, but for the overall
community

Examples of unacceptable behavior include:

* The use of sexualized language or imagery, and sexual attention or
advances of any kind
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email
address, without their explicit permission, accidents such as
using personal email in a co-author is allowed, but try to avoid
that from happening
* Other conduct which could reasonably be considered inappropriate in a
- The use of sexualized language or imagery, and sexual attention or advances of
any kind
- Trolling, insulting or derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or email address,
without their explicit permission, accidents such as using personal email in a
co-author is allowed, but try to avoid that from happening
- Other conduct which could reasonably be considered inappropriate in a
professional setting

## Enforcement Responsibilities
Expand All @@ -53,16 +54,17 @@ decisions when appropriate.

This Code of Conduct applies within all community spaces, and also applies when
an individual is officially representing the community in public spaces.
Examples of representing our community include using an official e-mail address that ends with @kaplayjs.com,
posting via an official social media account, talking in discord, or acting as an appointed
representative at an online or offline event.
Examples of representing our community include using an official e-mail address
that ends with @kaplayjs.com, posting via an official social media account,
talking in discord, or acting as an appointed representative at an online or
offline event.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at
[email protected], or #support in the Discord,
All complaints will be reviewed and investigated promptly and fairly.
[email protected], or #support in the Discord, All complaints will be
reviewed and investigated promptly and fairly.

All community leaders are obligated to respect the privacy and security of the
reporter of any incident.
Expand All @@ -83,8 +85,8 @@ behavior was inappropriate. A public apology may be requested.

### 2. Warning

**Community Impact**: A violation through a single incident or series
of actions.
**Community Impact**: A violation through a single incident or series of
actions.

**Consequence**: A warning with consequences for continued behavior. No
interaction with the people involved, including unsolicited interaction with
Expand All @@ -110,19 +112,20 @@ Violating these terms may lead to a permanent ban.
standards, including sustained inappropriate behavior, harassment of an
individual, spamming messages on any of our platforms, or scamming other users.

**Consequence**: A permanent ban from any sort of public interaction within
the community.
**Consequence**: A permanent ban from any sort of public interaction within the
community.

**Important**: We dont give this punishment regularly,
this is only used in extreme circumstances.
**Important**: We dont give this punishment regularly, this is only used in
extreme circumstances.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 2.0, available at
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.

Community Impact Guidelines were inspired by [Mozilla's code of conduct
Community Impact Guidelines were inspired by
[Mozilla's code of conduct
enforcement ladder](https://github.com/mozilla/diversity).

[homepage]: https://www.contributor-covenant.org
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,15 @@ Collections of games made with KAPLAY (and Kaboom), selected by KAPLAY:
- [Newgrounds.com](https://www.newgrounds.com/playlist/379920/kaplay-games)

## Credits

- Thanks to [tga](https://space55.xyz) for all his work on the original
Kaboom.js
- Thanks to [mulfok](https://twitter.com/MulfoK) for the awesome
[mulfok32](https://lospec.com/palette-list/mulfok32) color palette, used in
KAPLAY sprites and art
- Thanks to [Pixabay](https://pixabay.com/users/pixabay-1/) for the great [burp](https://pixabay.com/sound-effects/burp-104984/) sound, used in `burp()` function
- Thanks to [Pixabay](https://pixabay.com/users/pixabay-1/) for the great
[burp](https://pixabay.com/sound-effects/burp-104984/) sound, used in `burp()`
function
- Thansk to [Kenney](https://kenney.nl/) for all used assets for examples
- [Impact Sound Pack](https://kenney.nl/assets/impact-sounds)
- [1-Bit Platformer Pack](https://kenney.nl/assets/1-bit-platformer-pack)
Expand Down
12 changes: 8 additions & 4 deletions examples/animation.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,14 @@ rotatingBean.animate("angle", [0, 360], {

onClick(() => {
rotatingBean.animation.seek(0);
})
});

rotatingBean.onAnimateChannelFinished(name => { debug.log(`${name} finished`) })
rotatingBean.onAnimateFinished(() => { debug.log(`All finished`) })
rotatingBean.onAnimateChannelFinished(name => {
debug.log(`${name} finished`);
});
rotatingBean.onAnimateFinished(() => {
debug.log(`All finished`);
});

// Now we'll move this bean from left to right
const movingBean = add([
Expand All @@ -48,7 +52,7 @@ movingBean.animate("pos", [vec2(50, 150), vec2(150, 150)], {

onClick(() => {
movingBean.animation.paused = !movingBean.animation.paused;
})
});

// Same animation as before, but relative to the spawn position
const secondMovingBean = add([
Expand Down
4 changes: 2 additions & 2 deletions examples/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ add([

bean.onUse(id => {
debug.log(`Component ${id} added`);
})
});

bean.onUnuse(id => {
debug.log(`Component ${id} removed`);
})
});
38 changes: 23 additions & 15 deletions examples/fastLoop.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,20 @@ loadBean();
const interval = 0.001;
const delay = 1;

loop(interval, () => {
const bean = add([
sprite("bean"),
pos(rand(vec2(0), vec2(width(), height()))),
]);
wait(delay, () => {
destroy(bean);
});
}, -1, true);
loop(
interval,
() => {
const bean = add([
sprite("bean"),
pos(rand(vec2(0), vec2(width(), height()))),
]);
wait(delay, () => {
destroy(bean);
});
},
-1,
true,
);

const counter = add([
pos(10, 10),
Expand All @@ -31,14 +36,17 @@ add([
update() {
this.width = counter.width;
this.height = counter.height;
}
}
])
},
},
]);

var beanCount = 0;
onAdd(() => beanCount++);
onDestroy(() => beanCount--);
loop(0.1, () => {
const error = 100 * Math.abs((delay / interval) - beanCount) / (delay / interval);
counter.text = `${beanCount.toFixed().padStart(5)} beans\nerror: ${error.toFixed(2).padStart(5)}%`;
});
const error = 100 * Math.abs((delay / interval) - beanCount)
/ (delay / interval);
counter.text = `${beanCount.toFixed().padStart(5)} beans\nerror: ${
error.toFixed(2).padStart(5)
}%`;
});
8 changes: 4 additions & 4 deletions examples/livequery.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ loop(5, () => {
area(),
timer(),
color(WHITE),
"touchable"
"touchable",
]);
ghost.wait(5, () => {
ghost.unuse("area");
Expand All @@ -25,8 +25,8 @@ loop(5, () => {
ghost.use(area());
ghost.tag("touchable");
ghost.use(color(WHITE));
})
})
});
});
}
});

Expand All @@ -36,4 +36,4 @@ onClick("touchable", (ghost) => {

loop(1, () => {
debug.log(`There are ${q.length} touchable ghosts`);
});
});
8 changes: 4 additions & 4 deletions examples/particletrail.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ onLoad(() => {
rate: 5,
direction: -90,
spread: 2,
})
])
}),
]);

onMouseMove((pos, delta) => {
trail.emitter.position = pos;
trail.emit(1);
})
})
});
});
4 changes: 2 additions & 2 deletions examples/tiled.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ add([

add([
circle(4),
pos(150, 150)
])
pos(150, 150),
]);

// debug.inspect = true
10 changes: 6 additions & 4 deletions scripts/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import { build } from "./lib/build.js";
import { wait } from "./lib/util.js";

const exampleCI = JSON.parse(
(await fs.readFile(
new URL("../examples/ciTest.json", import.meta.url),
)).toString(),
(
await fs.readFile(new URL("../examples/ciTest.json", import.meta.url))
).toString(),
);

await build();
Expand All @@ -19,7 +19,9 @@ const server = serve({ port: port });

let failed = false;
console.log("launching browser");
const browser = await puppeteer.launch();
const browser = await puppeteer.launch({
args: ["--no-sandbox"],
});
console.log("getting examples list");
let examples;

Expand Down
5 changes: 4 additions & 1 deletion src/assets/shader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,10 @@ export function loadShader(
vert?: string,
frag?: string,
) {
return _k.assets.shaders.addLoaded(name, makeShader(_k.gfx.ggl, vert, frag));
return _k.assets.shaders.addLoaded(
name,
makeShader(_k.gfx.ggl, vert, frag),
);
}

export function loadShaderURL(
Expand Down
10 changes: 6 additions & 4 deletions src/components/draw/particles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export interface ParticlesComp extends Comp {
* Relative direction of the emitter
*/
direction: number;
}
};
/**
* Emit a number of particles
*/
Expand Down Expand Up @@ -237,9 +237,11 @@ export function particles(popt: ParticlesOpt, eopt: EmitterOpt): ParticlesComp {
dampingRange[1],
);
const lt = lifetime ? rand(lifetime[0], lifetime[1]) : null;
const pos = this.emitter.position.add(eopt.shape
? eopt.shape.random()
: vec2());
const pos = this.emitter.position.add(
eopt.shape
? eopt.shape.random()
: vec2(),
);

const p = particles[index];
p.t = 0;
Expand Down
3 changes: 2 additions & 1 deletion src/components/misc/textInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ export function textInput(
charEv = _k.k.onCharInput((character) => {
if (
this.hasFocus
&& (!maxInputLength || this.typedText.length < maxInputLength)
&& (!maxInputLength
|| this.typedText.length < maxInputLength)
) {
if (_k.k.isKeyDown("shift")) {
this.typedText += character.toUpperCase();
Expand Down
Loading
Loading