PageRenderTime 54ms CodeModel.GetById 0ms RepoModel.GetById 1ms app.codeStats 0ms

/game/engine/actors/enemies/EnemyHobo.as

https://bitbucket.org/charliehoey/gatsby
ActionScript | 62 lines | 50 code | 12 blank | 0 comment | 6 complexity | 255915397411c822dac2cffa60a403d0 MD5 | raw file
  1. package engine.actors.enemies {
  2. import engine.actors.enemies.EnemyWalker;
  3. import engine.ISubject;
  4. import engine.IObserver;
  5. import engine.actors.geoms.*;
  6. public class EnemyHobo extends EnemyWalker {
  7. override public function setup() {
  8. points = 500;
  9. collide_left = 10; // what pixel do we collide on on the left
  10. collide_right = 22; // what pixel do we collide on on the right
  11. collide_left_ground = 10; // what pixel do we collide on on the left
  12. collide_right_ground = 22; // what pixel do we collide on on the right
  13. myName = "EnemyHobo"; // the generic name of our enemy
  14. mySkin = "HoboSkin"; // the name of the skin for this enemy
  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 = 10; // 5 replaced // how many frames should go by before we advance
  23. goingLeft = true;
  24. velx *= -1;
  25. frameDelay = 0;
  26. }
  27. override public function update():void {
  28. if(HP) {
  29. if(stuckTo) {
  30. depart(stuckTo);
  31. this.y += -gravity;
  32. vely = -jumpVelocity;
  33. setLoop(0, 1, 0, 0, 0, 2);
  34. }
  35. moveMe();
  36. checkDeath();
  37. if(deadFlag) {
  38. if(this.y > 240) {
  39. myMap.removeFromMap(this);
  40. } else {
  41. setLoop(0, 2, 2, 2, 0);
  42. this.y += 2;
  43. }
  44. }
  45. } else {
  46. killMe();
  47. }
  48. }
  49. }
  50. }