boot.js 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. var username; //user info
  2. var lang; //language
  3. var beepSound, okSound, errorSound; //sounds
  4. var okImg, errorImg;
  5. var timer, totalTime;
  6. var audioStatus = true;
  7. // Initialize the game
  8. var game = new Phaser.Game(
  9. 900,
  10. 600,
  11. Phaser.CANVAS,
  12. 'fractions-game'
  13. );
  14. hip = "143.107.45.11"; //Host ip
  15. name = ""; //player name
  16. lang = ""; //language
  17. // Game One : kid and truck
  18. onePosition = 0; //Map position
  19. oneMove = false; //Move to next position
  20. oneDifficulty = 0; //From one to five
  21. oneOperator= ""; //Plus; Minus; Mixed
  22. oneLabel= false; //Show block label
  23. oneShape = ""; //Circle; square
  24. oneType = ""; // A - Place distance; B - Select blocks
  25. oneMenu = true;
  26. // Game Two : fractions association
  27. twoPosition = 0; //Map position
  28. twoMove = false; //Move to next position
  29. twoDifficulty = 0; //From one to five
  30. twoOperator= ""; //Plus; Minus; Mixed
  31. twoLabel= false; //Show block label
  32. twoShape = ""; //Circle; square
  33. twoType = ""; // A - Normal position; B - Random position
  34. twoMenu= true;
  35. //adding game states (scenes)
  36. game.state.add('language', langState); // boot.js
  37. game.state.add('load', loadState); // boot.js
  38. game.state.add('name', nameState); // boot.js
  39. game.state.add('menu', menuState); // menu.js
  40. game.state.add('menuCOne', menuCircleOne); // circleOne.js
  41. game.state.add('mapCOne', mapCircleOne); // circleOne.js
  42. game.state.add('gameCOne', gameCircleOne); // circleOne.js
  43. game.state.add('endCOne', endCircleOne); // circleOne.js
  44. game.state.add('menuSOne', menuSquareOne); // squareOne.js
  45. game.state.add('mapSOne', mapSquareOne); // squareOne.js
  46. game.state.add('gameSOne', gameSquareOne); // squareOne.js
  47. game.state.add('endSOne', endSquareOne); // squareOne.js
  48. game.state.add('menuSTwo', menuSquareTwo); // squareTwo.js
  49. game.state.add('mapSTwo', mapSquareTwo); // squareTwo.js
  50. game.state.add('gameSTwo', gameSquareTwo); // squareTwo.js
  51. game.state.add('endSTwo', endSquareTwo); // squareTwo.js
  52. var loadAssets = {
  53. preload: function(){
  54. var imgsrc = 'assets/img/';
  55. //Progress bar image
  56. game.load.image('progressBar', imgsrc+'pgbar.png');
  57. //flags
  58. game.load.image('flag_BR', imgsrc+'flag/BRAZ.jpg');
  59. game.load.image('flag_PE', imgsrc+'flag/PERU.jpg');
  60. game.load.image('flag_US', imgsrc+'flag/UNST.jpg');
  61. game.load.image('flag_FR', imgsrc+'flag/FRAN.jpg');
  62. //scenario
  63. game.load.image('bgimage', imgsrc+'bg.jpg');
  64. game.load.image('bgmap', imgsrc+'bg_map.png');
  65. game.load.image('cloud', imgsrc+'cloud.png');
  66. game.load.image('floor', imgsrc+'floor.png');
  67. game.load.image('road', imgsrc+'road.png');
  68. //game phases buttons list
  69. game.load.image('game1c', imgsrc+'game/one-c.png');
  70. game.load.image('game2c', imgsrc+'game/two-c.png');
  71. game.load.image('game3c', imgsrc+'game/three-c.png');
  72. game.load.image('game4c', imgsrc+'game/four-c.png');
  73. game.load.image('game1s', imgsrc+'game/one-s.png');
  74. game.load.image('game2s', imgsrc+'game/two-s.png');
  75. game.load.image('game3s', imgsrc+'game/three-s.png');
  76. game.load.image('game4s', imgsrc+'game/four-s.png');
  77. game.load.image('game5s', imgsrc+'game/five-s.png');
  78. //header menu buttons
  79. game.load.image('back', imgsrc+'menu/back.png');
  80. game.load.image('home', imgsrc+'menu/home.png');
  81. game.load.image('info', imgsrc+'menu/info.png');
  82. game.load.image('world', imgsrc+'menu/language.png');
  83. game.load.image('list', imgsrc+'menu/menu.png');
  84. game.load.image('help', imgsrc+'menu/help.png');
  85. game.load.image('pgbar', imgsrc+'menu/progressBar.png');
  86. game.load.image('block', imgsrc+'menu/block.png');
  87. game.load.spritesheet('audio', imgsrc+'menu/audio_48x48.png',48,48,2);
  88. //operators
  89. game.load.image('add', imgsrc+'operator/add.png');
  90. game.load.image('subtract', imgsrc+'operator/subtract.png');
  91. game.load.image('separator', imgsrc+'operator/separator.png');
  92. game.load.image('equal', imgsrc+'operator/equal.png');
  93. //feedback
  94. game.load.image('h_arrow', imgsrc+'help/arrow.png');
  95. game.load.image('h_double', imgsrc+'help/double.png');
  96. game.load.image('h_error', imgsrc+'help/error.png');
  97. game.load.image('h_ok', imgsrc+'help/ok.png');
  98. game.load.image('down', imgsrc+'help/down.png');
  99. game.load.image('pointer', imgsrc+'help/pointer.png');
  100. // Loading assets based on language
  101. game.load.spritesheet('kid_run', imgsrc+'kid/run.png', 82, 178, 12);
  102. game.load.spritesheet('kid_walk', imgsrc+'kid/walk.png', 78, 175, 24);
  103. game.load.spritesheet('kid_lost', imgsrc+'kid/lost.png', 72, 170, 6);
  104. game.load.spritesheet('tractor', imgsrc+'tractor/frame.png', 201, 144, 10);
  105. game.load.image('balloon', imgsrc+'airballoon_upper.png');
  106. game.load.image('balloon_basket', imgsrc+'airballoon_base.png');
  107. game.load.image('birch', imgsrc+'birch.png');
  108. game.load.image('flag', imgsrc+'flag.png');
  109. game.load.image('house', imgsrc+'house.png');
  110. game.load.image('place_a', imgsrc+'place_a.png');
  111. game.load.image('place_b', imgsrc+'place_b.png');
  112. game.load.image('garage', imgsrc+'garage.png');
  113. game.load.image('farm', imgsrc+'farm.png');
  114. game.load.image('rock', imgsrc+'rock.png');
  115. game.load.image('school', imgsrc+'school.png');
  116. game.load.image('sign', imgsrc+'sign.png');
  117. game.load.image('tree1', imgsrc+'tree.png');
  118. game.load.image('tree2', imgsrc+'tree2.png');
  119. game.load.image('tree3', imgsrc+'tree3.png');
  120. game.load.image('tree4', imgsrc+'tree4.png');
  121. // Loadind Sound Effects
  122. game.load.audio('sound_ok', ['assets/fx/ok.ogg', 'assets/fx/ok.mp3']);
  123. game.load.audio('sound_error', ['assets/fx/error.ogg', 'assets/fx/error.mp3']);
  124. game.load.audio('sound_beep', ['assets/fx/beep.ogg', 'assets/fx/beep.mp3']);
  125. },
  126. create: function(){
  127. game.physics.startSystem(Phaser.Physics.ARCADE);
  128. game.state.start('language');
  129. }
  130. };
  131. //starting to boot game
  132. game.state.add('loadAssets', loadAssets); // squareTwo.js
  133. game.state.start('loadAssets');