Skip to content

Commit

Permalink
chore: big fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
lajbel committed Jan 15, 2025
1 parent fd5fb6d commit ff1b974
Show file tree
Hide file tree
Showing 33 changed files with 605 additions and 546 deletions.
41 changes: 26 additions & 15 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,35 @@
Copyright (c) 2025, KAPLAY Team and contributers

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions.
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions.

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

In addition, the following restrictions apply:

1. The Software and any modifications made to it may not be used for the purpose of training or improving machine learning algorithms,
including but not limited to artificial intelligence, natural language processing, or data mining. This condition applies to any derivatives,
modifications, or updates based on the Software code. Any usage of the Software in an AI-training dataset is considered a breach of this License.
1. The Software and any modifications made to it may not be used for the purpose
of training or improving machine learning algorithms, including but not
limited to artificial intelligence, natural language processing, or data
mining. This condition applies to any derivatives, modifications, or updates
based on the Software code. Any usage of the Software in an AI-training
dataset is considered a breach of this License.

2. The Software may not be included in any dataset used for training or improving machine learning algorithms,
including but not limited to artificial intelligence, natural language processing, or data mining.
2. The Software may not be included in any dataset used for training or
improving machine learning algorithms, including but not limited to
artificial intelligence, natural language processing, or data mining.

3. Any person or organization found to be in violation of these restrictions will be subject to legal action and may be held liable
for any damages resulting from such use.
3. Any person or organization found to be in violation of these restrictions
will be subject to legal action and may be held liable for any damages
resulting from such use.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
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
14 changes: 9 additions & 5 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 Expand Up @@ -149,7 +153,7 @@ timedSquaringBean.animate(
},
);

// We'll move this bean in a curve
// We'll move this bean in a curve
// Using spline interpolation to move according to a smoothened path
const curvingBean = add([
sprite("bean"),
Expand Down
78 changes: 39 additions & 39 deletions examples/binding.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,68 +2,68 @@

// You can set the input bindings for your game!
kaplay({
buttons: {
// Buttons for jumping
"jump": {
// When using a gamepad the button for jumping will be south
gamepad: ["south"],
// When using a keyboard the button will be "up" or "w"
keyboard: ["up", "w"],
// When using a mouse the button will be "left"
mouse: "left",
},
// Buttons for inspecting
"inspect": {
gamepad: "east",
keyboard: "f",
mouse: "right",
},
},
buttons: {
// Buttons for jumping
"jump": {
// When using a gamepad the button for jumping will be south
gamepad: ["south"],
// When using a keyboard the button will be "up" or "w"
keyboard: ["up", "w"],
// When using a mouse the button will be "left"
mouse: "left",
},
// Buttons for inspecting
"inspect": {
gamepad: "east",
keyboard: "f",
mouse: "right",
},
},
});

loadBean()
loadBean();

// Set the gravity acceleration (pixels per second)
setGravity(1600);

// Add player game object
const player = add([
sprite("bean"),
pos(center()),
area(),
// body() component gives the ability to respond to gravity
body(),
sprite("bean"),
pos(center()),
area(),
// body() component gives the ability to respond to gravity
body(),
]);

// Add a platform to hold the player
add([
rect(width(), 48),
outline(4),
area(),
pos(0, height() - 48),
// Give objects a body() component if you don't want other solid objects pass through
body({ isStatic: true }),
rect(width(), 48),
outline(4),
area(),
pos(0, height() - 48),
// Give objects a body() component if you don't want other solid objects pass through
body({ isStatic: true }),
]);

// Adds an object with a text
add([
text("Press jump button", { width: width() / 2 }),
pos(12, 12),
text("Press jump button", { width: width() / 2 }),
pos(12, 12),
]);

// This runs when the button for "jump" is pressed (will be on any input device)
onButtonPress("jump", () => {
// You can get the type of device that the last input was inputted in!
debug.log(getLastInputDeviceType());
// You can get the type of device that the last input was inputted in!
debug.log(getLastInputDeviceType());

// Now we'll check if the player is on the ground to make it jump
if (player.isGrounded()) {
// .jump() is provided by body()
player.jump();
}
// Now we'll check if the player is on the ground to make it jump
if (player.isGrounded()) {
// .jump() is provided by body()
player.jump();
}
});

// When the button for inspecting is pressed we will log in the debug console for our game the text "inspecting"
onButtonDown("inspect", () => {
debug.log("inspecting");
debug.log("inspecting");
});
6 changes: 5 additions & 1 deletion examples/button.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ kaplay({
onUpdate(() => setCursor("default"));

// Function that adds a button to the game with a given text, position and function
function addButton(txt = "start game", p = vec2(200, 100), f = () => debug.log("hello")) {
function addButton(
txt = "start game",
p = vec2(200, 100),
f = () => debug.log("hello"),
) {
// add a parent background object
const btn = add([
rect(240, 80, { radius: 8 }),
Expand Down
2 changes: 1 addition & 1 deletion examples/camera.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,4 @@ onClick(() => {
// Use toWorld() to transform a screen-space coordinate (like mousePos()) to
// the world-space coordinate, which has the camera transform applied
addKaboom(toWorld(mousePos()));
});
});
2 changes: 1 addition & 1 deletion examples/collision.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,4 @@ player.onUpdate(() => {
// Can also be toggled by pressing F1
debug.inspect = true;

// Check out https://kaplayjs.com/doc/AreaComp/ for everything area() provides
// Check out https://kaplayjs.com/doc/AreaComp/ for everything area() provides
Loading

0 comments on commit ff1b974

Please sign in to comment.