load.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. /*
  2. * ===========================================================================
  3. *
  4. * Wolf3D Browser Version GPL Source Code
  5. * Copyright (C) 2012 id Software LLC, a ZeniMax Media company.
  6. *
  7. * This file is part of the Wolf3D Browser Version GPL Source Code ("Wolf3D Browser Source Code").
  8. *
  9. * Wolf3D Browser Source Code is free software: you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation, either version 2 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * Wolf3D Browser Source Code is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License version 2
  20. * along with Wolf3D Browser Source Code. If not, see <http://www.gnu.org/licenses/>.
  21. *
  22. * If you have questions concerning this license, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
  23. *
  24. * ===========================================================================
  25. */
  26. (function($) {
  27. // these files are preloaded while the title screen is showing
  28. var files = [
  29. "js/requestanimframe.js",
  30. "js/wolf.js",
  31. "js/random.js",
  32. "js/angle.js",
  33. "js/math.js",
  34. "js/input.js",
  35. "js/sound.js",
  36. "js/menu.js",
  37. "js/file.js",
  38. "js/game.js",
  39. "js/player.js",
  40. "js/sprites.js",
  41. "js/powerups.js",
  42. "js/ai.js",
  43. "js/actorai.js",
  44. "js/actors.js",
  45. "js/actstat.js",
  46. "js/weapon.js",
  47. "js/doors.js",
  48. "js/pushwall.js",
  49. "js/areas.js",
  50. "js/level.js",
  51. "js/raycaster.js",
  52. "js/renderer.js",
  53. "js/episodes.js",
  54. "js/maps.js",
  55. "preload!art/menubg_main.png",
  56. "preload!art/menuitems.png",
  57. "preload!art/menuselector.png"
  58. ];
  59. // these files are preloaded in the background after the menu is displayed.
  60. // only non-essential files here
  61. var files2 = [
  62. "preload!art/menubg_episodes.png",
  63. "preload!art/menuitems_episodes.png",
  64. "preload!art/menubg_skill.png",
  65. "preload!art/menubg_levels.png",
  66. "preload!art/menuitems_levels.png",
  67. "preload!art/skillfaces.png",
  68. "preload!art/getpsyched.png",
  69. "preload!art/menubg_control.png",
  70. "preload!art/menulight.png",
  71. "preload!art/menubg_customize.png",
  72. "preload!art/control_keys.png",
  73. "preload!art/confirm_newgame.png",
  74. "preload!art/paused.png"
  75. ];
  76. $(document).ready(function() {
  77. var progress = $("<div>"),
  78. n = 0;
  79. progress.addClass("load-progress").appendTo("#title-screen");
  80. $("#title-screen").show();
  81. yepnope.addPrefix("preload", function(resource) {
  82. resource.noexec = true;
  83. resource.instead = function(input, callback) {
  84. var image = new Image();
  85. image.onload = callback;
  86. image.onerror = callback;
  87. image.src = input.substr(input.lastIndexOf("!")+1);
  88. };
  89. return resource;
  90. });
  91. Modernizr.load([
  92. {
  93. load : files,
  94. callback : function(file) {
  95. progress.width((++n / files.length) * 100 + "%");
  96. },
  97. complete : function() {
  98. progress.remove();
  99. $("#title-screen").fadeOut(1500, function() {
  100. Wolf.Input.init();
  101. Wolf.Game.init();
  102. Wolf.Menu.show();
  103. });
  104. // preload non-essential art
  105. Modernizr.load(files2);
  106. }
  107. }
  108. ]);
  109. });
  110. })(jQuery);