You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Platform.js 542B

12345678910111213141516171819202122232425
  1. import Entity from "../Entity.js";
  2. import TPlatform from "../traits/TPlatform.js";
  3. import TCollider from "../traits/TCollider.js";
  4. import TPhysics from "../traits/TPhysics.js";
  5. export default class Platform extends Entity {
  6. constructor(level) {
  7. super(level);
  8. this.bounds.size.set(5, 1);
  9. this.addTrait(new TCollider(this));
  10. this.addTrait(new TPlatform(this));
  11. this.addTrait(new TPhysics(this));
  12. }
  13. update(dt) {
  14. let phys = this.t.physics;
  15. phys.velocity.y -= phys.gravity * dt;
  16. }
  17. draw(ctx) {
  18. this.bounds.draw(ctx);
  19. }
  20. }