boot.js 6.5 KB

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