Guest User

Untitled

a guest
Nov 23rd, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.52 KB | None | 0 0
  1. import QtQuick 1.0
  2. import "gameCore.js" as Game
  3.  
  4. Rectangle {
  5. width: 360
  6. height: 480
  7.  
  8. property int diePos: 0
  9. property int shuffSpeed: 750
  10. property int level: 1
  11. property int randquestion: 0
  12. property int answer: 0
  13. property url cupimg: "IMAGES FOR THESIS/for cups/lvl1CUP.png"
  14. property url dieimg: "IMAGES FOR THESIS/for dice/lvl1die.png"
  15.  
  16. Image {
  17. id: bg
  18. anchors.fill: parent
  19. source: "IMAGES FOR THESIS/for backgrounds/CUPbackground.png"
  20.  
  21. Component {
  22. id: diecomp
  23.  
  24. Image {
  25. id: die
  26. y: 233
  27. source: dieimg
  28.  
  29. Component.onCompleted: {
  30. switch (diePos) {
  31. case 0: x = cup1.x + (cup1.width - width) / 2; break;
  32. case 1: x = cup2.x + (cup2.width - width) / 2; break;
  33. case 2: x = cup3.x + (cup3.width - width) / 2; break;
  34. }
  35. var diePosY = [233,218,205,187,170]
  36. y = diePosY[level - 1]
  37. console.log(y)
  38. }
  39. }
  40. }
  41. Loader {
  42. id: ldrdie
  43. }
  44.  
  45. Button {
  46. id: cup1
  47. y: 114
  48. x: 4
  49. enabled: false
  50. normalImage: cupimg
  51. pressedImage: cupimg
  52. onClicked: {
  53. na1.running = true
  54. select.opacity = 0
  55. cup2.enabled = false
  56. cup3.enabled = false
  57. if (diePos == 0) {
  58. exe.opacity = 1
  59. nextbtn.visible = true
  60. } else { wro.opacity = 1 }
  61. }
  62.  
  63. NumberAnimation{id: na1; target: cup1; property: "y"; to: 50; duration: 750}
  64. }
  65. Button {
  66. id: cup2
  67. x: 119
  68. y: 91
  69. enabled: false
  70. normalImage: cupimg
  71. pressedImage: cupimg
  72. onClicked: {
  73. na2.running = true
  74. select.opacity = 0
  75. cup1.enabled = false
  76. cup3.enabled = false
  77. if (diePos == 1) {
  78. exe.opacity = 1
  79. nextbtn.visible = true
  80. } else { wro.opacity = 1 }
  81. }
  82.  
  83. NumberAnimation{id: na2; target: cup2; property: "y"; to: 50; duration: 750}
  84.  
  85. }
  86. Button {
  87. id: cup3
  88. x: 233
  89. y: 113
  90. enabled: false
  91. normalImage: cupimg
  92. pressedImage: cupimg
  93. onClicked: {
  94. na3.running = true
  95. select.opacity = 0
  96. cup1.enabled = false
  97. cup2.enabled = false
  98. if (diePos == 2) {
  99. exe.opacity = 1
  100. nextbtn.visible = true
  101. } else { wro.opacity = 1 }
  102. }
  103.  
  104. NumberAnimation{id: na3; target: cup3; property: "y"; to: 50; duration: 750}
  105.  
  106. }
  107. Button {
  108. id: startbtn
  109. x:60
  110. y:377
  111. width: 249
  112. height:75
  113. normalImage: "IMAGES FOR THESIS/for buttons/startbutton.png"
  114. pressedImage: "IMAGES FOR THESIS/for buttons/startbutton.png"
  115. onClicked: {
  116. switch (level) {
  117. case 1: sta.running = true; break
  118. case 2: sta2.running = true; break
  119. case 3: sta3.running = true; break
  120. case 4: sta4.running = true; break
  121. case 5: sta5.running = true; break
  122. }
  123. tmr.running = true
  124. startbtn.enabled = false
  125. }
  126. }
  127. Button {
  128. id: resetbtn
  129. x:60
  130. y:377
  131. width: 249
  132. height:75
  133. visible: false
  134. normalImage: "IMAGES FOR THESIS/for buttons/retrybutton.png"
  135. pressedImage: "IMAGES FOR THESIS/for buttons/retrybutton.png"
  136. onClicked: {
  137. var cupPos = [
  138. [[4,119,233],[114,91,113]],
  139. [[13,127,242],[114,91,113]],
  140. [[32,137,243],[113,91,113]],
  141. [[57,147,238],[113,91,113]],
  142. [[76,153,233],[114,91,113]]
  143. ]
  144. cup1.x = cupPos[level - 1][0][0]; cup1.y = cupPos[level - 1][1][0]
  145. cup2.x = cupPos[level - 1][0][1]; cup2.y = cupPos[level - 1][1][1]
  146. cup3.x = cupPos[level - 1][0][2]; cup3.y = cupPos[level - 1][1][2]
  147. Game.rand()
  148. wro.opacity = 0
  149. visible = false
  150. startbtn.visible = true
  151. startbtn.enabled = true
  152. }
  153. }
  154. Button {
  155. id: nextbtn
  156. x:60
  157. y:377
  158. width: 249
  159. height:75
  160. visible: false
  161. normalImage: "IMAGES FOR THESIS/for buttons/nextbutton.png"
  162. pressedImage: "IMAGES FOR THESIS/for buttons/nextbutton.png"
  163. onClicked: {
  164. warning.opacity = 1
  165. exe.opacity = 0
  166. tmr3.running = true
  167. ldrdie.sourceComponent = null
  168. }
  169. }
  170. }
  171. Text {
  172. id: exe
  173. x: 135
  174. y: 292
  175. text: "Excellent!"
  176. font.family: "Imprint MT Shadow"
  177. anchors.verticalCenterOffset: 64
  178. anchors.horizontalCenter: parent.horizontalCenter
  179. color: "white"
  180. font.pointSize: 15
  181. anchors.centerIn: parent
  182. opacity: 0
  183. }
  184. Text {
  185. id:wro
  186. x: 108
  187. y: 298
  188. text: "You Lost! Try Again"
  189. anchors.verticalCenterOffset: 68
  190. anchors.horizontalCenter: parent.horizontalCenter
  191. font.pointSize: 12
  192. font.family: "Imprint MT Shadow"
  193. color: "white"
  194. anchors.centerIn: parent
  195. opacity: 0
  196. onOpacityChanged: {
  197. if (opacity) {
  198. startbtn.visible = false
  199. resetbtn.visible = true
  200. }
  201. }
  202. }
  203. Text {
  204. id: select
  205. text: "Select A Cup!"
  206. anchors.verticalCenterOffset: 68
  207. anchors.horizontalCenter: parent.horizontalCenter
  208. font.pointSize: 12
  209. font.family: "Imprint MT Shadow"
  210. color: "white"
  211. anchors.centerIn: parent
  212. opacity: 0
  213.  
  214. }
  215. Text {
  216. id: warning
  217. text: "Oops! Before you can go to the next level,\nyou must answer this question first!"
  218. horizontalAlignment: Text.AlignHCenter
  219. anchors.verticalCenterOffset: 68
  220. anchors.horizontalCenter: parent.horizontalCenter
  221. font.pointSize: 12
  222. font.family: "Imprint MT Shadow"
  223. color: "white"
  224. anchors.centerIn: parent
  225. opacity: 0
  226. }
  227. Text {
  228. id: leveltxt
  229. opacity: 1
  230. x: 161
  231. y: 2
  232. color: "white"
  233. text:"Level: 1"
  234. anchors.rightMargin: -156
  235. anchors.bottomMargin: -1
  236. anchors.leftMargin: 156
  237. anchors.topMargin: 2
  238. font.pointSize: 4
  239. styleColor: "white"
  240. }
  241. Text {
  242. id: exe2
  243. x: 135
  244. y: 292
  245. text: "Congrats! You already finished the game. \nHere is your reward!"
  246. horizontalAlignment: Text.AlignHCenter
  247. font.family: "Imprint MT Shadow"
  248. anchors.verticalCenterOffset: 64
  249. anchors.horizontalCenter: parent.horizontalCenter
  250. color: "white"
  251. font.pointSize: 15
  252. anchors.centerIn: parent
  253. opacity: 0
  254. }
  255.  
  256. Image {
  257. id: askscreen
  258. anchors.fill: parent
  259. source: "IMAGES FOR THESIS/for backgrounds/background.png"
  260. visible: false
  261.  
  262. Text {
  263. id: question
  264. text: ""
  265. font.pointSize: 12
  266. font.family: "Imprint MT Shadow"
  267. color: "white"
  268. anchors.centerIn: parent
  269. horizontalAlignment: Text.AlignHCenter
  270. }
  271. Text {
  272. id: c1
  273. text: ""
  274. font.pointSize: 12
  275. font.family: "Imprint MT Shadow"
  276. color: "white"
  277. anchors.top: question.bottom
  278. anchors.topMargin: 5
  279. anchors.horizontalCenter: parent.horizontalCenter
  280.  
  281. MouseArea {
  282. anchors.fill: parent
  283. onClicked: {
  284. answer = 0
  285. Game.checkanswer()
  286. }
  287. }
  288. }
  289. Text {
  290. id: c2
  291. text: ""
  292. font.pointSize: 12
  293. font.family: "Imprint MT Shadow"
  294. color: "white"
  295. anchors.top: c1.bottom
  296. anchors.topMargin: 5
  297. anchors.horizontalCenter: parent.horizontalCenter
  298.  
  299. MouseArea {
  300. anchors.fill: parent
  301. onClicked: {
  302. answer = 1
  303. Game.checkanswer()
  304. }
  305. }
  306. }
  307. Text {
  308. id: c3
  309. text: ""
  310. font.pointSize: 12
  311. font.family: "Imprint MT Shadow"
  312. color: "white"
  313. anchors.top: c2.bottom
  314. anchors.topMargin: 5
  315. anchors.horizontalCenter: parent.horizontalCenter
  316.  
  317. MouseArea {
  318. anchors.fill: parent
  319. onClicked: {
  320. answer = 2
  321. Game.checkanswer()
  322. }
  323. }
  324. }
  325. }
  326. Image {
  327. id: reward
  328. anchors.fill: parent
  329. source: "IMAGES FOR THESIS/horror/mumu.jpg"
  330. visible: false
  331. }
  332.  
  333. Timer {
  334. id: tmr
  335. interval: 750
  336. onTriggered: {
  337. tmr2.running = true
  338. ldrdie.sourceComponent = null
  339. }
  340. }
  341. Timer {
  342. id: tmr2
  343. interval: 6750
  344. onTriggered: {
  345. ldrdie.sourceComponent = diecomp
  346. select.opacity = 1.0
  347. cup1.enabled = true
  348. cup2.enabled = true
  349. cup3.enabled = true
  350. }
  351. }
  352. Timer {
  353. id: tmr3
  354. interval: 3000
  355. onTriggered: {
  356. warning.opacity = 0
  357. askscreen.visible = true
  358. Game.ask()
  359. }
  360. }
  361. Timer {
  362. id: tmr4
  363. interval: 10000
  364. onTriggered: {
  365. askscreen.visible = false
  366. reward.visible = true
  367. }
  368. }
  369.  
  370. SequentialAnimation {
  371. id: sta
  372. running: false;
  373.  
  374. ParallelAnimation {
  375. NumberAnimation {target: cup1; property: "y"; to: 160; duration: 750}
  376. NumberAnimation {target: cup2;property: "y"; to:160; duration:750}
  377. NumberAnimation {target: cup3; property: "y"; to: 160; duration:750}
  378. }
  379. ParallelAnimation {
  380. NumberAnimation {target:cup2; property: "x"; to: 233; duration: 450}
  381. }
  382. ParallelAnimation {
  383. NumberAnimation {target:cup2; property: "x"; to: 4; duration: 450}
  384. NumberAnimation {target: cup1; property: "x"; to: 119; duration:450}
  385. }
  386. ParallelAnimation {
  387. NumberAnimation {target: cup1;property: "x";to: 233; duration: 450}
  388. NumberAnimation {target: cup3;property: "x"; to: 119; duration: 450}
  389. }
  390. ParallelAnimation {
  391. NumberAnimation {target: cup2; property: "x"; to: 233; duration: 450}
  392. NumberAnimation {target: cup1;property: "x"; to: 4; duration: 450}
  393. }
  394. ParallelAnimation {
  395. NumberAnimation {target: cup3; property: "x"; to: 4; duration: 450}
  396. NumberAnimation {target: cup1; property: "x"; to: 233; duration: 450}
  397. NumberAnimation {target: cup2; property: "x"; to: 119; duration: 450}
  398. }
  399. ParallelAnimation {
  400. NumberAnimation {target: cup1; property: "x"; to: 4; duration: 450}
  401. NumberAnimation {target: cup3; property: "x"; to: 233; duration: 450}
  402. }
  403. ParallelAnimation {
  404. NumberAnimation {target: cup1; property: "x"; to: 119; duration: 400}
  405. NumberAnimation {target: cup2; property: "x"; to: 4; duration: 400}
  406. }
  407. ParallelAnimation {
  408. NumberAnimation {target: cup1; property: "x"; to: 233; duration: 400}
  409. NumberAnimation {target: cup3; property: "x"; to: 119; duration: 400}
  410. }
  411. ParallelAnimation {
  412. NumberAnimation {target: cup2; property: "x"; to: 119; duration: 400}
  413. NumberAnimation {target: cup3; property: "x"; to: 4; duration: 400}
  414. }
  415. ParallelAnimation {
  416. NumberAnimation {target: cup2; property: "x"; to: 233; duration: 400}
  417. NumberAnimation {target: cup1; property: "x"; to: 119; duration: 400}
  418. }
  419. ParallelAnimation {
  420. NumberAnimation {target: cup1; property: "x"; to: 4; duration: 400}
  421. NumberAnimation {target: cup3; property: "x"; to: 119; duration: 400}
  422. }
  423. ParallelAnimation {
  424. NumberAnimation {target: cup2; property: "x"; to: 4; duration: 400}
  425. NumberAnimation {target: cup1; property: "x"; to: 233; duration: 400}
  426. }
  427. ParallelAnimation {
  428. NumberAnimation {target: cup1; property: "x"; to: 119; duration: 400}
  429. NumberAnimation {target: cup3; property: "x"; to: 233; duration: 400}
  430. }
  431. ParallelAnimation {
  432. NumberAnimation {target: cup2; property: "x"; to: 233; duration: 400}
  433. NumberAnimation {target: cup3; property: "x"; to: 4; duration: 400}
  434. }
  435. ParallelAnimation {
  436. NumberAnimation {target: cup3; property: "x"; to: 233; duration: 400}
  437. NumberAnimation {target: cup2; property: "x"; to: 4; duration: 400}
  438. }
  439. }
  440.  
  441. Component.onCompleted: {
  442. Game.rand()
  443. }
  444. }
Add Comment
Please, Sign In to add comment