boot.js 7.8 KB

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