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.

Vec2.js 449B

123456789101112131415161718192021222324252627282930313233
  1. let meter = 32;
  2. export default class Vec2 {
  3. constructor(x = 0, y = 0) {
  4. this.x = x;
  5. this.y = y;
  6. }
  7. set(x, y) {
  8. this.x = x;
  9. this.y = y;
  10. }
  11. clone() {
  12. return new Vec2(this.x, this.y);
  13. }
  14. get pixelX() {
  15. return Math.floor(this.x * meter);
  16. }
  17. set pixelX(x) {
  18. this.x = Math.floor(x) / meter;
  19. }
  20. get pixelY() {
  21. return Math.floor(this.y * meter);
  22. }
  23. set pixelY(y) {
  24. this.y = Math.floor(y) / meter;
  25. }
  26. }
  27. Vec2.zero = new Vec2();