Skip to content

Commit 6544786

Browse files
feat: texture repacking for EVERYTHING!! (#1021)
1 parent 608167d commit 6544786

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+605
-576
lines changed

.vscode/settings.json

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,16 @@
22
"typescript.tsdk": "node_modules/typescript/lib",
33
"typescript.preferences.importModuleSpecifierEnding": "minimal",
44
"typescript.preferences.importModuleSpecifier": "shortest",
5-
"dprint.path": "./node_modules/dprint/dprint"
5+
"dprint.path": "./node_modules/dprint/dprint",
6+
"cSpell.words": [
7+
"anims",
8+
"Bbox",
9+
"gopt",
10+
"kaplay",
11+
"lajbel",
12+
"lerp",
13+
"minver",
14+
"mult",
15+
"verts"
16+
]
617
}

CHANGELOG.md

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,36 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
1212
- [Jump to v3001 changelog](#changelog-for-v3001).
1313

1414
<!--
15+
1516
Hey, KAPLAY Dev, you must changelog here, in unreleased, so later your
1617
best friend, lajbel, can put the correct version name here
18+
19+
Make sure to format each entry like this:
20+
21+
- short description (#PR Number) - @your username
22+
1723
-->
1824

1925
## [unreleased]
2026

27+
### Breaking Changes
28+
29+
- The texture uv coordinates for primitives (solid- or gradient-filled circles,
30+
rectangles, lines, and polygons) have now been changed to (1, 1) instead of
31+
(0, 0), so shaders written for primitives will need to be updated. (#1021) -
32+
@dragoncoder047
33+
- The global `onDraw()` handler's no-tag form now always draws before all game
34+
objects are drawn, **regardless of whether it was attached after game objects
35+
were added** (#977) - @lajbel
36+
- The `LoadFontOpt.filter` option has been **removed** since fonts are now
37+
packed into the same texture as sprites, so only the global filter setting can
38+
change this (#1021) - @dragoncoder047
39+
- The sprite data format has been changed to allow individual frames to be on
40+
different GPU textures. Now `SpriteData.tex` doesn't exist, and
41+
`SpriteData.frames` is a list of `Frame`s instead of a list of `Quad`s. A
42+
`Frame` contains `tex` and `q` (quad) properties that contain that data.
43+
(#1021) - @dragoncoder047
44+
2145
### Added
2246

2347
- Added `tileMode` option to 9-slice sprites with four tiling strategies:
@@ -26,7 +50,7 @@ best friend, lajbel, can put the correct version name here
2650
- Added a `calculate()` method to the internal FPS counters, so advanced users
2751
can access them to create their own FPS monitor (#1010) - @dragoncoder047
2852
- Added Intl.Segmenter-based grapheme splitting for proper Indic language
29-
support, via the `locale` option in `DrawTextOpt (#1013) - @shajidhasan
53+
support, via the `locale` option in `DrawTextOpt` (#1013) - @shajidhasan
3054
- Added topMostOnlyActivate kaplay option. When true, only the topmost object
3155
will receive clicks. This avoids problems in a UI where elements overlap -
3256
@mflerackers
@@ -37,12 +61,17 @@ best friend, lajbel, can put the correct version name here
3761
- Updated the texture packer to use a new packing algorithm which may get more
3862
sprites onto the same texture, improving graphics batching performance
3963
(#1011) - @dragoncoder047
64+
- Updated all sprite and font loading to pack everything in the same texture to
65+
allow it to all batch together, for speed and efficiency (#1021) -
66+
@dragoncoder047
67+
- Added spritesheet repacking, so spritesheet images that contain lots of blank
68+
space don't waste texture memory (#1021) - @dragoncoder047
4069

4170
### Fixed
4271

4372
- Fixed tiled mode drawing of sprites ignoring opacity when it was 0 (#1020) -
4473
@dragoncoder047
45-
- Now, all global events handlers are avaible in scopes, `app.onXXXX` and
74+
- Now, all global events handlers are available in scopes, `app.onXXXX` and
4675
`scene.onXXXX()` (#977) - @lajbel
4776
- Fixed input events attached to paused ancestors not being paused (#1009) -
4877
@amyspark-ng, @dragoncoder047

examples/ai.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const BULLET_SPEED = 800;
2626
const player = add([
2727
sprite("bean"),
2828
pos(80, 80),
29-
area(),
29+
area({ isSensor: true }),
3030
anchor("center"),
3131
]);
3232

@@ -55,7 +55,7 @@ enemy.onStateEnter("attack", async () => {
5555
pos(enemy.pos),
5656
move(dir, BULLET_SPEED),
5757
rect(12, 12),
58-
area(),
58+
area({ isSensor: true }),
5959
offscreen({ destroy: true }),
6060
anchor("center"),
6161
color(BLUE),

examples/analogtriggers.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ scene("main", () => {
4848
add([
4949
pos(rand(vec2(width() - 60, height() - 60))),
5050
sprite("ghosty"),
51-
area(),
51+
area({ isSensor: true }),
5252
color(WHITE),
5353
"ghosty",
5454
]);
@@ -65,7 +65,7 @@ scene("main", () => {
6565
rotate(gun.angle),
6666
move(dir, 1000 * analogValue),
6767
pos(player.pos.add(dir.scale(60))),
68-
area(),
68+
area({ isSensor: true }),
6969
offscreen({ destroy: true }), // Destroy them on offscreen to avoid lag
7070
"bullet",
7171
{

examples/animation.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ rotatingBean.animate("angle", [0, 360], {
3030
loops: 1,
3131
});
3232

33-
onClick(() => {
33+
onMousePress(() => {
3434
rotatingBean.animation.play();
3535
});
3636

@@ -56,7 +56,7 @@ movingBean.animate("pos", [vec2(50, 150), vec2(150, 150)], {
5656
direction: "ping-pong",
5757
});
5858

59-
onClick(() => {
59+
onMousePress(() => {
6060
movingBean.animation.paused = !movingBean.animation.paused;
6161
});
6262

examples/burp.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ add([
2929
]);
3030

3131
// burp() on click / tap for our friends on mobile
32-
onClick(() => burp());
32+
onMousePress(() => burp());

examples/camera.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ scoreCounter.onUpdate(() => {
107107
scoreCounter.text = score.toString();
108108
});
109109

110-
onClick(() => {
110+
onMousePress(() => {
111111
// Use toWorld() to transform a screen-space coordinate (like mousePos()) to
112112
// the world-space coordinate, which has the camera transform applied
113113
addKaboom(toWorld(mousePos()));

examples/collision.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ for (let i = 0; i < 3; i++) {
7373
sprite("ghosty"),
7474
pos(x, y),
7575
// Both objects must have area() component to enable collision detection between
76+
// The isSensor option tells area() to enable collision detection even without body()
7677
area({ isSensor: true }),
7778
"enemy",
7879
]);

examples/component.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,10 @@ const bean = add([
8383
area(),
8484
// Use our component here
8585
funky(),
86-
// Tags are empty components, it's equivalent to a { id: "friend" }
86+
// A string here turns into a tag
8787
"friend",
88-
// Plain objects here are components too and work the same way, except unnamed
88+
// Plain objects here are components too and work the same way,
89+
// except unnamed (which means they can't be removed with unuse())
8990
{
9091
coolness: 100,
9192
friends: [],

examples/confetti.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,12 @@ function addConfetti(opt = {}) {
7070

7171
p.onUpdate(() => {
7272
velY += gravity * dt();
73-
p.pos.x += velX * dt();
74-
p.pos.y += velY * dt();
73+
p.move(velX, velY);
7574
p.angle += velA * dt();
7675
p.opacity -= fade * dt();
7776
velX *= airDrag;
7877
velY *= airDrag;
79-
p.scale.x = wave(-1, 1, time() * spin);
78+
p.scaleTo(wave(-1, 1, time() * spin), p.scale.y);
8079
});
8180
}
8281
}

0 commit comments

Comments
 (0)