globals_tokens.js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557
  1. const baseUrl = 'src/assets/img/'; // Base directory for media
  2. /**
  3. * Information for all the games
  4. * @type {Array}
  5. */
  6. const gameList = [
  7. {
  8. gameName: 'squareOne',
  9. gameMode: ['A', 'B'],
  10. gameOperation: ['Plus', 'Minus'],
  11. gameDifficulty: 3,
  12. // info
  13. gameShape: 'square',
  14. assets: {
  15. gameNameBtn: 'game0',
  16. gameModeBtn: ['mode0', 'mode1'],
  17. gameOperationBtn: ['operation_plus', 'operation_minus'],
  18. mapCharacterAnimation: (operation) => {
  19. return operation === 'plus'
  20. ? ['green_tractor', [0, 1, 2, 3, 4], 3]
  21. : ['red_tractor', [10, 11, 12, 13, 14], 3];
  22. },
  23. mapCharacter: (operation) => {
  24. let char;
  25. if (operation == 'Plus') {
  26. char = game.add.sprite(
  27. self.points.x[curMapPosition],
  28. self.points.y[curMapPosition],
  29. 'tractor',
  30. 0,
  31. 0.75
  32. );
  33. }
  34. if (operation === 'Minus') {
  35. char = game.add.sprite(
  36. self.points.x[curMapPosition],
  37. self.points.y[curMapPosition],
  38. 'tractor',
  39. 10,
  40. 0.75
  41. );
  42. }
  43. char.rotate = -30; // 25 anticlock
  44. return char;
  45. },
  46. mapStart: () => {
  47. return game.add
  48. .image(self.points.x[0], self.points.y[0], 'garage', 0.6)
  49. .anchor(0.5, 1);
  50. },
  51. mapEnd: () => {
  52. return game.add
  53. .image(self.points.x[5], self.points.y[5], 'farm', 0.9)
  54. .anchor(0.4, 0.7);
  55. },
  56. },
  57. },
  58. {
  59. // game data
  60. gameName: 'circleOne',
  61. gameMode: ['A', 'B'],
  62. gameOperation: ['Plus', 'Minus', 'Mixed'],
  63. gameDifficulty: 5,
  64. // info
  65. gameShape: 'circle',
  66. assets: {
  67. gameNameBtn: 'game1',
  68. gameModeBtn: ['mode2', 'mode3'],
  69. gameOperationBtn: [
  70. 'operation_plus',
  71. 'operation_minus',
  72. 'operation_mixed',
  73. ],
  74. mapCharacterAnimation: () => {
  75. ['kid', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 3];
  76. },
  77. mapCharacter: () => {
  78. return game.add.sprite(
  79. self.points.x[curMapPosition],
  80. self.points.y[curMapPosition],
  81. 'kid_run',
  82. 0,
  83. 0.6
  84. );
  85. },
  86. mapStart: () => {
  87. return game.add
  88. .image(self.points.x[0], self.points.y[0], 'house', 1.05)
  89. .anchor(0.5, 0.8);
  90. },
  91. mapEnd: () => {
  92. return game.add
  93. .image(self.points.x[5], self.points.y[5], 'school', 0.525)
  94. .anchor(0.2, 0.7);
  95. },
  96. },
  97. },
  98. {
  99. // game data
  100. gameName: 'squareTwo',
  101. gameMode: ['A', 'B'],
  102. gameOperation: ['Equals'],
  103. gameDifficulty: 5,
  104. // info
  105. gameShape: 'square',
  106. assets: {
  107. gameNameBtn: 'game2',
  108. gameModeBtn: ['mode4', 'mode5'],
  109. gameOperationBtn: ['operation_equals'],
  110. mapCharacterAnimation: () => {
  111. ['kid', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 3];
  112. },
  113. mapCharacter: () => {
  114. return game.add.sprite(
  115. self.points.x[curMapPosition],
  116. self.points.y[curMapPosition],
  117. 'kid_run',
  118. 0,
  119. 0.6
  120. );
  121. },
  122. mapStart: () => {
  123. return game.add
  124. .image(this.points.x[0], this.points.y[0], 'house', 1.05)
  125. .anchor(0.5, 0.8);
  126. },
  127. mapEnd: () => {
  128. return game.add
  129. .image(this.points.x[5], this.points.y[5], 'school', 0.525)
  130. .anchor(0.2, 0.7);
  131. },
  132. },
  133. },
  134. {
  135. // game data
  136. gameName: 'scaleOne',
  137. gameMode: ['A'],
  138. gameOperation: ['Plus'],
  139. gameDifficulty: 1,
  140. // info
  141. gameShape: 'noShape',
  142. assets: {
  143. gameNameBtn: 'game3',
  144. gameModeBtn: ['mode6'],
  145. gameOperationBtn: ['operation_equals'],
  146. mapCharacterAnimation: (operation) => {
  147. return operation === 'plus'
  148. ? ['green_tractor', [0, 1, 2, 3, 4], 3]
  149. : ['red_tractor', [10, 11, 12, 13, 14], 3];
  150. },
  151. mapCharacter: (operation) => {
  152. let char;
  153. if (operation == 'Plus') {
  154. char = game.add.sprite(
  155. self.points.x[curMapPosition],
  156. self.points.y[curMapPosition],
  157. 'tractor',
  158. 0,
  159. 0.75
  160. );
  161. }
  162. if (operation === 'Minus') {
  163. char = game.add.sprite(
  164. self.points.x[curMapPosition],
  165. self.points.y[curMapPosition],
  166. 'tractor',
  167. 10,
  168. 0.75
  169. );
  170. }
  171. char.rotate = -30; // 25 anticlock
  172. return char;
  173. },
  174. mapStart: () => {
  175. return game.add
  176. .image(self.points.x[0], self.points.y[0], 'garage', 0.6)
  177. .anchor(0.5, 1);
  178. },
  179. mapEnd: () => {
  180. return game.add
  181. .image(self.points.x[5], self.points.y[5], 'farm', 0.9)
  182. .anchor(0.4, 0.7);
  183. },
  184. },
  185. },
  186. ];
  187. /**
  188. * Preset colors for graphic elements.
  189. * @type {object}
  190. */
  191. const colors = {
  192. // Blues
  193. blue: '#003cb3', // Subtitle
  194. blueDark: '#183780', // Line color that indicates right and fraction numbers
  195. blueBg: '#cce5ff', // Background color
  196. blueBgOff: '#adc8e6',
  197. blueBgInsideLevel: '#a8c0e6', // Background color in squareOne (used for floor gap)
  198. blueMenuLine: '#b7cdf4',
  199. // Reds
  200. red: '#b30000', // Linecolor that indicates left
  201. redLight: '#d27979', // squareTwo figures
  202. redDark: '#330000', // squareTwo figures and some titles
  203. // Greens
  204. green: '#00804d', // Title
  205. greenLight: '#83afaf', // squareTwo figures
  206. greenDark: '#1e2f2f', // squareTwo figures
  207. greenNeon: '#00d600',
  208. // Basics
  209. white: '#efeff5',
  210. gray: '#708090',
  211. black: '#000',
  212. yellow: '#ffef1f',
  213. };
  214. const fontSizes = {
  215. h1: '48px',
  216. h2: '42px',
  217. h3: '38px',
  218. h4: '36px',
  219. p: '30px',
  220. };
  221. /**
  222. * Preset text styles for game text.<br>
  223. * Contains: font, size, text color and text align.
  224. * @type {object}
  225. */
  226. const textStyles = {
  227. h1_green: {
  228. font: fontSizes.h1 + ' Arial,sans-serif',
  229. fill: colors.green,
  230. align: 'center',
  231. }, // Menu title
  232. h2_green: {
  233. font: fontSizes.h2 + ' Arial,sans-serif',
  234. fill: colors.green,
  235. align: 'center',
  236. }, // Flag labels (langState)
  237. h3_green: {
  238. font: fontSizes.h3 + ' Arial,sans-serif',
  239. fill: colors.green,
  240. align: 'center',
  241. },
  242. h4_green: {
  243. font: fontSizes.h4 + ' Arial,sans-serif',
  244. fill: colors.green,
  245. align: 'center',
  246. },
  247. p_green: {
  248. font: fontSizes.p + ' Arial,sans-serif',
  249. fill: colors.green,
  250. align: 'center',
  251. },
  252. h1_white: {
  253. font: fontSizes.h1 + ' Arial,sans-serif',
  254. fill: colors.white,
  255. align: 'center',
  256. }, // Ok button (nameState)
  257. h2_white: {
  258. font: fontSizes.h2 + ' Arial,sans-serif',
  259. fill: colors.white,
  260. align: 'center',
  261. }, // Difficulty buttons (menuState)
  262. h3__white: {
  263. font: fontSizes.h3 + ' Arial,sans-serif',
  264. fill: colors.white,
  265. align: 'center',
  266. }, // Difficulty numbers (menuState)
  267. h4_white: {
  268. font: fontSizes.h4 + ' Arial,sans-serif',
  269. fill: colors.white,
  270. align: 'center',
  271. }, // Difficulty numbers (menuState)
  272. p_white: {
  273. font: fontSizes.p + ' Arial,sans-serif',
  274. fill: colors.white,
  275. align: 'center',
  276. }, // Enter button (menuState)
  277. h1_brown: {
  278. font: fontSizes.h1 + ' Arial,sans-serif',
  279. fill: colors.redDark,
  280. align: 'center',
  281. },
  282. h2_brown: {
  283. font: fontSizes.h2 + ' Arial,sans-serif',
  284. fill: colors.redDark,
  285. align: 'center',
  286. }, // Map difficulty label
  287. h3_brown: {
  288. font: fontSizes.h3 + ' Arial,sans-serif',
  289. fill: colors.redDark,
  290. align: 'center',
  291. },
  292. h4_brown: {
  293. font: fontSizes.h4 + ' Arial,sans-serif',
  294. fill: colors.redDark,
  295. align: 'center',
  296. }, // Menu overtitle
  297. p_brown: {
  298. font: fontSizes.p + ' Arial,sans-serif',
  299. fill: colors.redDark,
  300. align: 'center',
  301. }, // Map difficulty label
  302. h1_blue: {
  303. font: fontSizes.h1 + ' Arial,sans-serif',
  304. fill: colors.blue,
  305. align: 'center',
  306. },
  307. h2_blue: {
  308. font: fontSizes.h2 + ' Arial,sans-serif',
  309. fill: colors.blue,
  310. align: 'center',
  311. }, // Menu subtitle
  312. h3_blue: {
  313. font: fontSizes.h3 + ' Arial,sans-serif',
  314. fill: colors.blue,
  315. align: 'center',
  316. },
  317. h4_blue: {
  318. font: fontSizes.h4 + ' Arial,sans-serif',
  319. fill: colors.blue,
  320. align: 'center',
  321. }, // Menu subtitle
  322. p_blue: {
  323. font: fontSizes.p + ' Arial,sans-serif',
  324. fill: colors.blue,
  325. align: 'center',
  326. },
  327. h1_blueDark: {
  328. font: fontSizes.h1 + ' Arial,sans-serif',
  329. fill: colors.blueDark,
  330. align: 'center',
  331. },
  332. h2_blueDark: {
  333. font: fontSizes.h2 + ' Arial,sans-serif',
  334. fill: colors.blueDark,
  335. align: 'center',
  336. }, // Fractions
  337. h3_blueDark: {
  338. font: fontSizes.h3 + ' Arial,sans-serif',
  339. fill: colors.blueDark,
  340. align: 'center',
  341. },
  342. h4_blueDark: {
  343. font: fontSizes.h4 + ' Arial,sans-serif',
  344. fill: colors.blueDark,
  345. align: 'center',
  346. }, // Fractions
  347. p_blueDark: {
  348. font: fontSizes.p + ' Arial,sans-serif',
  349. fill: colors.blueDark,
  350. align: 'center',
  351. }, // Fractions
  352. };
  353. /**
  354. * List of URL for all media in the game
  355. * divided 1st by the 'state' that loads the media
  356. * and 2nd by the 'media type' for that state.
  357. *
  358. * @type {object}
  359. */
  360. const url = {
  361. /**
  362. * url.<state>
  363. * where <state> can be: boot, menu, squareOne, squareTwo, circleOne.
  364. */
  365. boot: {
  366. /**
  367. * url.<state>.<media type>
  368. * where <media type> can be: image, sprite, audio <br><br>
  369. *
  370. * image: [ [name, source], ... ] <br>
  371. * sprite: [ [name, source, number of frames], ... ] <br>
  372. * audio: [ [name, [source, alternative source] ], ... ]
  373. */
  374. image: [
  375. // Scene
  376. ['bgimage', baseUrl + 'scene/bg.jpg'],
  377. ['bg_snow', baseUrl + 'scene/bg_snow.png'],
  378. ['bgmap', baseUrl + 'scene/bg_map.png'],
  379. ['broken_sign', baseUrl + 'scene/broken_sign.png'],
  380. ['bush', baseUrl + 'scene/bush.png'],
  381. ['cloud', baseUrl + 'scene/cloud.png'],
  382. ['floor_stone_left', baseUrl + 'scene/floor_stone_left.png'],
  383. ['floor_stone_right', baseUrl + 'scene/floor_stone_right.png'],
  384. ['floor_stone', baseUrl + 'scene/floor_stone.png'],
  385. ['floor', baseUrl + 'scene/floor.png'],
  386. ['wood_shelf', baseUrl + 'scene/wood_shelf.png'],
  387. ['place_off', baseUrl + 'scene/place_off.png'],
  388. ['place_on', baseUrl + 'scene/place_on.png'],
  389. ['rock', baseUrl + 'scene/rock.png'],
  390. ['road', baseUrl + 'scene/road.png'],
  391. ['sign', baseUrl + 'scene/sign.png'],
  392. ['tree1', baseUrl + 'scene/tree.png'],
  393. ['tree2', baseUrl + 'scene/tree2.png'],
  394. ['tree3', baseUrl + 'scene/tree3.png'],
  395. ['tree4', baseUrl + 'scene/tree4.png'],
  396. // Flags
  397. ['flag_BR', baseUrl + 'flag/br.png'],
  398. ['flag_FR', baseUrl + 'flag/fr.png'],
  399. ['flag_IT', baseUrl + 'flag/it.png'],
  400. ['flag_PE', baseUrl + 'flag/pe.png'],
  401. ['flag_US', baseUrl + 'flag/us.png'],
  402. // Navigation icons on the top of the page
  403. ['back', baseUrl + 'navig_icon/back.png'],
  404. ['help', baseUrl + 'navig_icon/help.png'],
  405. ['home', baseUrl + 'navig_icon/home.png'],
  406. ['language', baseUrl + 'navig_icon/language.png'],
  407. ['menu', baseUrl + 'navig_icon/menu.png'],
  408. // Interactive icons
  409. ['arrow_down', baseUrl + 'interac_icon/down.png'],
  410. ['close', baseUrl + 'interac_icon/close.png'],
  411. ['error', baseUrl + 'interac_icon/error.png'],
  412. ['help_pointer', baseUrl + 'interac_icon/pointer.png'],
  413. ['info', baseUrl + 'interac_icon/info.png'],
  414. ['ok', baseUrl + 'interac_icon/ok.png'],
  415. ['button', baseUrl + 'interac_icon/button.png'],
  416. // Menu icons - Games
  417. ['game0', baseUrl + 'levels/squareOne.png'], // Square I
  418. ['game1', baseUrl + 'levels/circleOne.png'], // Circle I
  419. ['game2', baseUrl + 'levels/squareTwo.png'], // Square II
  420. ['game3', baseUrl + 'levels/scaleOne.png'], // Scale I
  421. // Menu icons - Info box
  422. ['c1-A', baseUrl + 'info_box/c1-A.png'],
  423. ['c1-A-h', baseUrl + 'info_box/c1-A-h.png'],
  424. ['c1-B-h', baseUrl + 'info_box/c1-B-h.png'],
  425. ['c1-diff-1', baseUrl + 'info_box/c1-diff-1.png'],
  426. ['c1-diff-5', baseUrl + 'info_box/c1-diff-5.png'],
  427. ['c1-label', baseUrl + 'info_box/c1-label.png'],
  428. ['map-c1s2', baseUrl + 'info_box/map-c1s2.png'],
  429. ['map-s1', baseUrl + 'info_box/map-s1.png'],
  430. ['s1-A', baseUrl + 'info_box/s1-A.png'],
  431. ['s1-A-h', baseUrl + 'info_box/s1-A-h.png'],
  432. ['s1-B-h', baseUrl + 'info_box/s1-B-h.png'],
  433. ['s1-diff-1', baseUrl + 'info_box/s1-diff-1.png'],
  434. ['s1-diff-3', baseUrl + 'info_box/s1-diff-3.png'],
  435. ['s1-label', baseUrl + 'info_box/s1-label.png'],
  436. ['s2', baseUrl + 'info_box/s2.png'],
  437. ['s2-A-h', baseUrl + 'info_box/s2-A-h.png'],
  438. ['s2-B-h', baseUrl + 'info_box/s2-B-h.png'],
  439. ['s2-diff-1', baseUrl + 'info_box/s2-diff-1.png'],
  440. ['s2-diff-5', baseUrl + 'info_box/s2-diff-5.png'],
  441. ['s2-label', baseUrl + 'info_box/s2-label.png'],
  442. ['operation_plus', baseUrl + 'info_box/operation_plus.png'],
  443. ['operation_minus', baseUrl + 'info_box/operation_minus.png'],
  444. ['operation_mixed', baseUrl + 'info_box/operation_mixed.png'],
  445. ['operation_equals', baseUrl + 'info_box/operation_equals.png'],
  446. ],
  447. sprite: [
  448. // Game Sprites
  449. ['kid_walk', baseUrl + 'character/kid/walk.png', 26],
  450. // Navigation icons on the top of the page
  451. ['audio', baseUrl + 'navig_icon/audio.png', 2],
  452. // Interactive icons
  453. ['select', baseUrl + 'interac_icon/selection_box.png', 2],
  454. ['btn_square', baseUrl + 'interac_icon/button_square.png', 2],
  455. // Menu icons - Game modes
  456. ['mode0', baseUrl + 'levels/squareOne_1.png', 2], // Square I : A
  457. ['mode1', baseUrl + 'levels/squareOne_2.png', 2], // Square I : B
  458. ['mode2', baseUrl + 'levels/circleOne_1.png', 2], // Circle I : A
  459. ['mode3', baseUrl + 'levels/circleOne_2.png', 2], // Circle I : B
  460. ['mode4', baseUrl + 'levels/squareTwo_1.png', 2], // Square II : A
  461. ['mode5', baseUrl + 'levels/squareTwo_2.png', 2], // Square II : B
  462. ['mode6', baseUrl + 'levels/scaleOne_1.png', 2], // Scale I : A
  463. // Menu icons - Math operations
  464. ['operation_plus', baseUrl + 'levels/operation_plus.png', 2], // Square/circle I : right
  465. ['operation_minus', baseUrl + 'levels/operation_minus.png', 2], // Square/circle I : left
  466. ['operation_mixed', baseUrl + 'levels/operation_mixed.png', 2], // Circle I : mixed
  467. ['operation_equals', baseUrl + 'levels/operation_equals.png', 2], // Square II : equals
  468. ],
  469. audio: [
  470. // Sound effects
  471. ['beepSound', ['src/assets/audio/beep.ogg', 'src/assets/audio/beep.mp3']],
  472. ['okSound', ['src/assets/audio/ok.ogg', 'src/assets/audio/ok.mp3']],
  473. [
  474. 'errorSound',
  475. ['src/assets/audio/error.ogg', 'src/assets/audio/error.mp3'],
  476. ],
  477. ['popSound', ['', 'src/assets/audio/pop.wav']],
  478. ],
  479. },
  480. squareOne: {
  481. image: [
  482. // Map buildings
  483. ['farm', baseUrl + 'scene/farm.png'],
  484. ['garage', baseUrl + 'scene/garage.png'],
  485. ],
  486. sprite: [
  487. // Game sprites
  488. ['tractor', baseUrl + 'character/tractor/tractor.png', 15],
  489. ],
  490. audio: [],
  491. },
  492. squareTwo: {
  493. image: [
  494. // Map buildings
  495. ['house', baseUrl + 'scene/house.png'],
  496. ['school', baseUrl + 'scene/school.png'],
  497. ],
  498. sprite: [
  499. // Game sprites
  500. ['kid_standing', baseUrl + 'character/kid/lost.png', 6],
  501. ['kid_run', baseUrl + 'character/kid/run.png', 12],
  502. ],
  503. audio: [],
  504. },
  505. circleOne: {
  506. image: [
  507. // Map buildings
  508. ['house', baseUrl + 'scene/house.png'],
  509. ['school', baseUrl + 'scene/school.png'],
  510. // Game images
  511. ['balloon', baseUrl + 'character/balloon/airballoon_upper.png'],
  512. ['balloon_basket', baseUrl + 'character/balloon/airballoon_base.png'],
  513. ],
  514. sprite: [
  515. // Game sprites
  516. ['kid_run', baseUrl + 'character/kid/run.png', 12],
  517. ],
  518. audio: [],
  519. },
  520. scaleOne: {
  521. image: [
  522. // Map buildings
  523. ['farm', baseUrl + 'scene/farm.png'],
  524. ['garage', baseUrl + 'scene/garage.png'],
  525. ['scale_base', baseUrl + 'character/scale/scale_base.png'],
  526. ['scale_top', baseUrl + 'character/scale/scale_top.png'],
  527. ['scale_plate', baseUrl + 'character/scale/scale_plate.png'],
  528. ],
  529. sprite: [
  530. // Game sprites
  531. ['tractor', baseUrl + 'character/tractor/tractor.png', 15],
  532. ['floor_snow', baseUrl + 'scene/floor_snow.png', 9],
  533. ],
  534. audio: [],
  535. },
  536. };