Skip to content

Commit

Permalink
chore: replicate changes of #408
Browse files Browse the repository at this point in the history
  • Loading branch information
lajbel committed Sep 18, 2024
1 parent 2a21da7 commit 59f243c
Show file tree
Hide file tree
Showing 85 changed files with 406 additions and 207 deletions.
147 changes: 79 additions & 68 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
# v4000.0.0 and v3001.0.0
# v4000.0.0

- Replaced the Separating Axis Theorem (SAT) with the Gilbert–Johnson–Keerthi
(GJK) distance algorithm.
- Added circle and (rotated) ellipse collision shapes.
- Added an ellipse component.
- Circle area is no longer a box.
- Added a fake cursor API

This version is a double release, with a lot of new features and breaking
changes. v3001 release are focused in backward compatibility with v3000 with the
features of v4000, while v4000 will have the most features and breaking changes.
```js
const myCursor = add([fakeMouse(), sprite("kat"), pos(100, 100)]);

myCursor.press(); // trigger onClick events if the mouse is over
myCursor.release();
myCursor.move(vec2(100, 200)); // move as your wish
```

# v4000.0.0 and v3001.0.0

## Input

Expand Down Expand Up @@ -187,77 +200,75 @@ obj.scale = vec2(3, 4);
obj.sprite = "bag";
```
- `sprite()` new methods, `getAnim`, `hasAnim`, `getCurAnim()`,
- added `shuffle()` to shuffle an array. (**v3001/4000**)
```js
const obj = add([
sprite("bean"),
]);
```js
const numbers = [1, 2, 3, 4, 5];
shuffle(numbers); // [3, 1, 5, 2, 4]
```
// get the current animation name
debug.log(obj.getCurAnim().name);
// check if an animation exists
debug.log(obj.hasAnim("walk"));
// get the animation data
debug.log(obj.getAnim("walk"));
```
## Debug mode
## Misc
- added `outline()`, `shader()`, and `area()` properties to `debug.inspect`.
- added `KAPLAYOpt.debugKey` for customizing the key used to toggle debug mode.
- (**v3001/4000**) added `loadMusic()` to load streaming audio (doesn't block in
loading screen)
- (**v3001/4000**) added `chooseMultiple()` and `shuffle()` helpers for arrays
- (**v3001/4000**) added `getSceneName()` to get the current scene name
- (**v3001/4000**) added `camFlash()` to flash the screen
- (**v3001/4000**) added `SpriteComp.getCurAnim()` to get the current animation
data
- (**v3001/4000**) added `Color.toArray()` to convert a color to an array
- added `Vec2.toArray()` to convert a vec2 to an array (eg:
player.pos.toArray())
- (**v3001/4000**) added `Vec2.fromArray()` to convert an array to a vec2 (eg:
player.pos = Vec2.fromArray(newPosition))
- (**v3001/4000**) added `outline()`, `shader()`, and `area()` properties to
`debug.inspect` (f1)
- (**v3001/4000**) added `kaboomOpt.debugKey` for customizing the key used to
toggle debug mode
- (**v3001/4000**) added `GameObjRaw.tags` to get a game object's tags
- (**v3001/4000**) added `GameObjRaw<SpriteComp>.sprite` property to get the
name of the sprite
- (**v3001/4000**) added `patrol()` component to move along a list of waypoints
- (**v3001/4000**) added `sentry()` component to notify when certain objects are
in sight
- (**v3001/4000**) added `particles()` component to emit and draw particles
- (**v3001/4000**) added `NavMesh` class for pathfinding on a mesh
- (**v3001/4000**) added `navigation()` component to calculate a list of
waypoints on a graph
- (**v3001/4000**) added `animate()` component to animate the properties of an
object using keyframes
- (**v3001/4000**) added effector components: `areaEffector()`,
`buoyancyEffector()`, `pointEffector()`, `surfaceEffector()`
- (**v3001/4000**) added `constantForce()` component
- (**v3001/4000**) added global raycast function and raycast method to level
- (**v3001/4000**) added support for textured polygons
- (**v3001/4000**) added support for concave polygon drawing
- (**v3001/4000**) added support for arrays in uniforms
- (**v3001/4000**) added support for texture larger than 2048x2048
- (**v3001/4000**) added support for gravity direction
- (**v3001/4000**) added line join (bevel, miter, round) and line caps (square,
round)
- (**v3001/4000**) added quadratic bezier and Catmull-Rom evaluation
- (**v3001/4000**) added evaluation of the first and second derivatives for all
splines
- (**v3001/4000**) added higher order easing functions linear, steps and
cubic-bezier
- (**v3001/4000**) added `textInput()` component
- (**v3001/4000**) now you can see custom properties in debug.inspect
```js
kaplay({
debugKey: "l",
});
```
- added compatibility with custom properties in debug mode
## Bug fixes
```js
const obj = add([
sprite("bean"),
{
health: 100, // on debug.inspect
damage: 10, // on debug.inspect
hp() {
this.health -= this.damage;
}, // not on debug.inspect
},
]);
- **(break)** much typescript definitions was fixed, if you use typescript now
maybe you see new errors that make your code strict
- fix error screen not showing with not Error object
// see the custom properties in debug mode
debug.inspect = true;
```
- Now `debug.log()` accepts multiple argument of any type, like `console.log()`.
## Helpers
- added `getSceneName()` to get the current scene name
- added `Color.toArray()` to convert a color to an array
- added global raycast function and raycast method to level
- added support for textured polygons
- added support for concave polygon drawing
- added support for arrays in uniforms
- added support for texture larger than 2048x2048
- added support for gravity direction
- added line join (bevel, miter, round) and line caps (square, round)
- added quadratic bezier and Catmull-Rom evaluation
- added evaluation of the first and second derivatives for all splines
- added higher order easing functions linear, steps and cubic-bezier
## TypeScript
- Now you can type `get()` with a type parameter and passing component types.
(**v4000**)
```ts
const player = get<BodyComp>("player");
```
- Now `Key` also accepts a string as an acceptable value.
- Now `text()` component doesn't require to pass a string.
- Now `camScale()` and `camPos()` accept only 1 number as parameter.
- Now `shake()` can be called without args.
- Now `loadShader()` and `loadShaderURL()` accepts null for unused parameters.
- Now `RectCompOpt` accepts a array of numbers for `radius`.

## Deprecated
## Deprecations

> All changes applies for both v3001 and v4000

- deprecated `kaboom()` in favor of `kaplay()` (you can still use `kaboom*`)
- deprecated `SpriteComp.curAnim()` in favor of `SpriteComp.getCurAnim().name`
Expand Down
2 changes: 2 additions & 0 deletions examples/add.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// @ts-check

// Adding game objects to screen

// Start a KAPLAY game
Expand Down
2 changes: 2 additions & 0 deletions examples/ai.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// @ts-check

// Use state() component to handle basic AI

// Start kaboom
Expand Down
4 changes: 3 additions & 1 deletion examples/animation.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// @ts-check

// Start kaboom
kaplay();

Expand Down Expand Up @@ -174,7 +176,7 @@ console.log(JSON.stringify(serializeAnimation(curvingBean, "root"), "", 2));

/*onDraw(() => {
drawCurve(t => evaluateCatmullRom(
vec2(200, 400),
vec2(200, 400),\
vec2(250, 500),
vec2(300, 400),
vec2(350, 500), t), { color: RED })
Expand Down
2 changes: 2 additions & 0 deletions examples/audio.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// @ts-check

// audio playback & control

kaplay({
Expand Down
2 changes: 2 additions & 0 deletions examples/bench.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// @ts-config

// bench marking sprite rendering performance

kaplay();
Expand Down
2 changes: 2 additions & 0 deletions examples/binding.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// @ts-check

kaplay({
buttons: {
"jump": {
Expand Down
2 changes: 2 additions & 0 deletions examples/burp.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// @ts-check

// Start the game in burp mode
kaplay({
burp: true,
Expand Down
3 changes: 3 additions & 0 deletions examples/button.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// @ts-check

// Simple Button UI

kaplay({
Expand All @@ -16,6 +18,7 @@ function addButton(txt, p, f) {
scale(1),
anchor("center"),
outline(4),
color(0, 0, 0),
]);

// add a child object that displays the text
Expand Down
8 changes: 6 additions & 2 deletions examples/camera.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// @ts-check

// Adjust camera / viewport

// Start game
Expand Down Expand Up @@ -77,7 +79,8 @@ onKeyDown("right", () => player.move(SPEED, 0));

let score = 0;

// Add a ui layer with fixed() component to make the object not affected by camera
// Add a ui layer with fixed() component to make the object
// not affected by camera
const ui = add([
fixed(),
]);
Expand All @@ -94,6 +97,7 @@ ui.add([
]);

onClick(() => {
// Use toWorld() to transform a screen-space coordinate (like mousePos()) to the world-space coordinate, which has the camera transform applied
// 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: 2 additions & 0 deletions examples/children.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// @ts-check

kaplay();

loadSprite("bean", "/sprites/bean.png");
Expand Down
2 changes: 2 additions & 0 deletions examples/collision.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// @ts-check

// Collision handling

// Start kaboom
Expand Down
1 change: 1 addition & 0 deletions examples/component.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-check
// Custom component

kaplay();
Expand Down
2 changes: 2 additions & 0 deletions examples/concert.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// @ts-check

// bean is holding a concert to celebrate kaboom2000!

kaplay({
Expand Down
6 changes: 4 additions & 2 deletions examples/confetti.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// @ts-check

kaplay();

const DEF_COUNT = 80;
const DEF_GRAVITY = 800;
const DEF_AIR_DRAG = 0.9;
Expand All @@ -9,8 +13,6 @@ const DEF_SPIN = [2, 8];
const DEF_SATURATION = 0.7;
const DEF_LIGHTNESS = 0.6;

kaplay();

add([
text("click for confetti"),
anchor("top"),
Expand Down
2 changes: 2 additions & 0 deletions examples/curves.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// @ts-check

kaplay();

function addPoint(c, ...args) {
Expand Down
2 changes: 2 additions & 0 deletions examples/dialog.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// @ts-check

// Simple dialogues with character avatars

kaplay({
Expand Down
8 changes: 5 additions & 3 deletions examples/doublejump.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// @ts-check

kaplay({
background: [141, 183, 255],
});
Expand Down Expand Up @@ -37,7 +39,7 @@ function spin(speed = 1200) {

scene("game", () => {
const score = add([
text("0", 24),
text("0", { size: 24 }),
pos(24, 24),
{ value: 0 },
]);
Expand Down Expand Up @@ -111,7 +113,7 @@ scene("game", () => {
destroy(c);
play("coin");
score.value += 1;
score.text = score.value;
score.text = score.value.toString();
genCoin(c.idx);
});

Expand Down Expand Up @@ -161,7 +163,7 @@ scene("game", () => {
const timer = add([
anchor("topright"),
pos(width() - 24, 24),
text(timeLeft),
text(timeLeft.toString()),
]);

onUpdate(() => {
Expand Down
2 changes: 2 additions & 0 deletions examples/drag.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// @ts-check

// Drag & drop interaction

kaplay();
Expand Down
3 changes: 3 additions & 0 deletions examples/draw.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// @ts-check

// Kaboom as pure rendering lib (no component / game obj etc.)

kaplay();
Expand Down Expand Up @@ -26,6 +28,7 @@ const py = 160;
const doodles = [];
const trail = [];

/** @type { import("../dist/declaration").Outline } */
const outline = {
width: 4,
color: rgb(0, 0, 0),
Expand Down
2 changes: 2 additions & 0 deletions examples/easing.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// @ts-check

kaplay();

add([
Expand Down
8 changes: 6 additions & 2 deletions examples/eatlove.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// @ts-check

kaplay();

const fruits = [
Expand Down Expand Up @@ -80,7 +82,9 @@ scene("game", () => {
let score = 0;

const scoreLabel = add([
text(score, 32),
text(score.toString(), {
size: 32,
}),
pos(12, 12),
]);

Expand All @@ -89,7 +93,7 @@ scene("game", () => {
addKaboom(player.pos);
score += 1;
destroy(heart);
scoreLabel.text = score;
scoreLabel.text = score.toString();
burp();
shake(12);
});
Expand Down
Loading

0 comments on commit 59f243c

Please sign in to comment.