boot.js 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. // OUTRAS VARIAVEIS GLOBAIS
  2. /*
  3. --- DO PHASER
  4. this.game.world.centerX...
  5. --- vem do phaser.js
  6. this.points
  7. this.count
  8. --- falta olhar ainda
  9. this.rocks
  10. this.trees
  11. this.r_types
  12. this t_types
  13. this.wait;
  14. */
  15. var passedLevels = 0;
  16. //map
  17. var kid, tractor;
  18. //square 1 + circle 1
  19. var startX;
  20. var clicked, hideLabels, animate, checkCollide, result, hasFigure;
  21. var detail;
  22. var endPosition;
  23. var fractionClicked, fractionIndex;
  24. var blocks, maxBlocks, numBlocks, curBlock, blockDirection, blockDistance, blockLabel, blockSeparator; //blocks control
  25. //square 1
  26. var blockWidth, blockIndex;
  27. var floorBlocks, floorIndex, floorCount, floorClicked, curFloor;
  28. var move, moveCounter, moveEnd;
  29. var arrow;
  30. var arrowPlace;
  31. //circle 1
  32. var blockSize, blockAngle, blockTraceColor;
  33. var fly, flyCounter, flyend; //flyvariables
  34. var trace; //circle trace
  35. var numPlus, endIndex;
  36. var kid_walk, balloon, basket;
  37. var balloonPlace;
  38. //square 2
  39. var sizeA, sizeB, valueA, valueB;
  40. var clickA, clickB, animateA, animateB, result, animate, cDelay, eDelay;
  41. var blocksA, blocksB, auxblqA, auxblqB;
  42. var labelA, fractionA, separatorA, labelB, fractionB, separatorB;
  43. var kidDirection, equals, counter, endCounter;
  44. var xA, yA, xB, yB, blockW, blockH;
  45. // INFO
  46. var username; //player name
  47. var lang; //language
  48. // IMAGES
  49. var beepSound, okSound, errorSound; //sounds
  50. var okImg, errorImg;
  51. var timer, totalTime;
  52. // variaveis globais
  53. var audioStatus = true; // turns game audio on/off
  54. var firstTime = true; //if player has just oppened the game
  55. var debugMode = true; //turns console messages for developers on/off (changeable only by code)
  56. // Initialize the game
  57. var game = new Phaser.Game(
  58. 900,
  59. 600,
  60. Phaser.CANVAS,
  61. 'fractions-game'
  62. );
  63. hip = "143.107.45.11"; //Host ip
  64. name = ""; //player name
  65. lang = ""; //language
  66. // Game One : kid and truck
  67. levelPosition = 0; //Map position
  68. levelMove = false; //Move to next position
  69. levelDifficulty = 0; //From one to five
  70. levelOperator= ""; //Plus; Minus; Mixed
  71. levelLabel= false; //Show block label
  72. levelShape = ""; //Circle; square
  73. levelType = ""; // A - Place distance; B - Select blocks
  74. levelMenu = true;
  75. // Game Two : fractions association
  76. //twoPosition = 0; //Map position
  77. //twoMove = false; //Move to next position
  78. //twoDifficulty = 0; //From one to five
  79. //levelOperator= ""; //Plus; Minus; Mixed
  80. //twoLabel= false; //Show block label
  81. //twoShape = ""; //Circle; square
  82. //twoType = ""; // A - Normal position; B - Random position
  83. //twoMenu= true;
  84. //adding game states (scenes)
  85. game.state.add('language', langState); // boot.js
  86. game.state.add('load', loadState); // boot.js
  87. game.state.add('name', nameState); // boot.js
  88. game.state.add('menu', menuState); // menu.js
  89. game.state.add('menuCOne', menuCircleOne); // circleOne.js
  90. game.state.add('mapCOne', mapCircleOne); // circleOne.js
  91. game.state.add('gameCOne', gameCircleOne); // circleOne.js
  92. game.state.add('endCOne', endCircleOne); // circleOne.js
  93. game.state.add('menuSOne', menuSquareOne); // squareOne.js
  94. game.state.add('mapSOne', mapSquareOne); // squareOne.js
  95. game.state.add('gameSOne', gameSquareOne); // squareOne.js
  96. game.state.add('endSOne', endSquareOne); // squareOne.js
  97. game.state.add('menuSTwo', menuSquareTwo); // squareTwo.js
  98. game.state.add('mapSTwo', mapSquareTwo); // squareTwo.js
  99. game.state.add('gameSTwo', gameSquareTwo); // squareTwo.js
  100. game.state.add('endSTwo', endSquareTwo); // squareTwo.js
  101. var loadAssets = {
  102. preload: function(){
  103. //directory auxiliar
  104. var imgsrc = 'assets/img/';
  105. //Progress bar image
  106. game.load.image('progressBar', imgsrc+'pgbar.png');
  107. //flags
  108. game.load.image('flag_BR', imgsrc+'flag/BRAZ.jpg');
  109. game.load.image('flag_PE', imgsrc+'flag/PERU.jpg');
  110. game.load.image('flag_US', imgsrc+'flag/UNST.jpg');
  111. game.load.image('flag_FR', imgsrc+'flag/FRAN.jpg');
  112. //scenario
  113. game.load.image('bgimage', imgsrc+'bg.jpg');
  114. game.load.image('bgmap', imgsrc+'bg_map.png');
  115. game.load.image('cloud', imgsrc+'cloud.png');
  116. game.load.image('floor', imgsrc+'floor.png');
  117. game.load.image('road', imgsrc+'road.png');
  118. //game phases buttons list
  119. game.load.image('game1s', imgsrc+'game/1-left-subs.png');
  120. game.load.image('game2s', imgsrc+'game/1-right-nosubs.png');
  121. game.load.image('game3s', imgsrc+'game/2-left-subs.png');
  122. game.load.image('game4s', imgsrc+'game/2-right-nosubs.png');
  123. game.load.image('game1c', imgsrc+'game/3-left-subs.png');
  124. game.load.image('game2c', imgsrc+'game/3-right-nosubs.png');
  125. game.load.image('game3c', imgsrc+'game/4-left-subs.png');
  126. game.load.image('game4c', imgsrc+'game/4-right-nosubs.png');
  127. game.load.image('game5s', imgsrc+'game/5.png');
  128. //header menu buttons
  129. game.load.image('back', imgsrc+'menu/back.png');
  130. game.load.image('home', imgsrc+'menu/home.png');
  131. game.load.image('info', imgsrc+'menu/info.png');
  132. game.load.image('world', imgsrc+'menu/language.png');
  133. game.load.image('list', imgsrc+'menu/menu.png');
  134. game.load.image('help', imgsrc+'menu/help.png');
  135. game.load.image('pgbar', imgsrc+'menu/progressBar.png');
  136. game.load.image('block', imgsrc+'menu/block.png');
  137. game.load.spritesheet('audio', imgsrc+'menu/audio_48x48.png',48,48,2);
  138. //operators
  139. game.load.image('add', imgsrc+'operator/add.png');
  140. game.load.image('subtract', imgsrc+'operator/subtract.png');
  141. game.load.image('separator', imgsrc+'operator/separator.png');
  142. game.load.image('equal', imgsrc+'operator/equal.png');
  143. //feedback
  144. game.load.image('h_arrow', imgsrc+'help/arrow.png');
  145. game.load.image('h_double', imgsrc+'help/double.png');
  146. game.load.image('h_error', imgsrc+'help/error.png');
  147. game.load.image('h_ok', imgsrc+'help/ok.png');
  148. game.load.image('down', imgsrc+'help/down.png');
  149. game.load.image('pointer', imgsrc+'help/pointer.png');
  150. // Loading assets based on language
  151. game.load.spritesheet('kid_run', imgsrc+'kid/run.png', 82, 178, 12);
  152. game.load.spritesheet('kid_walk', imgsrc+'kid/walk.png', 78, 175, 26);
  153. game.load.spritesheet('kid_lost', imgsrc+'kid/lost.png', 72, 170, 6);
  154. game.load.spritesheet('tractor', imgsrc+'tractor/frame.png', 201, 144, 10);
  155. game.load.image('tractor_green', imgsrc+'tractor/frame-0.png');
  156. game.load.image('tractor_red', imgsrc+'tractor/frame-5.png');
  157. game.load.image('balloon', imgsrc+'airballoon_upper.png');
  158. game.load.image('balloon_basket', imgsrc+'airballoon_base.png');
  159. game.load.image('birch', imgsrc+'birch.png');
  160. game.load.image('flag', imgsrc+'flag.png');
  161. game.load.image('house', imgsrc+'house.png');
  162. game.load.image('place_a', imgsrc+'place_a.png');
  163. game.load.image('place_b', imgsrc+'place_b.png');
  164. game.load.image('garage', imgsrc+'garage.png');
  165. game.load.image('farm', imgsrc+'farm.png');
  166. game.load.image('rock', imgsrc+'rock.png');
  167. game.load.image('school', imgsrc+'school.png');
  168. game.load.image('sign', imgsrc+'sign.png');
  169. game.load.image('tree1', imgsrc+'tree.png');
  170. game.load.image('tree2', imgsrc+'tree2.png');
  171. game.load.image('tree3', imgsrc+'tree3.png');
  172. game.load.image('tree4', imgsrc+'tree4.png');
  173. // Loadind Sound Effects
  174. game.load.audio('sound_ok', ['assets/fx/ok.ogg', 'assets/fx/ok.mp3']);
  175. game.load.audio('sound_error', ['assets/fx/error.ogg', 'assets/fx/error.mp3']);
  176. game.load.audio('sound_beep', ['assets/fx/beep.ogg', 'assets/fx/beep.mp3']);
  177. },
  178. create: function(){
  179. game.physics.startSystem(Phaser.Physics.ARCADE);
  180. game.state.start('language');
  181. }
  182. };
  183. //starting to boot game
  184. game.state.add('loadAssets', loadAssets); // squareTwo.js
  185. game.state.start('loadAssets');