feat: explicit collision rotation

This commit is contained in:
cha0s 2024-11-11 23:00:15 -06:00
parent d55c35ca33
commit aaa78c99c5
2 changed files with 6 additions and 1 deletions

View File

@ -237,7 +237,10 @@ export default class Collider extends Component {
this.$$aabb = {x0: Infinity, x1: -Infinity, y0: Infinity, y1: -Infinity};
this.$$aabbs = [];
const {bodies} = this;
const {Direction: {direction = 0} = {}} = ecs.get(this.entity) || {};
let {Direction: {direction = 0} = {}} = ecs.get(this.entity) || {};
if (!this.rotatesCollision) {
direction = 0;
}
for (const body of bodies) {
let x0 = Infinity, x1 = -Infinity, y0 = Infinity, y1 = -Infinity;
for (const point of transform(body.points, {rotation: direction})) {
@ -297,5 +300,6 @@ export default class Collider extends Component {
collisionEndScript: {type: 'script'},
collisionStartScript: {type: 'script'},
isColliding: {defaultValue: 1, type: 'uint8'},
rotatesCollision: {defaultValue: 1, type: 'uint8'},
};
}

View File

@ -13,6 +13,7 @@ export default function createPlayer(id) {
],
},
],
rotatesCollision: 0,
},
Controlled: {},
Direction: {},