PageRenderTime 1128ms CodeModel.GetById 26ms RepoModel.GetById 1ms app.codeStats 0ms

/game/engine/actors/weapons/TrashProjectile.as

https://bitbucket.org/charliehoey/gatsby
ActionScript | 58 lines | 46 code | 11 blank | 1 comment | 2 complexity | 01003f1c6c909451a921d5cbe4158bf5 MD5 | raw file
  1. package engine.actors.weapons{
  2. import engine.actors.weapons.Projectile
  3. import engine.actors.player.Hero;
  4. public class TrashProjectile extends Projectile {
  5. public function TrashProjectile(owner) {
  6. super(owner);
  7. }
  8. override public function setup() {
  9. myName = "TrashProjectile";
  10. mySkin = "TrashSkin";
  11. tilesWide = 1;
  12. tilesTall = 1;
  13. collide_left = 4; // what pixel do we collide on on the left
  14. collide_right = 12; // what pixel do we collide on on the right
  15. startFrame = 0; // the first frame to loop on
  16. endFrame = 1; // the final frame in the row
  17. nowFrame = 0; // current frame in row
  18. loopFrame = 0; // frame at which to loop
  19. loopType = 0; // 0 loops, 1 bounces
  20. loopRow = 0; // which row are we on
  21. loopDir = 1; // loop forward (to the right) by default
  22. speed = 5; // how many frames should go by before we advance
  23. startLifeTimer();
  24. animate();
  25. }
  26. override public function moveMe() {
  27. // this will get overwritten later, if necessary
  28. }
  29. override public function notify(subject):void {
  30. if(subject is Hero) {
  31. if(checkCollision(subject)) {
  32. subject.receiveDamage(this);
  33. frameCount = frameDelay;
  34. }
  35. }
  36. }
  37. override public function update():void {
  38. moveMe();
  39. velx = mySpeed * vecx;
  40. vely = mySpeed * vecy;
  41. this.x += velx;
  42. this.y += vely;
  43. notifyObservers();
  44. animate();
  45. }
  46. }//end class
  47. }//end package