1
0

fighters.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563
  1. var PLAYGROUND_WIDTH = 384;
  2. var PLAYGROUND_HEIGHT = 96;
  3. var FIGHTER_STD_WIDTH = 82;
  4. var FIGHTER_EXT_WIDTH = 126;
  5. var FIGHTER_EXT_WIDTH_2 = 136;
  6. var FIGHTER_EXT_WIDTH_3 = 95;
  7. var FIGHTER_EXT_WIDTH_4 = 105;
  8. var FIGHTER_EXT_WIDTH_5 = 86;
  9. var FIGHTER1_POSX = PLAYGROUND_WIDTH / 2 - (FIGHTER_EXT_WIDTH - FIGHTER_STD_WIDTH) / 2 - FIGHTER_STD_WIDTH;
  10. var FIGHTER2_POSX = PLAYGROUND_WIDTH / 2 + (FIGHTER_EXT_WIDTH - FIGHTER_STD_WIDTH) / 2;
  11. var COUNTDOWN_WIDTH = 48;
  12. var COUNTDOWN_POSX = (PLAYGROUND_WIDTH - COUNTDOWN_WIDTH) / 2;
  13. var HEALTH_REFRESH_RATE = 15;
  14. var FIGHTER_HEALTH = 60;
  15. var LOOP_COUNT_REFRESH = 66;
  16. var fighter1 = null;
  17. var fighter2 = null;
  18. var loopCount = 0;
  19. var fighters = new Array();
  20. $(function(){
  21. //Playground Sprites
  22. var background = new $.gameQuery.Animation({imageURL: "images/background.png", offsety: PLAYGROUND_HEIGHT * Math.floor(Math.random()*11)});
  23. $("#playground").playground({height: PLAYGROUND_HEIGHT, width: PLAYGROUND_WIDTH, keyTracker: true});
  24. $.playground().addGroup("background", {width: PLAYGROUND_WIDTH, height: PLAYGROUND_HEIGHT})
  25. .addSprite( "background1",
  26. {posx: 0, posy: 0,
  27. height: PLAYGROUND_HEIGHT, width: PLAYGROUND_WIDTH,
  28. animation: background})
  29. .end()
  30. .addGroup("fighters", {width: PLAYGROUND_WIDTH, height: PLAYGROUND_HEIGHT})
  31. .end()
  32. .addGroup( "hud", {width: PLAYGROUND_WIDTH, height: PLAYGROUND_HEIGHT})
  33. .end();
  34. $("#hud").append("<div id='countdown'><div id='subSeconds'></div></div>");
  35. $("#hud").append("<div id='step_title'></div>");
  36. $.playground().registerCallback(function(){
  37. if( fighter1 )
  38. updateHealth( $("#player1_health_level"), fighter1.health / fighter1.maxHealth );
  39. if( fighter2 ) {
  40. updateHealth( $("#player2_health_level"), fighter2.health / fighter2.maxHealth );
  41. //$("#player2_health_level").css( "margin-left", ( 100 - (fighter2.health / fighter2.maxHealth) * 100) );
  42. }
  43. loopCount++;
  44. if( loopCount == LOOP_COUNT_REFRESH ) {
  45. loopCount = 0;
  46. var fighter = fighters[ "fighter1" ];
  47. if( fighter && fighter.isIdle() ) {
  48. fighter.node.width( FIGHTER_STD_WIDTH );
  49. fighter.node.x( FIGHTER1_POSX );
  50. }
  51. fighter = fighters[ "fighter2" ];
  52. if( fighter && fighter.isIdle() ) {
  53. fighter.node.width( FIGHTER_STD_WIDTH );
  54. fighter.node.x( FIGHTER2_POSX );
  55. }
  56. }
  57. }, HEALTH_REFRESH_RATE);
  58. $.playground().startGame( function() {});
  59. addFighter = function( fighter) {
  60. $("#fighters").addSprite("fighter1", {animation: fighter.animations["idle"], posx:FIGHTER1_POSX, posy: 15, width: FIGHTER_STD_WIDTH, height: FIGHTER_STD_WIDTH});
  61. fighter.node = $("#fighter1");
  62. fighter1 = fighter;
  63. fighters[ "fighter1" ] = fighter;
  64. };
  65. addFighter2 = function( fighter ) {
  66. $("#fighters").addSprite("fighter2", {animation: fighter.animations["idle"], posx:FIGHTER2_POSX, posy: 15, width: FIGHTER_STD_WIDTH, height: FIGHTER_STD_WIDTH});
  67. fighter.node = $("#fighter2");
  68. $("#fighter2").fliph(true);
  69. fighter2 = fighter;
  70. fighters[ "fighter2" ] = fighter;
  71. };
  72. addScoreBoard = function() {
  73. $("#hud").append("<div id='scoreboard' class='scoreboard'><div class='subScoreboard'></div></div>");
  74. };
  75. addHealthBars = function() {
  76. $("#hud").append("<div id='player1_health' style='left: 10px;' class='health_bar'><div id='player1_health_level' class='health_level good'></div></div>");
  77. $("#hud").append("<div id='player2_health' style='left: " + (PLAYGROUND_WIDTH - 100 - 10) + "px;'class='health_bar'><div id='player2_health_level' class='health_level good reverse'></div></div>");
  78. };
  79. updateHealth = function( HTMLDiv, health ) {
  80. HTMLDiv.removeClass();
  81. HTMLDiv.addClass("health_level");
  82. if( health > 2/3)
  83. HTMLDiv.addClass("good");
  84. else if( health > 1/3)
  85. HTMLDiv.addClass("middle");
  86. else
  87. HTMLDiv.addClass("bad");
  88. HTMLDiv.width( (health * 100) + "%" );
  89. };
  90. display_text = function( text, divId = "#step_title", offset = 1, changePosition = true ) {
  91. var message = text.toLowerCase();
  92. var divHTML = $(divId);
  93. var html = "";
  94. var yPos = offset * 16;
  95. for( var i = 0; i < message.length; i++ ) {
  96. var letter = message[i];
  97. var x = ((97 - message.charCodeAt(i)) * 16);
  98. if( letter == " " )
  99. html += "<div class='blank'></div>";
  100. else if( letter == "!" )
  101. html += "<div class='clock' style='background-position: -416px -" + yPos + "px'></div>";
  102. else
  103. html += "<div class='clock' style='background-position: " + x + "px -" + yPos + "px'></div>";
  104. }
  105. divHTML.empty();
  106. divHTML.width( (text.length * 16) + "px");
  107. if( changePosition ) {
  108. divHTML.css( "margin-left", "-" + (text.length * 8) + "px");
  109. }
  110. divHTML.append( html );
  111. };
  112. hide_text = function() {
  113. $("#step_title").empty();
  114. };
  115. });
  116. //Game objects:
  117. function Fighter(){
  118. this.node = null;
  119. this.animations = new Array();
  120. this.maxHealth = FIGHTER_HEALTH;
  121. this.health = FIGHTER_HEALTH;
  122. this.idle_state = false;
  123. this.isIdle = function() {
  124. return this.idle_state;
  125. };
  126. this.setIdle = function( state ) {
  127. this.idle_state = state;
  128. };
  129. this.start = function() {
  130. this.node.setAnimation(this.animations["start"],
  131. function(node) {
  132. fighters[ node.id ].idle();
  133. });
  134. };
  135. this.idle = function() {
  136. this.node.setAnimation(this.animations["idle"]);
  137. this.setIdle( true );
  138. };
  139. this.punch = function() {
  140. if( !this.isIdle() )
  141. return;
  142. this.setIdle( false );
  143. this.node.setAnimation(this.animations["punch"],
  144. function(node) {
  145. fighters[ node.id ].idle();
  146. });
  147. };
  148. this.kick = function() {
  149. if( !this.isIdle() )
  150. return;
  151. this.setIdle( false );
  152. this.node.setAnimation(this.animations["kick"],
  153. function(node) {
  154. fighters[ node.id ].idle();
  155. });
  156. };
  157. this.special = function() {};
  158. this.victory = function() {
  159. if( !this.isIdle() )
  160. return;
  161. this.setIdle( false );
  162. this.node.setAnimation(this.animations["victory"]);
  163. };
  164. this.loose = function() {
  165. if( !this.isIdle() )
  166. return;
  167. this.setIdle( false );
  168. this.node.setAnimation(this.animations["loose"]);
  169. };
  170. this.ouch = function() {
  171. if( !this.isIdle() )
  172. return;
  173. this.setIdle( false );
  174. this.node.setAnimation(this.animations["ouch"],
  175. function(node) {
  176. fighters[ node.id ].idle();
  177. });
  178. };
  179. this.laught = function() {
  180. if( !this.isIdle() )
  181. return;
  182. this.setIdle( false );
  183. this.node.setAnimation(this.animations["laught"],
  184. function(node) {
  185. fighters[ node.id ].idle();
  186. });
  187. };
  188. };
  189. function Ryu(){
  190. this.animations["start"] = new $.gameQuery.Animation({imageURL: "images/ryu.png", numberOfFrame: 8, offsety: 0, delta: FIGHTER_STD_WIDTH, rate: 150, type: $.gameQuery.ANIMATION_HORIZONTAL | $.gameQuery.ANIMATION_ONCE | $.gameQuery.ANIMATION_CALLBACK});
  191. this.animations["victory"] = new $.gameQuery.Animation({imageURL: "images/ryu.png", numberOfFrame: 7, offsety: 82, delta: FIGHTER_STD_WIDTH, rate: 150, type: $.gameQuery.ANIMATION_HORIZONTAL | $.gameQuery.ANIMATION_ONCE | $.gameQuery.ANIMATION_CALLBACK});
  192. this.animations["victory2"] = new $.gameQuery.Animation({imageURL: "images/ryu.png", numberOfFrame: 4, offsety: 82, offsetx: 246, delta: FIGHTER_STD_WIDTH, rate: 200, type: $.gameQuery.ANIMATION_HORIZONTAL | $.gameQuery.ANIMATION_ONCE | $.gameQuery.ANIMATION_CALLBACK});
  193. this.animations["idle"] = new $.gameQuery.Animation({imageURL: "images/ryu.png", numberOfFrame: 6, offsety: 164, delta: FIGHTER_STD_WIDTH, rate: 150, type: $.gameQuery.ANIMATION_HORIZONTAL});
  194. this.animations["punch"] = new $.gameQuery.Animation({imageURL: "images/ryu.png", numberOfFrame: 6, offsety: 246, delta: FIGHTER_EXT_WIDTH, rate: 150, type: $.gameQuery.ANIMATION_HORIZONTAL | $.gameQuery.ANIMATION_ONCE | $.gameQuery.ANIMATION_CALLBACK});
  195. this.animations["kick"] = new $.gameQuery.Animation({imageURL: "images/ryu.png", numberOfFrame: 7, offsety: 328, delta: FIGHTER_EXT_WIDTH_2, rate: 150, type: $.gameQuery.ANIMATION_HORIZONTAL | $.gameQuery.ANIMATION_ONCE | $.gameQuery.ANIMATION_CALLBACK});
  196. this.animations["ouch"] = new $.gameQuery.Animation({imageURL: "images/ryu.png", numberOfFrame: 4, offsety: 410, delta: FIGHTER_STD_WIDTH, rate: 150, type: $.gameQuery.ANIMATION_HORIZONTAL | $.gameQuery.ANIMATION_ONCE | $.gameQuery.ANIMATION_CALLBACK});
  197. this.animations["laught"] = new $.gameQuery.Animation({imageURL: "images/ryu.png", numberOfFrame: 7, offsety: 492, delta: FIGHTER_EXT_WIDTH_3, rate: 150, type: $.gameQuery.ANIMATION_HORIZONTAL | $.gameQuery.ANIMATION_ONCE | $.gameQuery.ANIMATION_CALLBACK});
  198. this.animations["loose"] = new $.gameQuery.Animation({imageURL: "images/ryu.png", numberOfFrame: 9, offsety: 574, delta: FIGHTER_EXT_WIDTH_4, rate: 150, type: $.gameQuery.ANIMATION_HORIZONTAL | $.gameQuery.ANIMATION_ONCE | $.gameQuery.ANIMATION_CALLBACK});
  199. this.animations["loose2"] = new $.gameQuery.Animation({imageURL: "images/ryu.png", numberOfFrame: 6, offsety: 656, delta: FIGHTER_EXT_WIDTH_4, rate: 150, type: $.gameQuery.ANIMATION_HORIZONTAL | $.gameQuery.ANIMATION_ONCE});
  200. };
  201. Ryu.prototype = new Fighter();
  202. Ryu.prototype.punch = function() {
  203. this.node.width( FIGHTER_EXT_WIDTH );
  204. if( this.node.fliph() ) {
  205. this.node.x( -(FIGHTER_EXT_WIDTH - FIGHTER_STD_WIDTH), true);
  206. }
  207. this.node.setAnimation(this.animations["punch"],
  208. function(node) {
  209. var HTMLnode = fighters[ node.id ].node;
  210. HTMLnode.width( FIGHTER_STD_WIDTH );
  211. if( HTMLnode.fliph() ) {
  212. HTMLnode.x(FIGHTER_EXT_WIDTH - FIGHTER_STD_WIDTH, true);
  213. }
  214. fighters[ node.id ].idle();
  215. });
  216. }
  217. Ryu.prototype.kick = function() {
  218. if( !this.isIdle() )
  219. return;
  220. this.setIdle( false );
  221. this.node.width( FIGHTER_EXT_WIDTH_2 );
  222. if( this.node.fliph() ) {
  223. this.node.x( -(FIGHTER_EXT_WIDTH_2 - FIGHTER_STD_WIDTH), true);
  224. }
  225. this.node.setAnimation(this.animations["kick"],
  226. function(node) {
  227. var HTMLnode = fighters[ node.id ].node;
  228. HTMLnode.width( FIGHTER_STD_WIDTH );
  229. if( HTMLnode.fliph() ) {
  230. HTMLnode.x( FIGHTER_EXT_WIDTH_2 - FIGHTER_STD_WIDTH, true);
  231. }
  232. fighters[ node.id ].idle();
  233. });
  234. }
  235. Ryu.prototype.laught = function() {
  236. if( !this.isIdle() )
  237. return;
  238. this.setIdle( false );
  239. this.node.width( FIGHTER_EXT_WIDTH_3 );
  240. if( this.node.fliph() ) {
  241. this.node.x( -(FIGHTER_EXT_WIDTH_3 - FIGHTER_STD_WIDTH),true);
  242. }
  243. this.node.setAnimation(this.animations["laught"],
  244. function(node) {
  245. var HTMLnode = fighters[ node.id ].node;
  246. HTMLnode.width( FIGHTER_STD_WIDTH );
  247. if( HTMLnode.fliph() ) {
  248. HTMLnode.x(FIGHTER_EXT_WIDTH_3 - FIGHTER_STD_WIDTH, true);
  249. }
  250. fighters[ node.id ].idle();
  251. });
  252. }
  253. Ryu.prototype.loose = function() {
  254. if( !this.isIdle() )
  255. return;
  256. this.setIdle( false );
  257. this.node.width( FIGHTER_EXT_WIDTH_4 );
  258. if( this.node.fliph() ) {
  259. this.node.x( -(FIGHTER_EXT_WIDTH_4 - FIGHTER_STD_WIDTH), true);
  260. }
  261. this.node.setAnimation(this.animations["loose"],
  262. function(node) {
  263. fighters[ node.id ].node.setAnimation(fighters[ node.id ].animations["loose2"]);
  264. });
  265. }
  266. Ryu.prototype.victory = function() {
  267. if( !this.isIdle() )
  268. return;
  269. this.setIdle( false );
  270. this.node.setAnimation(this.animations["victory"],
  271. function(node) {
  272. fighters[ node.id ].node.setAnimation(fighters[ node.id ].animations["victory2"]);
  273. });
  274. }
  275. function Sakura(){
  276. this.animations["start"] = new $.gameQuery.Animation({imageURL: "images/sakura.png", numberOfFrame: 9, offsety: 334, delta: FIGHTER_EXT_WIDTH_3, rate: 150, type: $.gameQuery.ANIMATION_HORIZONTAL | $.gameQuery.ANIMATION_ONCE | $.gameQuery.ANIMATION_CALLBACK});
  277. this.animations["victory"] = new $.gameQuery.Animation({imageURL: "images/sakura.png", numberOfFrame: 7, offsety: 82, delta: FIGHTER_EXT_WIDTH_5, rate: 150, type: $.gameQuery.ANIMATION_HORIZONTAL | $.gameQuery.ANIMATION_ONCE | $.gameQuery.ANIMATION_CALLBACK});
  278. this.animations["victory2"] = new $.gameQuery.Animation({imageURL: "images/sakura.png", numberOfFrame: 4, offsety: 82, offsetx: 258, delta: FIGHTER_EXT_WIDTH_5, rate: 200, type: $.gameQuery.ANIMATION_HORIZONTAL | $.gameQuery.ANIMATION_ONCE | $.gameQuery.ANIMATION_CALLBACK});
  279. this.animations["idle"] = new $.gameQuery.Animation({imageURL: "images/sakura.png", numberOfFrame: 5, offsety: 0, delta: FIGHTER_STD_WIDTH, rate: 150, type: $.gameQuery.ANIMATION_HORIZONTAL});
  280. this.animations["punch"] = new $.gameQuery.Animation({imageURL: "images/sakura.png", numberOfFrame: 5, offsety: 166, delta: FIGHTER_EXT_WIDTH, rate: 150, type: $.gameQuery.ANIMATION_HORIZONTAL | $.gameQuery.ANIMATION_ONCE | $.gameQuery.ANIMATION_CALLBACK});
  281. this.animations["kick"] = new $.gameQuery.Animation({imageURL: "images/sakura.png", numberOfFrame: 6, offsety: 252, delta: FIGHTER_EXT_WIDTH, rate: 150, type: $.gameQuery.ANIMATION_HORIZONTAL | $.gameQuery.ANIMATION_ONCE | $.gameQuery.ANIMATION_CALLBACK});
  282. this.animations["ouch"] = new $.gameQuery.Animation({imageURL: "images/sakura.png", numberOfFrame: 4, offsetx: 492, delta: FIGHTER_STD_WIDTH, rate: 150, type: $.gameQuery.ANIMATION_HORIZONTAL | $.gameQuery.ANIMATION_ONCE | $.gameQuery.ANIMATION_CALLBACK});
  283. // this.animations["laught"] = new $.gameQuery.Animation({imageURL: "images/sakura.png", numberOfFrame: 7, offsety: 492, delta: FIGHTER_EXT_WIDTH_3, rate: 150, type: $.gameQuery.ANIMATION_HORIZONTAL | $.gameQuery.ANIMATION_ONCE | $.gameQuery.ANIMATION_CALLBACK});
  284. this.animations["loose"] = new $.gameQuery.Animation({imageURL: "images/sakura.png", numberOfFrame: 10, offsety: 412, delta: FIGHTER_EXT_WIDTH_4, rate: 150, type: $.gameQuery.ANIMATION_HORIZONTAL | $.gameQuery.ANIMATION_ONCE });
  285. // this.animations["loose2"] = new $.gameQuery.Animation({imageURL: "images/sakura.png", numberOfFrame: 6, offsety: 656, delta: FIGHTER_EXT_WIDTH_4, rate: 150, type: $.gameQuery.ANIMATION_HORIZONTAL | $.gameQuery.ANIMATION_ONCE});
  286. };
  287. Sakura.prototype = new Fighter();
  288. Sakura.prototype.victory = function() {
  289. if( !this.isIdle() )
  290. return;
  291. this.setIdle( false );
  292. this.node.setAnimation(this.animations["victory"],
  293. function(node) {
  294. fighters[ node.id ].node.setAnimation(fighters[ node.id ].animations["victory2"]);
  295. });
  296. }
  297. Sakura.prototype.punch = function() {
  298. if( !this.isIdle() )
  299. return;
  300. this.setIdle( false );
  301. this.node.width( FIGHTER_EXT_WIDTH );
  302. if( this.node.fliph() ) {
  303. this.node.x( -(FIGHTER_EXT_WIDTH - FIGHTER_STD_WIDTH), true);
  304. }
  305. this.node.setAnimation(this.animations["punch"],
  306. function(node) {
  307. var HTMLnode = fighters[ node.id ].node;
  308. HTMLnode.width( FIGHTER_STD_WIDTH );
  309. if( HTMLnode.fliph() ) {
  310. HTMLnode.x(FIGHTER_EXT_WIDTH - FIGHTER_STD_WIDTH, true);
  311. }
  312. fighters[ node.id ].idle();
  313. });
  314. }
  315. Sakura.prototype.kick = function() {
  316. if( !this.isIdle() )
  317. return;
  318. this.setIdle( false );
  319. this.node.width( FIGHTER_EXT_WIDTH );
  320. if( this.node.fliph() ) {
  321. this.node.x( -(FIGHTER_EXT_WIDTH - FIGHTER_STD_WIDTH), true);
  322. }
  323. this.node.setAnimation(this.animations["kick"],
  324. function(node) {
  325. var HTMLnode = fighters[ node.id ].node;
  326. HTMLnode.width( FIGHTER_STD_WIDTH );
  327. if( HTMLnode.fliph() ) {
  328. HTMLnode.x(FIGHTER_EXT_WIDTH - FIGHTER_STD_WIDTH, true);
  329. }
  330. fighters[ node.id ].idle();
  331. });
  332. }
  333. Sakura.prototype.laught = function() {
  334. if( !this.isIdle() )
  335. return;
  336. this.setIdle( false );
  337. this.node.width( FIGHTER_EXT_WIDTH_3 );
  338. if( this.node.fliph() ) {
  339. this.node.x(-(FIGHTER_EXT_WIDTH_3 - FIGHTER_STD_WIDTH), true);
  340. }
  341. this.node.setAnimation(this.animations["start"],
  342. function(node) {
  343. var HTMLnode = fighters[ node.id ].node;
  344. HTMLnode.width( FIGHTER_STD_WIDTH );
  345. if( HTMLnode.fliph() ) {
  346. HTMLnodex(FIGHTER_EXT_WIDTH_3 - FIGHTER_STD_WIDTH, true);
  347. }
  348. fighters[ node.id ].idle();
  349. });
  350. }
  351. Sakura.prototype.loose = function() {
  352. if( !this.isIdle() )
  353. return;
  354. this.setIdle( false );
  355. this.node.width( FIGHTER_EXT_WIDTH_4 );
  356. if( this.node.fliph() ) {
  357. this.node.x( -(FIGHTER_EXT_WIDTH_4 - FIGHTER_STD_WIDTH), true);
  358. }
  359. this.node.setAnimation(this.animations["loose"]);
  360. }
  361. function Akuma(){
  362. this.animations["start"] = new $.gameQuery.Animation({imageURL: "images/akuma.png", numberOfFrame: 11, offsety: 82, delta: FIGHTER_STD_WIDTH, rate: 150, type: $.gameQuery.ANIMATION_HORIZONTAL | $.gameQuery.ANIMATION_ONCE | $.gameQuery.ANIMATION_CALLBACK});
  363. this.animations["victory"] = new $.gameQuery.Animation({imageURL: "images/akuma.png", numberOfFrame: 10, offsety: 328, delta: FIGHTER_STD_WIDTH, rate: 150, type: $.gameQuery.ANIMATION_HORIZONTAL | $.gameQuery.ANIMATION_ONCE | $.gameQuery.ANIMATION_CALLBACK});
  364. this.animations["victory2"] = new $.gameQuery.Animation({imageURL: "images/akuma.png", numberOfFrame: 8, offsety: 328, offsetx: 162, delta: FIGHTER_STD_WIDTH, rate: 200, type: $.gameQuery.ANIMATION_HORIZONTAL | $.gameQuery.ANIMATION_ONCE | $.gameQuery.ANIMATION_CALLBACK});
  365. this.animations["idle"] = new $.gameQuery.Animation({imageURL: "images/akuma.png", numberOfFrame: 11, offsety: 0, delta: FIGHTER_STD_WIDTH, rate: 150, type: $.gameQuery.ANIMATION_HORIZONTAL});
  366. this.animations["punch"] = new $.gameQuery.Animation({imageURL: "images/akuma.png", numberOfFrame: 5, offsety: 164, delta: FIGHTER_EXT_WIDTH_4, rate: 150, type: $.gameQuery.ANIMATION_HORIZONTAL | $.gameQuery.ANIMATION_ONCE | $.gameQuery.ANIMATION_CALLBACK});
  367. this.animations["kick"] = new $.gameQuery.Animation({imageURL: "images/akuma.png", numberOfFrame: 7, offsety: 246, delta: FIGHTER_EXT_WIDTH_2, rate: 150, type: $.gameQuery.ANIMATION_HORIZONTAL | $.gameQuery.ANIMATION_ONCE | $.gameQuery.ANIMATION_CALLBACK});
  368. this.animations["ouch"] = new $.gameQuery.Animation({imageURL: "images/akuma.png", numberOfFrame: 7, offsety: 576, delta: FIGHTER_EXT_WIDTH_4, rate: 150, type: $.gameQuery.ANIMATION_HORIZONTAL | $.gameQuery.ANIMATION_ONCE | $.gameQuery.ANIMATION_CALLBACK});
  369. // this.animations["laught"] = new $.gameQuery.Animation({imageURL: "images/akuma.png", numberOfFrame: 7, offsety: 492, delta: FIGHTER_EXT_WIDTH_3, rate: 150, type: $.gameQuery.ANIMATION_HORIZONTAL | $.gameQuery.ANIMATION_ONCE | $.gameQuery.ANIMATION_CALLBACK});
  370. this.animations["loose"] = new $.gameQuery.Animation({imageURL: "images/akuma.png", numberOfFrame: 9, offsety: 412, delta: FIGHTER_EXT_WIDTH_4, rate: 150, type: $.gameQuery.ANIMATION_HORIZONTAL | $.gameQuery.ANIMATION_ONCE | $.gameQuery.ANIMATION_CALLBACK});
  371. this.animations["loose2"] = new $.gameQuery.Animation({imageURL: "images/akuma.png", numberOfFrame: 3, offsety: 494, delta: FIGHTER_EXT_WIDTH_4, rate: 150, type: $.gameQuery.ANIMATION_HORIZONTAL | $.gameQuery.ANIMATION_ONCE});
  372. };
  373. Akuma.prototype = new Fighter();
  374. Akuma.prototype.punch = function() {
  375. if( !this.isIdle() )
  376. return;
  377. this.setIdle( false );
  378. this.node.width( FIGHTER_EXT_WIDTH_4 );
  379. if( this.node.fliph() ) {
  380. this.node.x( -(FIGHTER_EXT_WIDTH_4 - FIGHTER_STD_WIDTH), true);
  381. }
  382. this.node.setAnimation(this.animations["punch"],
  383. function(node) {
  384. var HTMLnode = fighters[ node.id ].node;
  385. HTMLnode.width( FIGHTER_STD_WIDTH );
  386. if( HTMLnode.fliph() ) {
  387. HTMLnode.x(FIGHTER_EXT_WIDTH_4 - FIGHTER_STD_WIDTH, true);
  388. }
  389. fighters[ node.id ].idle();
  390. });
  391. }
  392. Akuma.prototype.kick = function() {
  393. if( !this.isIdle() )
  394. return;
  395. this.setIdle( false );
  396. this.node.width( FIGHTER_EXT_WIDTH_2 );
  397. if( this.node.fliph() ) {
  398. this.node.x( -(FIGHTER_EXT_WIDTH_2 - FIGHTER_STD_WIDTH), true);
  399. }
  400. this.node.setAnimation(this.animations["kick"],
  401. function(node) {
  402. var HTMLnode = fighters[ node.id ].node;
  403. HTMLnode.width( FIGHTER_STD_WIDTH );
  404. if( HTMLnode.fliph() ) {
  405. HTMLnode.x(FIGHTER_EXT_WIDTH_2 - FIGHTER_STD_WIDTH, true);
  406. }
  407. fighters[ node.id ].idle();
  408. });
  409. }
  410. Akuma.prototype.victory = function() {
  411. if( !this.isIdle() )
  412. return;
  413. this.setIdle( false );
  414. this.node.setAnimation(this.animations["victory"],
  415. function(node) {
  416. fighters[ node.id ].node.setAnimation(fighters[ node.id ].animations["victory2"]);
  417. });
  418. }
  419. Akuma.prototype.loose = function() {
  420. if( !this.isIdle() )
  421. return;
  422. this.setIdle( false );
  423. this.node.width( FIGHTER_EXT_WIDTH_4 );
  424. if( this.node.fliph() ) {
  425. this.node.x( -(FIGHTER_EXT_WIDTH_4 - FIGHTER_STD_WIDTH), true);
  426. }
  427. this.node.setAnimation(this.animations["loose"],
  428. function(node) {
  429. fighters[ node.id ].node.setAnimation(fighters[ node.id ].animations["loose2"]);
  430. });
  431. }
  432. Akuma.prototype.ouch = function() {
  433. if( !this.isIdle() )
  434. return;
  435. this.setIdle( false );
  436. this.node.width( FIGHTER_EXT_WIDTH_4 );
  437. if( this.node.fliph() ) {
  438. this.node.x(-(FIGHTER_EXT_WIDTH_4 - FIGHTER_STD_WIDTH), true);
  439. }
  440. this.node.setAnimation(this.animations["ouch"],
  441. function(node) {
  442. var HTMLnode = fighters[ node.id ].node;
  443. HTMLnode.width( FIGHTER_STD_WIDTH );
  444. if( HTMLnode.fliph() ) {
  445. HTMLnode.x(FIGHTER_EXT_WIDTH_4 - FIGHTER_STD_WIDTH, true);
  446. }
  447. fighters[ node.id ].idle();
  448. });
  449. }
  450. function Felicia(){
  451. this.animations["start"] = new $.gameQuery.Animation({imageURL: "images/felicia.png", numberOfFrame: 10, offsety: 82, delta: FIGHTER_STD_WIDTH, rate: 150, type: $.gameQuery.ANIMATION_HORIZONTAL | $.gameQuery.ANIMATION_ONCE | $.gameQuery.ANIMATION_CALLBACK});
  452. this.animations["victory"] = new $.gameQuery.Animation({imageURL: "images/felicia.png", numberOfFrame: 10, offsety: 328, delta: FIGHTER_STD_WIDTH, rate: 150, type: $.gameQuery.ANIMATION_HORIZONTAL | $.gameQuery.ANIMATION_ONCE | $.gameQuery.ANIMATION_CALLBACK});
  453. this.animations["victory2"] = new $.gameQuery.Animation({imageURL: "images/felicia.png", numberOfFrame: 5, offsety: 328, offsetx: 410, delta: FIGHTER_STD_WIDTH, rate: 200, type: $.gameQuery.ANIMATION_HORIZONTAL | $.gameQuery.ANIMATION_ONCE | $.gameQuery.ANIMATION_CALLBACK});
  454. this.animations["idle"] = new $.gameQuery.Animation({imageURL: "images/felicia.png", numberOfFrame: 8, offsety: 0, delta: FIGHTER_STD_WIDTH, rate: 200, type: $.gameQuery.ANIMATION_HORIZONTAL});
  455. this.animations["punch"] = new $.gameQuery.Animation({imageURL: "images/felicia.png", numberOfFrame: 6, offsety: 164, delta: FIGHTER_EXT_WIDTH, rate: 150, type: $.gameQuery.ANIMATION_HORIZONTAL | $.gameQuery.ANIMATION_ONCE | $.gameQuery.ANIMATION_CALLBACK});
  456. this.animations["kick"] = new $.gameQuery.Animation({imageURL: "images/felicia.png", numberOfFrame: 7, offsety: 246, delta: FIGHTER_EXT_WIDTH, rate: 150, type: $.gameQuery.ANIMATION_HORIZONTAL | $.gameQuery.ANIMATION_ONCE | $.gameQuery.ANIMATION_CALLBACK});
  457. this.animations["ouch"] = new $.gameQuery.Animation({imageURL: "images/felicia.png", numberOfFrame: 5, offsety: 492, delta: FIGHTER_EXT_WIDTH_4, rate: 150, type: $.gameQuery.ANIMATION_HORIZONTAL | $.gameQuery.ANIMATION_ONCE | $.gameQuery.ANIMATION_CALLBACK});
  458. // this.animations["laught"] = new $.gameQuery.Animation({imageURL: "images/felicia.png", numberOfFrame: 7, offsety: 492, delta: FIGHTER_EXT_WIDTH_3, rate: 150, type: $.gameQuery.ANIMATION_HORIZONTAL | $.gameQuery.ANIMATION_ONCE | $.gameQuery.ANIMATION_CALLBACK});
  459. this.animations["loose"] = new $.gameQuery.Animation({imageURL: "images/felicia.png", numberOfFrame: 6, offsety: 410, delta: FIGHTER_STD_WIDTH, rate: 150, type: $.gameQuery.ANIMATION_HORIZONTAL | $.gameQuery.ANIMATION_ONCE });
  460. };
  461. Felicia.prototype = new Fighter();
  462. Felicia.prototype.punch = function() {
  463. if( !this.isIdle() )
  464. return;
  465. this.setIdle( false );
  466. this.node.width( FIGHTER_EXT_WIDTH );
  467. if( this.node.fliph() ) {
  468. this.node.x( -(FIGHTER_EXT_WIDTH - FIGHTER_STD_WIDTH), true);
  469. }
  470. this.node.setAnimation(this.animations["punch"],
  471. function(node) {
  472. var HTMLnode = fighters[ node.id ].node;
  473. HTMLnode.width( FIGHTER_STD_WIDTH );
  474. if( HTMLnode.fliph() ) {
  475. HTMLnode.x(FIGHTER_EXT_WIDTH - FIGHTER_STD_WIDTH, true);
  476. }
  477. fighters[ node.id ].idle();
  478. });
  479. }
  480. Felicia.prototype.kick = function() {
  481. if( !this.isIdle() )
  482. return;
  483. this.setIdle( false );
  484. this.node.width( FIGHTER_EXT_WIDTH );
  485. if( this.node.fliph() ) {
  486. this.node.x(-(FIGHTER_EXT_WIDTH - FIGHTER_STD_WIDTH), true);
  487. }
  488. this.node.setAnimation(this.animations["kick"],
  489. function(node) {
  490. var HTMLnode = fighters[ node.id ].node;
  491. HTMLnode.width( FIGHTER_STD_WIDTH );
  492. if( HTMLnode.fliph() ) {
  493. HTMLnode.x(FIGHTER_EXT_WIDTH - FIGHTER_STD_WIDTH, true);
  494. }
  495. fighters[ node.id ].idle();
  496. });
  497. }
  498. Felicia.prototype.victory = function() {
  499. if( !this.isIdle() )
  500. return;
  501. this.setIdle( false );
  502. this.node.setAnimation(this.animations["victory"],
  503. function(node) {
  504. fighters[ node.id ].node.setAnimation(fighters[ node.id ].animations["victory2"]);
  505. });
  506. }
  507. Felicia.prototype.ouch = function() {
  508. if( !this.isIdle() )
  509. return;
  510. this.setIdle( false );
  511. this.node.width( FIGHTER_EXT_WIDTH_4 );
  512. if( this.node.fliph() ) {
  513. this.node.x( -(FIGHTER_EXT_WIDTH_4 - FIGHTER_STD_WIDTH), true);
  514. }
  515. this.node.setAnimation(this.animations["ouch"],
  516. function(node) {
  517. var HTMLnode = fighters[ node.id ].node;
  518. HTMLnode.width( FIGHTER_STD_WIDTH );
  519. if( HTMLnode.fliph() ) {
  520. HTMLnode.x(FIGHTER_EXT_WIDTH_4 - FIGHTER_STD_WIDTH, true);
  521. }
  522. fighters[ node.id ].idle();
  523. });
  524. }