[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [gcompris/sok_iamutkarshtiwari_railroad] src/activities/railroad: Railroad, ensured non-repeative wa
From: Utkarsh Tiwari <null () kde ! org>
Date: 2016-12-15 22:27:03
Message-ID: E1cHeUR-00050P-Jh () code ! kde ! org
[Download RAW message or body]
Git commit 9189f020eb79299248ab990b8de1eae8794d628f by Utkarsh Tiwari.
Committed on 15/12/2016 at 22:26.
Pushed by utkarshtiwari into branch 'sok_iamutkarshtiwari_railroad'.
Railroad, ensured non-repeative wagon setup question
M +7 -3 src/activities/railroad/railroad.js
https://commits.kde.org/gcompris/9189f020eb79299248ab990b8de1eae8794d628f
diff --git a/src/activities/railroad/railroad.js b/src/activities/railroad/railroad.js
index 3cbfe091..52da9d1c 100644
--- a/src/activities/railroad/railroad.js
+++ b/src/activities/railroad/railroad.js
@@ -45,6 +45,7 @@ function stop() {
function initLevel() {
var index = 0;
memoryMode = false;
+ items.animateFlow.stop(); // Stops any previous animations
items.listModel.clear();
items.displayList.model = items.listModel;
if (isReset == false) {
@@ -53,11 +54,15 @@ function initLevel() {
for (var i = 0; i < currentLevel + 2; i++) {
if (i == (currentLevel + 1)) {
// Selects the last carriage
- index = Math.floor(Math.random() * 9) + 1;
+ do {
+ index = Math.floor(Math.random() * 9) + 1;
+ } while (backupArray.indexOf(index) != -1) // Ensures non-repeative wagons setup
} else {
// Selects the follow up wagons
- index = Math.floor(Math.random() * 12) + 10;
+ do {
+ index = Math.floor(Math.random() * 12) + 10;
+ } while (backupArray.indexOf(index) != -1)
}
backupArray.push(index);
items.listModel.append({"name" : index});
@@ -94,7 +99,6 @@ function previousLevel() {
function reset() {
isReset = true;
- items.animateFlow.stop();
initLevel();
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic