Guest User

Untitled

a guest
Nov 24th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.47 KB | None | 0 0
  1. var questions = [ // structure: ["question",["choice1", "choice2", "choice3"], answer index]
  2. ["1+0",["1","2","3"],0],
  3. ["1+1",["1","2","3"],1],
  4. ["1+3",["1","4","3"],1],
  5. ["1+4",["1","5","3"],1],
  6. ["1+2",["1","2","3"],2]
  7. ]
  8. var cupPos = [
  9. [[4,119,233],[114,91,113]],
  10. [[13,127,242],[114,91,113]],
  11. [[32,137,243],[113,91,113]],
  12. [[57,147,238],[113,91,113]],
  13. [[76,153,233],[114,91,113]]
  14. ]
  15. var asked = new Array()
  16.  
  17. function rand() {
  18. var position = [10,130,230]
  19. var random = Math.floor(Math.random() * position.length)
  20. diePos = random
  21. ldrdie.sourceComponent = diecomp
  22. }
  23. function questions() {
  24. return questions
  25. }
  26. function cupPos() {
  27. return cupPos
  28. }
  29.  
  30. function ask() {
  31. randquestion = Math.floor(Math.random() * questions.length)
  32. if (asked.length != 0) {
  33. var i = asked.length - 1
  34. do {
  35. if (asked.indexOf(randquestion) != -1) {
  36. randquestion = Math.floor(Math.random() * questions.length)
  37. } else { break; }
  38. } while (i--)
  39. }
  40. question.text = questions[randquestion][0]
  41. asked.push(randquestion)
  42. c1.text = questions[randquestion][1][0]
  43. c2.text = questions[randquestion][1][1]
  44. c3.text = questions[randquestion][1][2]
  45. }
  46. function checkanswer() {
  47. question.opacity = 0
  48. c1.opacity = 0
  49. c2.opacity = 0
  50. c3.opacity = 0
  51. tmr5.running = true
  52. if (answer == questions[randquestion][2]) {
  53. correct.text = "Correct!"
  54. } else {
  55. wrong.text = "Wrong!"
  56. }
  57. }
  58. function func() {
  59. if (answer == questions[randquestion][2]) {
  60. if (level < 5) {
  61. level += 1
  62. leveltxt.text = "Level: " + level
  63. cupimg = "IMAGES FOR THESIS/for cups/lvl" + level + "CUP.png"
  64. dieimg = "IMAGES FOR THESIS/for dice/lvl" + level + "die.png"
  65. nextbtn.visible = false
  66. } else {
  67. exe2.opacity = 1
  68. tmr4.running = true
  69. }
  70. tmr5.running = false
  71. correct.text = ""
  72. askscreen.visible = false
  73. } else {
  74. ask()
  75. wrong.text = ""
  76. tmr5.running = false
  77. question.opacity = 1
  78. c1.opacity = 1
  79. c2.opacity = 1
  80. c3.opacity = 1
  81. }
  82. cup1.x = cupPos[level - 1][0][0]; cup1.y = cupPos[level - 1][1][0]
  83. cup2.x = cupPos[level - 1][0][1]; cup2.y = cupPos[level - 1][1][1]
  84. cup3.x = cupPos[level - 1][0][2]; cup3.y = cupPos[level - 1][1][2]
  85. rand()
  86. startbtn.visible = true
  87. startbtn.enabled = true
  88. }
Add Comment
Please, Sign In to add comment