diff --git a/src/activities/target/ActivityInfo.qml b/src/activities/target/ActivityInfo.qml index 5be887ab9..be3346b57 100644 --- a/src/activities/target/ActivityInfo.qml +++ b/src/activities/target/ActivityInfo.qml @@ -1,40 +1,41 @@ /* GCompris - ActivityInfo.qml * * Copyright (C) 2015 Bruno Coudoin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . */ import GCompris 1.0 ActivityInfo { name: "target/Target.qml" difficulty: 2 icon: "target/target.svg" author: "Bruno Coudoin <bruno.coudoin@gcompris.net>" demo: false //: Activity title title: qsTr("Practice addition with a target game") //: Help title description: qsTr("Hit the target and count your points") // intro: "Click on the target to launch darts, then count your final score!" //: Help goal goal: qsTr("Throw darts at a target and count your score.") //: Help prerequisite prerequisite: qsTr("Can move the mouse, can read numbers and count up to 15 for the first level") //: Help manual manual: qsTr("Check the speed and direction of the target, and then click on it to launch a dart. When all your darts are thrown, you are asked to count your score. Enter the score with the keyboard.") credit: "" section: "math addition arithmetic" createdInVersion: 0 + levels: "1,2,3,4,5" } diff --git a/src/activities/target/Target.qml b/src/activities/target/Target.qml index 9fe5bd1d9..e4be14bc6 100644 --- a/src/activities/target/Target.qml +++ b/src/activities/target/Target.qml @@ -1,242 +1,266 @@ /* GCompris - target.qml * * Copyright (C) 2014 Bruno coudoin * * Authors: * Bruno Coudoin (GTK+ version) * Bruno Coudoin (Qt Quick port) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . */ import QtQuick 2.6 import GCompris 1.0 import "../../core" import "target.js" as Activity ActivityBase { id: activity onStart: focus = true onStop: {} pageComponent: Item { id: background anchors.fill: parent signal start signal stop signal targetReached Keys.onPressed: { if(items.currentArrow != items.nbArrow) return if(event.key === Qt.Key_Backspace) { backspace() } appendText(event.text) } Component.onCompleted: { + dialogActivityConfig.initialize() activity.start.connect(start) activity.stop.connect(stop) } // Add here the QML items you need to access in javascript QtObject { id: items property Item main: activity.main property alias background: background property alias bar: bar property alias bonus: bonus property alias targetModel: targetItem.model + property var levels: activity.datasetLoader.item.data property alias targetItem: targetItem property alias userEntry: userEntry property int currentArrow property int nbArrow property int currentSubLevel property int numberOfSubLevel property bool arrowFlying onNbArrowChanged: { arrowRepeater.init(nbArrow) } } onStart: { keyboard.populate(); Activity.start(items) } onStop: { Activity.stop() } TargetItem { id: targetItem } onTargetReached: { items.arrowFlying = false if(items.currentArrow == items.nbArrow) { targetItem.stop() targetItem.scoreText += " = " userEntry.text = "?" } } Arrow { id: arrowRepeater } Image { id: cross anchors.centerIn: parent source: Activity.url + "cross.svg" opacity: items.currentArrow != items.nbArrow ? 1 : 0 sourceSize.width: 50 * ApplicationInfo.ratio } MouseArea { id: mouseArea anchors.fill: parent enabled: items.currentArrow != items.nbArrow && !items.arrowFlying onClicked: { activity.audioEffects.play(Activity.url + 'arrow.wav') items.arrowFlying = true if(items.currentArrow != items.nbArrow) { arrowRepeater.itemAt(items.currentArrow).opacity = 1 arrowRepeater.itemAt(items.currentArrow++).scale = 0.5 } } } GCText { id: scoreItem anchors.horizontalCenter: parent.horizontalCenter width: parent.width text: targetItem.scoreText fontSize: 22 font.bold: true style: Text.Outline styleColor: "black" color: "white" wrapMode: Text.WordWrap horizontalAlignment: Text.AlignHCenter } function backspace() { userEntry.text = userEntry.text.slice(0, -1) if(userEntry.text.length === 0) { userEntry.text = "?" } else { if(targetItem.scoreTotal === userEntry.text) bonus.good("flower") } } function appendText(text) { if(text === keyboard.backspace) { backspace() return } var number = parseInt(text) if(isNaN(number)) return if(userEntry.text === "?") { userEntry.text = "" } if(userEntry.text.length > ('' + targetItem.scoreTotal).length) { return } userEntry.text += text - if(targetItem.scoreTotal === userEntry.text) + if(targetItem.scoreTotal.toString() === userEntry.text) bonus.good("flower") } GCText { id: userEntry anchors.top: scoreItem.bottom width: parent.width fontSize: 22 font.bold: true style: Text.Outline styleColor: "black" color: "white" wrapMode: Text.WordWrap horizontalAlignment: Text.AlignHCenter } VirtualKeyboard { id: keyboard anchors.bottom: parent.bottom anchors.horizontalCenter: parent.horizontalCenter hide: items.currentArrow == items.nbArrow ? false : true function populate() { layout = [ [ { label: "0" }, { label: "1" }, { label: "2" }, { label: "3" }, { label: "4" }, { label: "5" }, { label: "6" }, { label: "7" }, { label: "8" }, { label: "9" }, { label: keyboard.backspace } ] ] } onKeypress: background.appendText(text) onError: console.log("VirtualKeyboard error: " + msg); } + DialogChooseLevel { + id: dialogActivityConfig + currentActivity: activity.activityInfo + + onSaveData: { + levelFolder = dialogActivityConfig.chosenLevel + currentActivity.currentLevel = dialogActivityConfig.chosenLevel + ApplicationSettings.setCurrentLevel(currentActivity.name, dialogActivityConfig.chosenLevel) + background.start() + home() + } + onClose: { + home() + } + onStartActivity: { + background.start() + } + } + DialogHelp { id: dialogHelp onClose: home() } Bar { id: bar anchors.bottom: keyboard.top - content: BarEnumContent { value: help | home | level } + content: BarEnumContent { value: help | home | level | activityConfig } onHelpClicked: { displayDialog(dialogHelp) } + onActivityConfigClicked: { + displayDialog(dialogActivityConfig) + } onPreviousLevelClicked: Activity.previousLevel() onNextLevelClicked: Activity.nextLevel() onHomeClicked: activity.home() } Score { id: score anchors.right: parent.right anchors.top: parent.top anchors.bottom: undefined currentSubLevel: items.currentSubLevel + 1 numberOfSubLevels: items.numberOfSubLevel } Bonus { id: bonus Component.onCompleted: win.connect(Activity.nextSubLevel) } } } diff --git a/src/activities/target/TargetItem.qml b/src/activities/target/TargetItem.qml index 0d721426a..5ed138a6e 100644 --- a/src/activities/target/TargetItem.qml +++ b/src/activities/target/TargetItem.qml @@ -1,159 +1,164 @@ /* GCompris - TargetItem.qml * * Copyright (C) 2014 Bruno coudoin * * Authors: * Bruno Coudoin (GTK+ version) * Bruno Coudoin (Qt Quick port) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . */ import QtQuick 2.6 import GCompris 1.0 import "../../core" import "target.js" as Activity Image { id: targetItem fillMode: Image.PreserveAspectCrop source: Activity.url + "target_background.svg" width: parent.width * zoom height: parent.height * zoom sourceSize.width: Math.max(parent.width, parent.height) * zoom anchors.centerIn: parent property int zoom: 2 property alias model: targetModel property bool stopMe: false property var scores: [] property string scoreText property int scoreTotal signal start signal stop signal attachArrow(Item arrow) onStart: { scores = [] scoreText = "" scoreTotal = 0 stopMe = false targetItem.anchors.horizontalCenterOffset = getRandomOffset(0) targetItem.anchors.verticalCenterOffset = getRandomOffset(0) } onStop: { stopMe = true targetItem.anchors.horizontalCenterOffset = 0 targetItem.anchors.verticalCenterOffset = 0 } // Avoid taking the same value or the animation won't restart function getRandomOffset(oldValue) { if(oldValue != 0 && Math.random() < 0.5) return 0 var maxSize = targetModel.get(0).size * ApplicationInfo.ratio do { var newValue = Math.floor(Math.random() * maxSize) - maxSize / 2 } while(oldValue == newValue) return newValue } onAttachArrow: { arrow.anchors.centerIn = undefined var coordArrow = parent.mapToItem(targetItem, arrow.x, arrow.y) arrow.parent = targetItem arrow.x = coordArrow.x arrow.y = coordArrow.y var arrowCenterX = arrow.x + arrow.width / 2 var arrowCenterY = arrow.y + arrow.height / 2 var centerX = targetItem.width / 2 var centerY = targetItem.height / 2 // Calc the arrow score var dist = Math.sqrt(Math.pow(arrowCenterX - centerX, 2) + Math.pow(arrowCenterY - centerY, 2)) dist *= zoom / ApplicationInfo.ratio var score = 0 for(var i = targetModel.count - 1; i >= 0; --i) { if(dist < targetModel.get(i).size) { score = targetModel.get(i).score break } } scores.push(score) scoreTotal += score scoreText = scores.join(" + ") parent.targetReached() } Behavior on anchors.horizontalCenterOffset { id: horizontal NumberAnimation { id: anim1 duration: 3000 easing.type: Easing.InOutQuad onRunningChanged: { if(!anim1.running) { var newValue = getRandomOffset(targetItem.anchors.horizontalCenterOffset) if(!stopMe) targetItem.anchors.horizontalCenterOffset = newValue } } } } Behavior on anchors.verticalCenterOffset { id: vertical NumberAnimation { id: anim2 duration: 3000 easing.type: Easing.InOutQuad onRunningChanged: { if(!anim2.running) { var newValue = getRandomOffset(targetItem.anchors.verticalCenterOffset) if(!stopMe) targetItem.anchors.verticalCenterOffset = newValue } } } } ListModel { id: targetModel } Repeater { id: repeater model: targetModel Rectangle { anchors.centerIn: targetItem width: size * ApplicationInfo.ratio height: size * ApplicationInfo.ratio color: model.color radius: width / 2 border.width: 1 * ApplicationInfo.ratio border.color: "black" GCText { anchors.horizontalCenter: parent.horizontalCenter anchors.bottom: parent.bottom + width: ApplicationInfo.ratio * 30 + horizontalAlignment: Text.AlignHCenter + font.pointSize: 20 + minimumPointSize: 5 + fontSizeMode: Text.Fit text: score } } } } diff --git a/src/activities/target/resource/1/Data.qml b/src/activities/target/resource/1/Data.qml new file mode 100644 index 000000000..f1a157d5f --- /dev/null +++ b/src/activities/target/resource/1/Data.qml @@ -0,0 +1,59 @@ +/* GCompris - Data.qml + * + * Copyright (C) 2019 Akshay Kumar + * + * Authors: + * Akshay Kumar + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + */ +import QtQuick 2.6 +import GCompris 1.0 +import "../../../../core" + +Dataset { + objective: qsTr("Practice addition on targets with max value 10") + difficulty: 2 + property var colors: [ + "#ff1b00", + "#7edee2", + "#f1f500", + "#3dff00", + "#b7d2d4", + "#6db5ba" + ] + data: [ + [ + {size: 50, color: colors[0], score: 5}, + {size: 100, color: colors[1], score: 4}, + {size: 150, color: colors[2], score: 3}, + {size: 200, color: colors[3], score: 2}, + {size: 250, color: colors[4], score: 1} + ], + [ + {size: 50, color: colors[0], score: 7}, + {size: 100, color: colors[1], score: 5}, + {size: 150, color: colors[2], score: 3}, + {size: 200, color: colors[3], score: 2}, + {size: 250, color: colors[4], score: 1} + ], + [ + {size: 50, color: colors[0], score: 10}, + {size: 100, color: colors[1], score: 7}, + {size: 150, color: colors[2], score: 5}, + {size: 200, color: colors[3], score: 3}, + {size: 250, color: colors[4], score: 2} + ] + ] +} diff --git a/src/activities/target/resource/2/Data.qml b/src/activities/target/resource/2/Data.qml new file mode 100644 index 000000000..b674e233b --- /dev/null +++ b/src/activities/target/resource/2/Data.qml @@ -0,0 +1,64 @@ +/* GCompris - Data.qml + * + * Copyright (C) 2019 Akshay Kumar + * + * Authors: + * Akshay Kumar + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + */ +import QtQuick 2.6 +import GCompris 1.0 +import "../../../../core" + +Dataset { + objective: qsTr("Practice addition on targets with max value 50") + difficulty: 3 + property var colors: [ + "#ff1b00", + "#7edee2", + "#f1f500", + "#3dff00", + "#b7d2d4", + "#6db5ba" + ] + data: [ + [ + {size: 50, color: colors[0], score: 20}, + {size: 100, color: colors[1], score: 10}, + {size: 150, color: colors[2], score: 8}, + {size: 200, color: colors[3], score: 4}, + {size: 250, color: colors[4], score: 2}, + {size: 300, color: colors[5], score: 1} + ], + [ + {size: 50, color: colors[0], score: 30}, + {size: 100, color: colors[1], score: 20}, + {size: 150, color: colors[2], score: 10}, + {size: 200, color: colors[3], score: 8}, + {size: 250, color: colors[4], score: 4}, + {size: 300, color: colors[5], score: 2}, + {size: 350, color: colors[5], score: 1} + ], + [ + {size: 50, color: colors[0], score: 50}, + {size: 100, color: colors[1], score: 20}, + {size: 150, color: colors[2], score: 10}, + {size: 200, color: colors[3], score: 8}, + {size: 250, color: colors[4], score: 4}, + {size: 300, color: colors[5], score: 2}, + {size: 350, color: colors[5], score: 1} + ] + ] +} diff --git a/src/activities/target/resource/3/Data.qml b/src/activities/target/resource/3/Data.qml new file mode 100644 index 000000000..880285afc --- /dev/null +++ b/src/activities/target/resource/3/Data.qml @@ -0,0 +1,70 @@ +/* GCompris - Data.qml + * + * Copyright (C) 2019 Akshay Kumar + * + * Authors: + * Akshay Kumar + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + */ +import QtQuick 2.6 +import GCompris 1.0 +import "../../../../core" + +Dataset { + objective: qsTr("Practice addition on targets with max value 500") + difficulty: 4 + property var colors: [ + "#ff1b00", + "#7edee2", + "#f1f500", + "#3dff00", + "#b7d2d4", + "#6db5ba" + ] + data: [ + [ + {size: 50, color: colors[0], score: 100}, + {size: 100, color: colors[1], score: 20}, + {size: 150, color: colors[2], score: 10}, + {size: 200, color: colors[3], score: 8}, + {size: 250, color: colors[4], score: 4}, + {size: 300, color: colors[5], score: 2}, + {size: 350, color: colors[5], score: 1} + ], + [ + {size: 50, color: colors[0], score: 300}, + {size: 100, color: colors[1], score: 100}, + {size: 150, color: colors[2], score: 30}, + {size: 200, color: colors[3], score: 20}, + {size: 250, color: colors[3], score: 10}, + {size: 300, color: colors[4], score: 8}, + {size: 350, color: colors[4], score: 4}, + {size: 400, color: colors[5], score: 2}, + {size: 450, color: colors[5], score: 1}, + ], + [ + {size: 50, color: colors[0], score: 500}, + {size: 100, color: colors[1], score: 300}, + {size: 150, color: colors[2], score: 100}, + {size: 200, color: colors[2], score: 30}, + {size: 250, color: colors[3], score: 20}, + {size: 300, color: colors[3], score: 10}, + {size: 350, color: colors[4], score: 8}, + {size: 400, color: colors[4], score: 4}, + {size: 450, color: colors[5], score: 2}, + {size: 450, color: colors[5], score: 1} + ] + ] +} diff --git a/src/activities/target/resource/4/Data.qml b/src/activities/target/resource/4/Data.qml new file mode 100644 index 000000000..f7fb6fbca --- /dev/null +++ b/src/activities/target/resource/4/Data.qml @@ -0,0 +1,74 @@ +/* GCompris - Data.qml + * + * Copyright (C) 2019 Akshay Kumar + * + * Authors: + * Akshay Kumar + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + */ +import QtQuick 2.6 +import GCompris 1.0 +import "../../../../core" + +Dataset { + objective: qsTr("Practice addition on targets with max value 50000") + difficulty: 5 + property var colors: [ + "#ff1b00", + "#7edee2", + "#f1f500", + "#3dff00", + "#b7d2d4", + "#6db5ba" + ] + data: [ + [ + {size: 50, color: colors[0], score: 100}, + {size: 100, color: colors[1], score: 20}, + {size: 150, color: colors[2], score: 10}, + {size: 200, color: colors[3], score: 8}, + {size: 250, color: colors[4], score: 4}, + {size: 300, color: colors[5], score: 2}, + {size: 350, color: colors[5], score: 1} + ], + [ + {size: 50, color: colors[0], score: 10000}, + {size: 100, color: colors[1], score: 4000}, + {size: 150, color: colors[1], score: 1000}, + {size: 200, color: colors[2], score: 300}, + {size: 250, color: colors[2], score: 100}, + {size: 300, color: colors[3], score: 30}, + {size: 350, color: colors[3], score: 10}, + {size: 400, color: colors[4], score: 8}, + {size: 450, color: colors[4], score: 4}, + {size: 500, color: colors[5], score: 2}, + {size: 550, color: colors[5], score: 1} + ], + [ + {size: 50, color: colors[0], score: 50000}, + {size: 100, color: colors[1], score: 10000}, + {size: 150, color: colors[1], score: 4000}, + {size: 200, color: colors[2], score: 1000}, + {size: 250, color: colors[2], score: 300}, + {size: 300, color: colors[3], score: 100}, + {size: 350, color: colors[3], score: 30}, + {size: 400, color: colors[4], score: 10}, + {size: 450, color: colors[4], score: 8}, + {size: 500, color: colors[5], score: 4}, + {size: 550, color: colors[5], score: 2}, + {size: 600, color: colors[5], score: 1}, + ] + ] +} diff --git a/src/activities/target/resource/5/Data.qml b/src/activities/target/resource/5/Data.qml new file mode 100644 index 000000000..17b417d5a --- /dev/null +++ b/src/activities/target/resource/5/Data.qml @@ -0,0 +1,78 @@ +/* GCompris - Data.qml + * + * Copyright (C) 2019 Akshay Kumar + * + * Authors: + * Akshay Kumar + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + */ +import QtQuick 2.6 +import GCompris 1.0 +import "../../../../core" + +Dataset { + objective: qsTr("Practice addition on targets with max value 500000") + difficulty: 6 + property var colors: [ + "#ff1b00", + "#7edee2", + "#f1f500", + "#3dff00", + "#b7d2d4", + "#6db5ba", + "#ffffff" + ] + + data: [ + [ + {size: 50, color: colors[0], score: 100}, + {size: 100, color: colors[1], score: 20}, + {size: 150, color: colors[2], score: 10}, + {size: 200, color: colors[3], score: 8}, + {size: 250, color: colors[4], score: 4}, + {size: 300, color: colors[5], score: 2}, + {size: 350, color: colors[5], score: 1} + ], + [ + {size: 50, color: colors[0], score: 10000}, + {size: 100, color: colors[1], score: 4000}, + {size: 150, color: colors[1], score: 1000}, + {size: 200, color: colors[2], score: 300}, + {size: 250, color: colors[2], score: 100}, + {size: 300, color: colors[3], score: 30}, + {size: 350, color: colors[3], score: 10}, + {size: 400, color: colors[4], score: 8}, + {size: 450, color: colors[4], score: 4}, + {size: 500, color: colors[5], score: 2}, + {size: 550, color: colors[5], score: 1} + ], + [ + {size: 50, color: colors[0], score: 500000}, + {size: 100, color: colors[1], score: 100000}, + {size: 150, color: colors[1], score: 50000}, + {size: 200, color: colors[2], score: 10000}, + {size: 250, color: colors[2], score: 4000}, + {size: 300, color: colors[3], score: 1000}, + {size: 350, color: colors[3], score: 300}, + {size: 400, color: colors[4], score: 100}, + {size: 450, color: colors[4], score: 30}, + {size: 500, color: colors[5], score: 10}, + {size: 550, color: colors[5], score: 8}, + {size: 600, color: colors[6], score: 4}, + {size: 650, color: colors[6], score: 2}, + {size: 700, color: colors[6], score: 1}, + ] + ] +} diff --git a/src/activities/target/target.js b/src/activities/target/target.js index 329abbe3f..b8056d9cd 100644 --- a/src/activities/target/target.js +++ b/src/activities/target/target.js @@ -1,152 +1,81 @@ /* GCompris - target.js * * Copyright (C) 2014 Bruno coudoin * * Authors: * Bruno Coudoin (GTK+ version) * Bruno Coudoin (Qt Quick port) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . */ .pragma library .import QtQuick 2.6 as Quick var url = "qrc:/gcompris/src/activities/target/resource/" -var colors = [ - "#ff1b00", - "#7edee2", - "#f1f500", - "#3dff00", - "#b7d2d4", - "#6db5ba" - ] - -var levels = [ - [ - {size: 50, color: colors[0], score: 5}, - {size: 100, color: colors[1], score: 4}, - {size: 150, color: colors[2], score: 3}, - {size: 200, color: colors[3], score: 2}, - {size: 250, color: colors[4], score: 1} - ], - [ - {size: 50, color: colors[0], score: 10}, - {size: 100, color: colors[1], score: 5}, - {size: 150, color: colors[2], score: 3}, - {size: 200, color: colors[3], score: 2}, - {size: 250, color: colors[4], score: 1} - ], - [ - {size: 50, color: colors[0], score: 20}, - {size: 100, color: colors[1], score: 10}, - {size: 150, color: colors[2], score: 8}, - {size: 200, color: colors[3], score: 5}, - {size: 250, color: colors[4], score: 3}, - {size: 300, color: colors[5], score: 2} - ], - [ - {size: 50, color: colors[0], score: 30}, - {size: 100, color: colors[1], score: 20}, - {size: 150, color: colors[2], score: 10}, - {size: 200, color: colors[3], score: 5}, - {size: 250, color: colors[4], score: 3}, - {size: 300, color: colors[5], score: 2} - ], - [ - {size: 50, color: colors[0], score: 50}, - {size: 100, color: colors[1], score: 30}, - {size: 150, color: colors[2], score: 20}, - {size: 200, color: colors[3], score: 8}, - {size: 250, color: colors[4], score: 3}, - {size: 300, color: colors[5], score: 2} - ], - [ - {size: 50, color: colors[0], score: 100}, - {size: 100, color: colors[1], score: 50}, - {size: 150, color: colors[2], score: 12}, - {size: 200, color: colors[3], score: 8}, - {size: 250, color: colors[4], score: 3}, - {size: 300, color: colors[5], score: 2} - ], - [ - {size: 50, color: colors[0], score: 500}, - {size: 100, color: colors[1], score: 100}, - {size: 150, color: colors[2], score: 50}, - {size: 200, color: colors[3], score: 15}, - {size: 250, color: colors[4], score: 7}, - {size: 300, color: colors[5], score: 3} - ], - [ - {size: 50, color: colors[0], score: 64}, - {size: 100, color: colors[1], score: 32}, - {size: 150, color: colors[2], score: 16}, - {size: 200, color: colors[3], score: 8}, - {size: 250, color: colors[4], score: 4}, - {size: 300, color: colors[5], score: 2} - ] - ] - +var levels var currentLevel = 0 -var numberOfLevel = levels.length +var numberOfLevel var items function start(items_) { items = items_ currentLevel = 0 + levels = items.levels + numberOfLevel = levels.length items.currentSubLevel = 0 items.numberOfSubLevel = 5 initLevel() } function stop() { } function initLevel() { items.bar.level = currentLevel + 1 items.targetModel.clear() items.arrowFlying = false for(var i = levels[currentLevel].length - 1; i >= 0 ; --i) { items.targetModel.append(levels[currentLevel][i]) } // Reset the arrows first items.nbArrow = 0 items.nbArrow = Math.min(currentLevel + 3, 6) items.targetItem.start() items.userEntry.text = "" } function nextSubLevel() { if(items.numberOfSubLevel <= ++items.currentSubLevel ) { nextLevel() } else { initLevel(); } } function nextLevel() { items.currentSubLevel = 0 if(numberOfLevel <= ++currentLevel ) { currentLevel = 0 } initLevel(); } function previousLevel() { items.currentSubLevel = 0 if(--currentLevel < 0) { currentLevel = numberOfLevel - 1 } initLevel(); }