/pocjs/gui/RubbleSprite.js

http://github.com/sbober/pocjs · JavaScript · 33 lines · 28 code · 5 blank · 0 comment · 2 complexity · 42931f11bee42bd89ec494630133a0b1 MD5 · raw file

  1. dojo.provide("pocjs.gui.RubbleSprite");
  2. dojo.declare("pocjs.gui.RubbleSprite", pocjs.gui.Sprite, {
  3. xa: null, ya: null, za: null,
  4. "-chains-": {constructor: "manual"},
  5. constructor: function() {
  6. this.inherited(arguments, [ Math.random() - 0.5,
  7. Math.random() * 0.8,
  8. Math.random() - 0.5,
  9. 2, 0x555555
  10. ]);
  11. this.xa = Math.random() - 0.5;
  12. this.ya = Math.random();
  13. this.za = Math.random() - 0.5;
  14. },
  15. tick: function() {
  16. this.x += this.xa * 0.03;
  17. this.y += this.ya * 0.03;
  18. this.z += this.za * 0.03;
  19. this.ya -= 0.1;
  20. if (this.y < 0) {
  21. this.y = 0;
  22. this.xa *= 0.8;
  23. this.za *= 0.8;
  24. if (Math.random() < 0.04)
  25. this.removed = true;
  26. }
  27. }
  28. });