lb.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. /*
  2. proper game init and run states
  3. add houses to grid
  4. update collisions to use grid
  5. figure out something with the paths
  6. people standing in line
  7. where for employees to stand
  8. thirst logic
  9. inventory screens
  10. store screens
  11. quadtree for collisions
  12. framerate throttle
  13. thought bubbles?
  14. assets needed:
  15. grass texture
  16. dirt texture
  17. gravel texture
  18. sidewalk textures
  19. road textures
  20. alley textures
  21. stands
  22. houses
  23. */
  24. // why can't browsers just get along?
  25. window.requestAnimFrame = (function(){
  26. return window.requestAnimationFrame ||
  27. window.webkitRequestAnimationFrame ||
  28. window.mozRequestAnimationFrame ||
  29. window.oRequestAnimationFrame ||
  30. window.msRequestAnimationFrame ||
  31. function(callback){
  32. window.setTimeout(callback, 1000 / 30);
  33. };
  34. })();
  35. // asset loading
  36. var img_to_load = {
  37. grass: 'textures/ground/grass.png',
  38. debug_grass: 'textures/ground/debug-grass.png',
  39. road: 'textures/ground/debug_road.png',
  40. debug_road: 'textures/ground/debug_road.png',
  41. debug_sidewalk: 'textures/ground/sidewalk_0101.png',
  42. sidewalk_0000: 'textures/ground/sidewalk_0000.png',
  43. sidewalk_0001: 'textures/ground/sidewalk_0001.png',
  44. sidewalk_0010: 'textures/ground/sidewalk_0010.png',
  45. sidewalk_0011: 'textures/ground/sidewalk_0011.png',
  46. sidewalk_0100: 'textures/ground/sidewalk_0100.png',
  47. sidewalk_0101: 'textures/ground/sidewalk_0101.png',
  48. sidewalk_0110: 'textures/ground/sidewalk_0110.png',
  49. sidewalk_0111: 'textures/ground/sidewalk_0111.png',
  50. sidewalk_1000: 'textures/ground/sidewalk_1000.png',
  51. sidewalk_1001: 'textures/ground/sidewalk_1001.png',
  52. sidewalk_1010: 'textures/ground/sidewalk_1010.png',
  53. sidewalk_1011: 'textures/ground/sidewalk_1011.png',
  54. sidewalk_1100: 'textures/ground/sidewalk_1100.png',
  55. sidewalk_1101: 'textures/ground/sidewalk_1101.png',
  56. sidewalk_1110: 'textures/ground/sidewalk_1110.png',
  57. sidewalk_1111: 'textures/ground/sidewalk_1111.png',
  58. susie: 'textures/susie.png',
  59. susieshouse: 'textures/susieshouse.png',
  60. stand: 'textures/debug_stand.png',
  61. }
  62. var images = {};
  63. $(function() {
  64. var imgs = Object.keys(img_to_load).length;
  65. function loadcb() {
  66. imgs--;
  67. if(imgs == 0) {
  68. $('.loading').hide();
  69. $('.intro').show();
  70. }
  71. }
  72. for(var k in img_to_load) {
  73. images[k] = new Image();
  74. images[k].onload = loadcb;
  75. images[k].src = img_to_load[k];
  76. }
  77. });