classlib.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. function spritesheet(s)
  2. {
  3. this.sheet = s;
  4. this.sheetname = s.sheetname;
  5. this.type = s.type;
  6. this.height = s.height;
  7. this.width = s.width;
  8. this.framewidth = s.framewidth;
  9. this.frameheight = s.frameheight;
  10. this.framedelay = s.framedelay;
  11. this.framesperdirection = s.framesperdirection;
  12. this.deathframe = s.deathframe;
  13. this.deathframecount = s.deathframecount;
  14. this.attackframe = s.attackframe;
  15. this.attackframecount = s.attackframecount;
  16. this.painframe = s.painframe;
  17. this.painframecount = s.painframecount;
  18. this.image = new Image();
  19. this.image.setAttribute("id", this.sheetname);
  20. this.image.src = s.src;
  21. };
  22. function star(id, x, y, size, speed, dir, colour)
  23. {
  24. this.id = id;
  25. this.x = x;
  26. this.y = y;
  27. this.size = size;
  28. this.basesize = size;
  29. this.speed = speed;
  30. this.basespeed = speed;
  31. this.direction = dir;
  32. this.colour = colour;
  33. };
  34. function sprite(id, nameid, spritesheet, x, y, speed, direction, visible)
  35. {
  36. this.id = id;
  37. this.nid = nameid;
  38. this.spritesheet = spritesheet;
  39. this.frame = 0; this.startframe = 0;
  40. this.framedelay = spritesheet.framedelay;
  41. this.framedelaymax = spritesheet.framedelay;
  42. this.x = x;
  43. this.y = y;
  44. this.basex = x;
  45. this.basey = y;
  46. this.oldx = x;
  47. this.oldy = y;
  48. this.targetx = -1;
  49. this.targety = -1;
  50. this.w = spritesheet.framewidth;
  51. this.h = spritesheet.frameheight;
  52. this.speed = speed;
  53. this.basespeed = speed;
  54. this.direction = direction;
  55. this.lastdirection = direction;
  56. this.offset = 0;
  57. this.frame = 0;
  58. this.row = 0; // row index
  59. this.visible = visible > 0 ? true : false;
  60. this.moveup = false;
  61. this.movedown = false;
  62. this.moveleft = false;
  63. this.moveright = false;
  64. this.angle = 0;
  65. this.opacity = 1;
  66. this.decay = 0;
  67. this.toggle = 0;
  68. this.dying = 0;
  69. this.dead = false;
  70. this.inpain = 0;
  71. this.nextthink = 1;
  72. this.basenextthink = this.nextthink;
  73. };