classlib.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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 laser(id,w,h,col,sp)
  23. {
  24. this.id = id;
  25. this.w = w;
  26. this.h = h;
  27. this.color = col;
  28. this.speed = sp;
  29. };
  30. function star(id, x, y, size, speed, dir, colour)
  31. {
  32. this.id = id;
  33. this.x = x;
  34. this.y = y;
  35. this.size = size;
  36. this.basesize = size;
  37. this.speed = speed;
  38. this.basespeed = speed;
  39. this.direction = dir;
  40. this.colour = colour;
  41. };
  42. function textsprite(id, x, y, txt, s)
  43. {
  44. this.id = id;
  45. this.x = x;
  46. this.y = y;
  47. this.text = txt;
  48. this.speed = s;
  49. this.ticks = 10; // ticks before removal
  50. this.visible = false;
  51. };
  52. function sprite(id, nameid, spritesheet, x, y, speed, direction, visible)
  53. {
  54. this.id = id;
  55. this.nid = nameid;
  56. this.spritesheet = spritesheet;
  57. this.frame = 0; this.startframe = 0;
  58. this.framedelay = spritesheet.framedelay;
  59. this.framedelaymax = spritesheet.framedelay;
  60. this.x = x;
  61. this.y = y;
  62. this.oldx = x;
  63. this.oldy = y;
  64. this.basex = x;
  65. this.basey = y;
  66. this.targetx = -1;
  67. this.targety = -1;
  68. this.w = spritesheet.framewidth;
  69. this.h = spritesheet.frameheight;
  70. this.speed = speed;
  71. this.basespeed = speed;
  72. this.direction = direction;
  73. this.lastdirection = direction;
  74. this.offset = 0;
  75. this.frame = 0;
  76. this.row = 0; // row index
  77. this.visible = visible > 0 ? true : false;
  78. this.moveup = false;
  79. this.movedown = false;
  80. this.moveleft = false;
  81. this.moveright = false;
  82. this.angle = 0;
  83. this.opacity = 1;
  84. this.decay = 0;
  85. this.dying = false;
  86. this.spinning = 0;
  87. this.dead = false;
  88. this.inpain = false;
  89. this.boosting = 0;
  90. this.jumping = false;
  91. this.nextthink = 1;
  92. this.basenextthink = this.nextthink;
  93. };