Changeset View
Changeset View
Standalone View
Standalone View
src/activities/planegame/planegame.js
Show All 35 Lines | |||||
36 | var upPressed | 36 | var upPressed | ||
37 | var downPressed | 37 | var downPressed | ||
38 | var leftPressed | 38 | var leftPressed | ||
39 | var rightPressed | 39 | var rightPressed | ||
40 | 40 | | |||
41 | var items | 41 | var items | ||
42 | var dataset | 42 | var dataset | ||
43 | 43 | | |||
44 | var cloudComponent = Qt.createComponent(url + "Cloud.qml"); | 44 | var cloudComponent = Qt.createComponent(url + "Cloud.qml"); | ||
jjazeix: these are specific to numbers-odd-even activity, the instructions should be on its folder (you… | |||||
45 | var clouds = new Array; | 45 | var clouds = new Array; | ||
46 | var cloudsErased = new Array; | 46 | var cloudsErased = new Array; | ||
47 | 47 | | |||
48 | function start(items_, dataset_) { | 48 | function start(items_, dataset_) { | ||
49 | Core.checkForVoices(items_.background); | 49 | Core.checkForVoices(items_.background); | ||
50 | 50 | | |||
51 | items = items_ | 51 | items = items_ | ||
52 | dataset = dataset_ | 52 | dataset = dataset_ | ||
53 | numberOfLevel = dataset.length | 53 | numberOfLevel = dataset.length | ||
54 | currentLevel = 0 | 54 | currentLevel = 0 | ||
55 | if(items.showTutorial === false) { | ||||
55 | initLevel() | 56 | initLevel() | ||
56 | } | 57 | } | ||
jjazeix: indentation | |||||
58 | } | ||||
57 | 59 | | |||
58 | function stop() { | 60 | function stop() { | ||
59 | cloudDestroy(clouds) | 61 | cloudDestroy(clouds) | ||
60 | cloudDestroy(cloudsErased) | 62 | cloudDestroy(cloudsErased) | ||
61 | items.movePlaneTimer.stop() | 63 | items.movePlaneTimer.stop() | ||
62 | items.cloudCreation.stop() | 64 | items.cloudCreation.stop() | ||
63 | } | 65 | } | ||
64 | 66 | | |||
Show All 10 Lines | |||||
75 | function initLevel() { | 77 | function initLevel() { | ||
76 | items.bar.level = currentLevel + 1; | 78 | items.bar.level = currentLevel + 1; | ||
77 | currentSubLevel = 0 | 79 | currentSubLevel = 0 | ||
78 | numberOfSubLevels = dataset[currentLevel].data.length | 80 | numberOfSubLevels = dataset[currentLevel].data.length | ||
79 | 81 | | |||
80 | items.movePlaneTimer.stop(); | 82 | items.movePlaneTimer.stop(); | ||
81 | items.cloudCreation.stop() | 83 | items.cloudCreation.stop() | ||
82 | 84 | | |||
83 | items.score.visible = dataset[currentLevel].showNext | | |||
84 | items.score.message = dataset[currentLevel].data[currentSubLevel] | 85 | items.score.message = dataset[currentLevel].data[currentSubLevel] | ||
85 | 86 | | |||
86 | upPressed = false | 87 | upPressed = false | ||
87 | downPressed = false | 88 | downPressed = false | ||
88 | leftPressed = false | 89 | leftPressed = false | ||
89 | rightPressed = false | 90 | rightPressed = false | ||
90 | 91 | | |||
91 | cloudDestroy(clouds) | 92 | cloudDestroy(clouds) | ||
92 | cloudDestroy(cloudsErased) | 93 | cloudDestroy(cloudsErased) | ||
93 | 94 | | |||
94 | // Tend towards 0.5 ratio | 95 | // Tend towards 0.5 ratio | ||
95 | items.plane.state = "init" | 96 | items.plane.state = "init" | ||
96 | items.movePlaneTimer.interval = 1000 | 97 | items.movePlaneTimer.interval = 1000 | ||
97 | items.movePlaneTimer.start(); | 98 | items.movePlaneTimer.start(); | ||
99 | items.score.visible = dataset[currentLevel].showNext | ||||
98 | items.cloudCreation.start() | 100 | items.cloudCreation.start() | ||
101 | | ||||
99 | // Inject the first cloud now | 102 | //Inject the first cloud now | ||
100 | createCloud() | 103 | createCloud() | ||
101 | } | 104 | } | ||
102 | 105 | | |||
103 | function nextLevel() { | 106 | function nextLevel() { | ||
104 | if(numberOfLevel <= ++currentLevel) { | 107 | if(numberOfLevel <= ++currentLevel) { | ||
105 | currentLevel = 0 | 108 | currentLevel = 0 | ||
106 | } | 109 | } | ||
107 | | ||||
108 | initLevel(); | 110 | initLevel(); | ||
jjazeix: indentation | |||||
109 | } | 111 | } | ||
110 | 112 | | |||
111 | function previousLevel() { | 113 | function previousLevel() { | ||
112 | if(--currentLevel < 0) { | 114 | if(--currentLevel < 0) { | ||
113 | currentLevel = numberOfLevel - 1 | 115 | currentLevel = numberOfLevel - 1 | ||
114 | } | 116 | } | ||
115 | initLevel(); | 117 | initLevel(); | ||
jjazeix: indentation | |||||
116 | } | 118 | } | ||
117 | 119 | | |||
118 | function repositionObjectsOnWidthChanged(factor) { | 120 | function repositionObjectsOnWidthChanged(factor) { | ||
119 | if(items && items.plane) { | 121 | if(items && items.plane) { | ||
120 | items.movePlaneTimer.interval = 1000 | 122 | items.movePlaneTimer.interval = 1000 | ||
121 | items.plane.state = "init" | 123 | items.plane.state = "init" | ||
122 | } | 124 | } | ||
123 | for(var i = clouds.length - 1; i >= 0 ; --i) { | 125 | for(var i = clouds.length - 1; i >= 0 ; --i) { | ||
▲ Show 20 Lines • Show All 210 Lines • Show Last 20 Lines |
these are specific to numbers-odd-even activity, the instructions should be on its folder (you can put them in the qml)