Changeset View
Changeset View
Standalone View
Standalone View
src/activities/memory/memory.js
Show All 31 Lines | |||||
32 | var cardLeft | 32 | var cardLeft | ||
33 | var cardList | 33 | var cardList | ||
34 | 34 | | |||
35 | function start(items_) { | 35 | function start(items_) { | ||
36 | 36 | | |||
37 | items = items_ | 37 | items = items_ | ||
38 | 38 | | |||
39 | currentLevel = 0 | 39 | currentLevel = 0 | ||
40 | numberOfLevel = items.dataset.length | 40 | numberOfLevel = items.levels.length | ||
41 | 41 | | |||
42 | initLevel() | 42 | initLevel() | ||
43 | } | 43 | } | ||
44 | 44 | | |||
45 | function stop() { | 45 | function stop() { | ||
46 | } | 46 | } | ||
47 | 47 | | |||
48 | function initLevel() { | 48 | function initLevel() { | ||
49 | items.bar.level = currentLevel + 1 | 49 | items.bar.level = currentLevel + 1 | ||
50 | items.containerModel.clear() | 50 | items.containerModel.clear() | ||
51 | items.playQueue = [] | 51 | items.playQueue = [] | ||
52 | items.tuxTurn = false | 52 | items.tuxTurn = false | ||
53 | items.selectionCount = 0 | 53 | items.selectionCount = 0 | ||
54 | items.blockClicks = false | 54 | items.blockClicks = false | ||
55 | 55 | | |||
56 | // compute the number of cards | 56 | // compute the number of cards | ||
57 | var columns = items.dataset[currentLevel].columns | 57 | var columns = items.levels[currentLevel].columns | ||
58 | var rows = items.dataset[currentLevel].rows | 58 | var rows = items.levels[currentLevel].rows | ||
59 | var images = items.dataset[currentLevel].images | 59 | var images = items.levels[currentLevel].images | ||
60 | var sounds = items.dataset[currentLevel].sounds | 60 | var sounds = items.levels[currentLevel].sounds | ||
61 | var texts = items.dataset[currentLevel].texts | 61 | var texts = items.levels[currentLevel].texts | ||
62 | items.columns = columns | 62 | items.columns = columns | ||
63 | items.rows = rows | 63 | items.rows = rows | ||
64 | nbOfPair = rows * columns / 2 | 64 | nbOfPair = rows * columns / 2 | ||
65 | cardLeft = nbOfPair * 2 | 65 | cardLeft = nbOfPair * 2 | ||
66 | 66 | | |||
67 | // Check the provided dataset has enough data | 67 | // Check the provided dataset has enough data | ||
68 | var maxData = Math.max( | 68 | var maxData = Math.max( | ||
69 | images ? images.length : 0, | 69 | images ? images.length : 0, | ||
▲ Show 20 Lines • Show All 195 Lines • Show Last 20 Lines |