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

feat: Replaces the broad phase collision detection, introduces a new renderer and has numerous optimizations #456

Merged
merged 16 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Fix tiled, replace foreach
  • Loading branch information
mflerackers committed Oct 1, 2024
commit fa74f0ecb17f48eeb3a357f515240b40a1c0c23b
8 changes: 6 additions & 2 deletions src/game/make.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,14 +174,18 @@ export function make<T>(comps: CompList<T> = []): GameObj<MakeType<T>> {
throw new Error(`Invalid mask func: "${this.mask}"`);
}
maskFunc(() => {
children.forEach((child) => child.draw());
for (let i = 0; i < children.length; i++) {
children[i].draw();
}
}, () => {
this.trigger("draw");
});
}
else {
this.trigger("draw");
children.forEach((child) => child.draw());
for (let i = 0; i < children.length; i++) {
children[i].draw();
}
}
popTransform();
gfx.fixed = f;
Expand Down
20 changes: 10 additions & 10 deletions src/gfx/draw/drawTexture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ export function drawTexture(opt: DrawTextureOpt) {

if (opt.tiled) {
const offset = anchorPt(opt.anchor || DEF_ANCHOR);
offset.x = (offset.x + 1) * 0.5 * (opt.width || w);
offset.y = (offset.y + 1) * 0.5 * (opt.height || h);
const offsetX = (offset.x + 1) * 0.5 * (opt.width || w);
const offsetY = (offset.y + 1) * 0.5 * (opt.height || h);

const fcols = (opt.width || w) / w;
const frows = (opt.height || h) / h;
Expand Down Expand Up @@ -59,35 +59,35 @@ export function drawTexture(opt: DrawTextureOpt) {
indices[index * 6 + 5] = index * 4 + 3;

let s = index * 4;
attributes.pos[s * 2] = x - offset.x;
attributes.pos[s * 2 + 1] = y - offset.y;
attributes.pos[s * 2] = x - offsetX;
attributes.pos[s * 2 + 1] = y - offsetY;
attributes.uv[s * 2] = q.x;
attributes.uv[s * 2 + 1] = q.y;
attributes.color[s * 3] = color.r;
attributes.color[s * 3 + 1] = color.g;
attributes.color[s * 3 + 2] = color.b;
attributes.opacity[s] = opacity;
s++;
attributes.pos[s * 2] = x + w - offset.x;
attributes.pos[s * 2 + 1] = y - offset.y;
attributes.pos[s * 2] = x + w - offsetX;
attributes.pos[s * 2 + 1] = y - offsetY;
attributes.uv[s * 2] = q.x + q.w;
attributes.uv[s * 2 + 1] = q.y;
attributes.color[s * 3] = color.r;
attributes.color[s * 3 + 1] = color.g;
attributes.color[s * 3 + 2] = color.b;
attributes.opacity[s] = opacity;
s++;
attributes.pos[s * 2] = x + w - offset.x;
attributes.pos[s * 2 + 1] = y + h - offset.y;
attributes.pos[s * 2] = x + w - offsetX;
attributes.pos[s * 2 + 1] = y + h - offsetY;
attributes.uv[s * 2] = q.x + q.w;
attributes.uv[s * 2 + 1] = q.y + q.h;
attributes.color[s * 3] = color.r;
attributes.color[s * 3 + 1] = color.g;
attributes.color[s * 3 + 2] = color.b;
attributes.opacity[s] = opacity;
s++;
attributes.pos[s * 2] = x - offset.x;
attributes.pos[s * 2 + 1] = y + h - offset.y;
attributes.pos[s * 2] = x - offsetX;
attributes.pos[s * 2 + 1] = y + h - offsetY;
attributes.uv[s * 2] = q.x;
attributes.uv[s * 2 + 1] = q.y + q.h;
attributes.color[s * 3] = color.r;
Expand Down