diff --git a/src/activities/alphabet-sequence/ActivityConfig.qml b/src/activities/alphabet-sequence/ActivityConfig.qml index f74e964ca..cb7aa2cd3 100644 --- a/src/activities/alphabet-sequence/ActivityConfig.qml +++ b/src/activities/alphabet-sequence/ActivityConfig.qml @@ -1,58 +1,58 @@ /* GCompris - ActivityConfig.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 "../../core" Item { id: activityConfiguration property Item background property alias modeBox: modeBox property var availableModes: [ { "text": qsTr("Lower Case"), "value": "lower" }, { "text": qsTr("Upper Case"), "value": "upper" }, ] Flow { id: flow spacing: 5 width: parent.width GCComboBox { id: modeBox model: availableModes background: activityConfiguration.background - label: qsTr("Select Domino Representation") + label: qsTr("Select Case") } } property var dataToSave function setDefaultValues() { for(var i = 0 ; i < availableModes.length ; i++) { if(availableModes[i].value === dataToSave["mode"]) { modeBox.currentIndex = i; break; } } } function saveValues() { var newMode = availableModes[modeBox.currentIndex].value; dataToSave = {"mode": newMode}; } } diff --git a/src/activities/alphabet-sequence/ActivityInfo.qml b/src/activities/alphabet-sequence/ActivityInfo.qml index 3ef9fe5d8..27712f3a1 100644 --- a/src/activities/alphabet-sequence/ActivityInfo.qml +++ b/src/activities/alphabet-sequence/ActivityInfo.qml @@ -1,41 +1,40 @@ /* 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: "alphabet-sequence/AlphabetSequence.qml" difficulty: 2 icon: "alphabet-sequence/alphabet-sequence.svg" author: "Bruno Coudoin <bruno.coudoin@gcompris.net>" demo: false //: Activity title title: qsTr("Alphabet sequence") //: Help title description: qsTr("Move the helicopter to catch the clouds following the order of the alphabet") // intro: "Move the helicopter to catch the clouds following the order of the alphabet." //: Help goal goal: qsTr("Alphabet sequence") //: Help prerequisite prerequisite: qsTr("Can decode letters") //: Help manual manual: qsTr("Catch the alphabet letters. With a keyboard use the arrow keys to move the helicopter. With a pointing device you just click or tap on the target location. To know which letter you have to catch you can either remember it or check the bottom right corner.") credit: "" section: "reading letters" createdInVersion: 0 - levels: "1,2,3" } diff --git a/src/activities/alphabet-sequence/resource/1/Data.qml b/src/activities/alphabet-sequence/resource/1/Data.qml deleted file mode 100644 index b7ce660f3..000000000 --- a/src/activities/alphabet-sequence/resource/1/Data.qml +++ /dev/null @@ -1,63 +0,0 @@ - -/* 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("Select letters in alphabetical order") - difficulty: 1 - data: [ - { - data: qsTr("a/b/c/d/e").split("/"), - showNext: true - }, - { - data: qsTr("f/g/h/i/j/k").split("/"), - showNext: true - }, - { - data: qsTr("a/b/c/d/e/f/g/h/i/j/k").split("/"), - showNext: false - }, - { - data: qsTr("l/m/n/o/p").split("/"), - showNext: false - }, - { - data: qsTr("q/r/s/t/u").split("/"), - showNext: false - }, - { - data: qsTr("a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u").split("/"), - showNext: false - }, - { - data: qsTr("u/v/w/x/y/z").split("/"), - showNext: false - }, - { - data: qsTr("a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z").split("/"), - showNext: false - } - ] -} diff --git a/src/activities/alphabet-sequence/resource/2/Data.qml b/src/activities/alphabet-sequence/resource/2/Data.qml deleted file mode 100644 index cd2ff7be3..000000000 --- a/src/activities/alphabet-sequence/resource/2/Data.qml +++ /dev/null @@ -1,143 +0,0 @@ - -/* 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("Select words in alphabetical order") - difficulty: 2 - data: [ - { - data: [ - qsTr("fruit"), - qsTr("road"), - qsTr("meat"), - qsTr("speech"), - qsTr("gold"), - qsTr("trip"), - qsTr("dance") - ].sort(), - showNext: true - }, - { - data: [ - qsTr("witch"), - qsTr("ghost"), - qsTr("trip"), - qsTr("house"), - qsTr("live"), - qsTr("like"), - qsTr("road"), - ].sort(), - showNext: true - }, - { - data: [ - qsTr("old"), - qsTr("crown"), - qsTr("tear"), - qsTr("bench"), - qsTr("computer"), - qsTr("key"), - ].sort(), - showNext: true - }, - { - data: [ - qsTr("brake"), - qsTr("dream"), - qsTr("prince"), - qsTr("talk"), - qsTr("fly"), - qsTr("history"), - ].sort(), - showNext: false - }, - { - data: [ - qsTr("watch"), - qsTr("shampoo"), - qsTr("sun"), - qsTr("apple"), - qsTr("table"), - qsTr("socks"), - ].sort(), - showNext: false - }, - { - data: [ - qsTr("needle"), - qsTr("couch"), - qsTr("peanuts"), - qsTr("stock"), - qsTr("shoes"), - ].sort(), - showNext: false - }, - { - data: [ - qsTr("needle"), - qsTr("couch"), - qsTr("peanuts"), - qsTr("stock"), - qsTr("shoes"), - ].sort(), - showNext: false - }, - { - data: [ - qsTr("hanger"), - qsTr("toothbrush"), - qsTr("plastic"), - qsTr("machine"), - qsTr("shampoo"), - qsTr("towel"), - ].sort(), - showNext: false - }, - { - data: [ - qsTr("bread"), - qsTr("waist"), - qsTr("law"), - qsTr("firm"), - qsTr("fibre"), - qsTr("move"), - qsTr("bright"), - qsTr("green"), - ].sort(), - showNext: false - }, - { - data: [ - qsTr("rush"), - qsTr("trade"), - qsTr("line"), - qsTr("boy"), - qsTr("girl"), - qsTr("key"), - ].sort(), - showNext: false - }, - ] -} diff --git a/src/activities/alphabet-sequence/resource/3/Data.qml b/src/activities/alphabet-sequence/resource/3/Data.qml deleted file mode 100644 index 0629c93bb..000000000 --- a/src/activities/alphabet-sequence/resource/3/Data.qml +++ /dev/null @@ -1,99 +0,0 @@ - -/* 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("Select words(with common initials) in alphabetical order") - difficulty: 3 - data: [ - { - data: [ - qsTr("band"), - qsTr("beautiful"), - qsTr("balance"), - qsTr("ball"), - qsTr("basket"), - qsTr("base"), - ].sort(), - showNext: true - }, - { - data: [ - qsTr("connection"), - qsTr("cook"), - qsTr("condition"), - qsTr("control"), - qsTr("conscious"), - qsTr("complex"), - ].sort(), - showNext: true - }, - { - data: [ - qsTr("discovery"), - qsTr("digestion"), - qsTr("direction"), - qsTr("discussion"), - qsTr("disease"), - qsTr("dirty"), - ].sort(), - showNext: true - }, - { - data: [ - qsTr("engine"), - qsTr("elastic"), - qsTr("egg"), - qsTr("effect"), - qsTr("enough"), - qsTr("end"), - qsTr("electric"), - ].sort(), - showNext: false - }, - { - data: [ - qsTr("family"), - qsTr("face"), - qsTr("fall"), - qsTr("fat"), - qsTr("fact"), - qsTr("false"), - qsTr("far") - ].sort(), - showNext: false - }, - { - data: [ - qsTr("fertile"), - qsTr("feeling"), - qsTr("fiction"), - qsTr("field"), - qsTr("fight"), - qsTr("female"), - ].sort(), - showNext: false - } - ] -} diff --git a/src/activities/numbers-odd-even/NumbersOddEven.qml b/src/activities/numbers-odd-even/NumbersOddEven.qml index bb53e9c9d..f694a8f64 100644 --- a/src/activities/numbers-odd-even/NumbersOddEven.qml +++ b/src/activities/numbers-odd-even/NumbersOddEven.qml @@ -1,82 +1,63 @@ /* gcompris - NumberOddEven.qml Copyright (C) 2014 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 QtQuick 2.6 import "../planegame" Planegame { showTutorial: true - dataset: [ - { - data: "0 2 4 6 8 10 12 14 16 18 20".split(" "), - showNext: true - }, - { - data: "1 3 5 7 9 11 13 15 17 19 21".split(" "), - showNext: true - }, - { - data: "0 2 4 6 8 10 12 14 16 18 20".split(" "), - showNext: false - }, - { - data: "1 3 5 7 9 11 13 15 17 19 21".split(" "), - showNext: false - } - ] - tutorialInstructions: [ { "instruction": qsTr("This activity teaches about even and odd numbers."), "instructionQml": "" }, { "instruction": qsTr("Even numbers are numbers which leave remainder 0 when divided by 2."), "instructionQml": "" }, { "instruction": qsTr("What is meant by remainder of a number?"), "instructionQml" : "qrc:/gcompris/src/activities/numbers-odd-even/resource/Tutorial1.qml" }, { "instruction": qsTr("Even numbers are numbers which leave remainder 0 when divided by 2."), "instructionQml" : "qrc:/gcompris/src/activities/numbers-odd-even/resource/Tutorial2.qml" }, { "instruction": qsTr("Odd numbers are numbers which do not leave remainder 0 when divided by 2."), "instructionQml": "qrc:/gcompris/src/activities/numbers-odd-even/resource/Tutorial3.qml" }, { "instruction": qsTr("Exercise to test your understanding."), "instructionQml": "qrc:/gcompris/src/activities/numbers-odd-even/resource/Tutorial4.qml" }, { "instruction": qsTr("Exercise to test your understanding."), "instructionQml": "qrc:/gcompris/src/activities/numbers-odd-even/resource/Tutorial5.qml" }, { "instruction": qsTr("Exercise to test your understanding."), "instructionQml": "qrc:/gcompris/src/activities/numbers-odd-even/resource/Tutorial6.qml" } ] } diff --git a/src/activities/numbers-odd-even/resource/1/Data.qml b/src/activities/numbers-odd-even/resource/1/Data.qml index a4a0c0636..f9a22c144 100644 --- a/src/activities/numbers-odd-even/resource/1/Data.qml +++ b/src/activities/numbers-odd-even/resource/1/Data.qml @@ -1,55 +1,55 @@ - /* 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("Select even and odd numbers upto 20") + objective: qsTr("Select even and odd numbers up to 20") difficulty: 1 + //: If the value of variable showNext is true then the next number to be selected is shown as hint, otherwise not. data: [ { data: "0 2 4".split(" "), showNext: true }, { data: "1 3 5".split(" "), showNext: true }, { data: "0 2 4 6 8 10 12".split(" "), showNext: true }, { data: "1 3 5 7 9 11 13".split(" "), showNext: false }, { data: "0 2 4 6 8 10 12 14 16 18 20".split(" "), showNext: false }, { data: "1 3 5 7 9 11 13 15 17 19 21".split(" "), showNext: false } ] } diff --git a/src/activities/numbers-odd-even/resource/2/Data.qml b/src/activities/numbers-odd-even/resource/2/Data.qml index a85880e9c..42e8a250a 100644 --- a/src/activities/numbers-odd-even/resource/2/Data.qml +++ b/src/activities/numbers-odd-even/resource/2/Data.qml @@ -1,55 +1,55 @@ - /* 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("Select even and odd numbers upto 30") + objective: qsTr("Select even and odd numbers up to 30") difficulty: 1 + //: If the value of variable showNext is true then the next number to be selected is shown as hint, otherwise not. data: [ { data: "0 2 4 6 8 10 12 14 16 18 20".split(" "), showNext: true }, { data: "1 3 5 7 9 11 13 15 17 19 21".split(" "), showNext: true }, { data: "0 2 4 6 8 10 12 14 16 18 20 22 24 26".split(" "), showNext: false }, { data: "1 3 5 7 9 11 13 15 17 19 21 23 25 27".split(" "), showNext: false }, { data: "0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30".split(" "), showNext: false }, { data: "1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31".split(" "), showNext: false } ] } diff --git a/src/activities/planegame/Planegame.qml b/src/activities/planegame/Planegame.qml index 7a09b1b13..aaa79cce8 100644 --- a/src/activities/planegame/Planegame.qml +++ b/src/activities/planegame/Planegame.qml @@ -1,217 +1,217 @@ /* gcompris - Planegame.qml Copyright (C) 2014 Johnny Jazeix 2003, 2014: Bruno Coudoin: initial version 2014: Johnny Jazeix: Qt 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 "planegame.js" as Activity ActivityBase { id: activity focus: true onStart: { focus = true; } onStop: { } Keys.onPressed: Activity.processPressedKey(event) Keys.onReleased: Activity.processReleasedKey(event) property string mode: "lower" property var dataset property var tutorialInstructions property bool showTutorial: false property int oldWidth: width onWidthChanged: { // Reposition helico and clouds, same for height Activity.repositionObjectsOnWidthChanged(width / oldWidth) oldWidth = width } property int oldHeight: height onHeightChanged: { // Reposition helico and clouds, same for height Activity.repositionObjectsOnHeightChanged(height / oldHeight) oldHeight = height } pageComponent: Image { id: background anchors.fill: parent signal start signal stop source: Activity.url + "../algorithm/resource/desert_scene.svg" sourceSize.width: parent.width Component.onCompleted: { dialogActivityConfig.initialize() activity.start.connect(start) activity.stop.connect(stop) } QtObject { id: items property alias background: background property alias bar: bar property alias bonus: bonus - property var levels: activity.datasetLoader.item.data + property var levels: activity.datasetLoader.item !== null ? activity.datasetLoader.item.data : null property alias score: score property alias plane: plane property GCAudio audioVoices: activity.audioVoices property GCSfx audioEffects: activity.audioEffects property alias movePlaneTimer: movePlaneTimer property alias cloudCreation: cloudCreation property bool showTutorial: activity.showTutorial property var letterMode: activity.mode } onStart: { Activity.start(items, dataset) } onStop: { Activity.stop() } //Tutorial section starts Loader { active: showTutorial anchors.fill: parent z: 1 sourceComponent: tutorialComponent Component { id: tutorialComponent Image { id: tutorialImage source: "../digital_electricity/resource/texture01.png" anchors.fill: parent fillMode: Image.Tile Tutorial { id: tutorialSection tutorialDetails: tutorialInstructions useImage: false onSkipPressed: { showTutorial = false Activity.initLevel() } } } } } // Tutorial section ends MultiPointTouchArea { anchors.fill: parent touchPoints: [ TouchPoint { id: point1 } ] onReleased: { plane.x = point1.x - plane.width / 2 plane.y = point1.y - plane.height / 2 } } DialogChooseLevel { id: dialogActivityConfig currentActivity: activity.activityInfo onSaveData: { levelFolder = dialogActivityConfig.chosenLevel currentActivity.currentLevel = dialogActivityConfig.chosenLevel ApplicationSettings.setCurrentLevel(currentActivity.name, dialogActivityConfig.chosenLevel) home() activity.focus = true background.stop() background.start() } onLoadData: { if(activityData && activityData["mode"]) { activity.mode = activityData["mode"]; Activity.initLevel() } } onClose: { home() } onStartActivity: { background.start() } } DialogHelp { id: dialogHelp onClose: home() } Bar { id: bar content: BarEnumContent { value: items.showTutorial ? (help | home | activityConfig) : (help | home | level | activityConfig) } onHelpClicked: displayDialog(dialogHelp) onPreviousLevelClicked: Activity.previousLevel() onNextLevelClicked: Activity.nextLevel() onHomeClicked: activity.home() onActivityConfigClicked: { displayDialog(dialogActivityConfig) } } Bonus { id: bonus Component.onCompleted: win.connect(Activity.nextLevel) } Score { id: score visible: !showTutorial fontSize: background.width >= background.height ? internalTextComponent.largeSize : internalTextComponent.mediumSize height: internalTextComponent.height + 10 anchors.bottom: bar.top anchors.margins: 10 } property int movePlaneTimerCounter: 0 Timer { id: movePlaneTimer running: false repeat: true onTriggered: { plane.state = "play" interval = 50 if(movePlaneTimerCounter++ % 3 == 0) { /* Do not call this too often or plane commands are too hard */ Activity.handleCollisionsWithCloud(); } Activity.computeVelocity(); Activity.planeMove(); } } Timer { id: cloudCreation running: false repeat: true interval: 10200 - (bar.level * 200) onTriggered: Activity.createCloud() } Plane { id: plane visible: !showTutorial background: background } } } diff --git a/src/activities/planegame/Sequence.qml b/src/activities/planegame/Sequence.qml index 21fe0299a..164ea1a94 100644 --- a/src/activities/planegame/Sequence.qml +++ b/src/activities/planegame/Sequence.qml @@ -1,43 +1,24 @@ /* GCompris - Sequence.qml * * Copyright (C) 2014 Bruno Coudoin * * Authors: * 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 QtQuick 2.6 Planegame { - - dataset: [ - { - data: "0 1 2 3 4 5 6 7 8 9 10".split(" "), - showNext: true - }, - { - data: "10 11 12 13 14 15 16 17 18 19 20".split(" "), - showNext: true - }, - { - data: "0 1 2 3 4 5 6 7 8 9 10".split(" "), - showNext: false - }, - { - data: "10 11 12 13 14 15 16 17 18 19 20".split(" "), - showNext: false - } - ] } diff --git a/src/activities/planegame/planegame.js b/src/activities/planegame/planegame.js index 563f110cc..200a407c6 100644 --- a/src/activities/planegame/planegame.js +++ b/src/activities/planegame/planegame.js @@ -1,343 +1,346 @@ /* gcompris - planegame.js Copyright (C) 2003, 2014: Bruno Coudoin: initial version 2014: Johnny Jazeix: Qt port 2014: Bruno Coudoin: Added support for dataset, smooth plane anim 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 .import GCompris 1.0 as GCompris //for ApplicationInfo .import "qrc:/gcompris/src/core/core.js" as Core var url = "qrc:/gcompris/src/activities/planegame/" var max_velocity = 500 * GCompris.ApplicationInfo.ratio var currentLevel var numberOfLevel var currentSubLevel var numberOfSubLevels var upPressed var downPressed var leftPressed var rightPressed var items var dataset var cloudComponent = Qt.createComponent(url + "Cloud.qml"); var clouds = new Array; var cloudsErased = new Array; function start(items_, dataset_) { Core.checkForVoices(items_.background); items = items_ - dataset = items.levels + if(items.levels) + dataset = items.levels + else + dataset = dataset_ numberOfLevel = dataset.length currentLevel = 0 if(items.showTutorial === false) { initLevel() } } function stop() { cloudDestroy(clouds) cloudDestroy(cloudsErased) items.movePlaneTimer.stop() items.cloudCreation.stop() } function cloudDestroy(clouds) { for(var i = clouds.length - 1; i >= 0 ; --i) { var cloud = clouds[i]; // Remove the cloud cloud.destroy() // Remove the element from the list clouds.splice(i, 1) } } function initLevel() { items.bar.level = currentLevel + 1; currentSubLevel = 0 numberOfSubLevels = dataset[currentLevel].data.length if(items.letterMode === "upper") { for(var i = 0; i < numberOfSubLevels; i++) { dataset[currentLevel].data[i] = dataset[currentLevel].data[i].toUpperCase() } } else { for(var i = 0; i < numberOfSubLevels; i++) { dataset[currentLevel].data[i] = dataset[currentLevel].data[i].toLowerCase() } } items.movePlaneTimer.stop(); items.cloudCreation.stop() items.score.message = dataset[currentLevel].data[currentSubLevel] items.score.visible = dataset[currentLevel].showNext upPressed = false downPressed = false leftPressed = false rightPressed = false cloudDestroy(clouds) cloudDestroy(cloudsErased) // Tend towards 0.5 ratio items.plane.state = "init" items.movePlaneTimer.interval = 1000 items.movePlaneTimer.start(); items.cloudCreation.start() //Inject the first cloud now createCloud() } function nextLevel() { if(numberOfLevel <= ++currentLevel) { currentLevel = 0 } initLevel(); } function previousLevel() { if(--currentLevel < 0) { currentLevel = numberOfLevel - 1 } initLevel(); } function repositionObjectsOnWidthChanged(factor) { if(items && items.plane) { items.movePlaneTimer.interval = 1000 items.plane.state = "init" } for(var i = clouds.length - 1; i >= 0 ; --i) { var cloud = clouds[i]; } } function repositionObjectsOnHeightChanged(factor) { if(items && items.plane) { items.movePlaneTimer.interval = 1000 items.plane.state = "init" } for(var i = clouds.length - 1; i >= 0 ; --i) { var cloud = clouds[i]; cloud.y *= factor } } var cloudCounter = 1 function createCloud() { var cloud = cloudComponent.createObject( items.background, { "background": items.background, "x": items.background.width, "heightRatio": 1.0 - 0.5 * currentLevel / 10 }); /* Random cloud number but at least one in 3 */ if(cloudCounter++ % 3 == 0 || getRandomInt(0, 1) === 0) { /* Put the target */ cloud.text = dataset[currentLevel].data[currentSubLevel]; cloudCounter = 1 } else { var min = Math.max(1, currentSubLevel - 1); var index = Math.min(min + getRandomInt(0, currentSubLevel - min + 3), numberOfSubLevels - 1) cloud.text = dataset[currentLevel].data[index] } clouds.push(cloud); } function getRandomInt(min, max) { return Math.floor(Math.random() * (max - min + 1) + min); } function processPressedKey(event) { switch(event.key) { case Qt.Key_Right: rightPressed = true; event.accepted = true; break; case Qt.Key_Left: leftPressed = true; event.accepted = true; break; case Qt.Key_Up: upPressed = true; event.accepted = true; break; case Qt.Key_Down: downPressed = true; event.accepted = true; } } function processReleasedKey(event) { switch(event.key) { case Qt.Key_Right: rightPressed = false; event.accepted = true; break; case Qt.Key_Left: leftPressed = false; event.accepted = true; break; case Qt.Key_Up: upPressed = false; event.accepted = true; break; case Qt.Key_Down: downPressed = false; event.accepted = true; } } var speedX = 0 var speedY = 0 var speedFactor = 20 function computeVelocity() { if(rightPressed && speedX < 300) speedX += speedFactor if(leftPressed && speedX > -300) speedX -= speedFactor if(!rightPressed && speedX > 0) speedX = 0 else if(!leftPressed && speedX < 0) speedX = 0 else if(leftPressed || rightPressed) items.plane.x += speedX if(upPressed && speedY > -300) speedY -= speedFactor if(downPressed && speedY < 300) speedY += speedFactor if(!upPressed && speedY < 0) speedY = 0 else if(!downPressed && speedY > 0) speedY = 0 else if(upPressed || downPressed) items.plane.y += speedY items.plane.rotation = speedX * 10 / max_velocity } /* We move x/y of the plane to let its smooth animation track it */ function planeMove() { if(items.plane.x + items.plane.width > items.background.width) { items.plane.x = items.background.width - items.plane.width; } if(items.plane.x < 0) { items.plane.x = 0; } if(items.plane.y < 0) { items.plane.y = 0; } if(items.plane.y + items.plane.height > items.background.height - items.bar.height) { items.plane.y = items.background.height - (items.plane.height + items.bar.height); } } function isIn(x1, y1, px1, py1, px2, py2) { return (x1>px1 && x1py1 && y1= 0 ; --i) { var cloud = clouds[i]; var x1 = cloud.x var x2 = cloud.x + cloud.width var y1 = cloud.y var y2 = cloud.y + cloud.height if(x2 < 0) { // Remove the cloud cloud.destroy() clouds.splice(i, 1) } else if(isIn(x1, y1, planeX1, planeY1, planeX2, planeY2) || isIn(x2, y1, planeX1, planeY1, planeX2, planeY2) || isIn(x1, y2, planeX1, planeY1, planeX2, planeY2) || isIn(x2, y2, planeX1, planeY1, planeX2, planeY2)) { gotOne = true // Collision, look for id if(cloud.text === dataset[currentLevel].data[currentSubLevel]) { playLetterSound(cloud.text) // Move the cloud to the erased list cloud.done() cloudsErased.push(cloud) clouds.splice(i, 1) currentSubLevel++ if(currentSubLevel === numberOfSubLevels) { /* Try the next level */ items.bonus.good("flower") } else { items.score.message = dataset[currentLevel].data[currentSubLevel] } } else { /* Touched the wrong cloud */ if(!cloud.touched) items.audioEffects.play("qrc:/gcompris/src/core/resource/sounds/crash.wav") cloud.touch() } break; } } // Reset the touched state on the clouds if(!gotOne) { for(var i = clouds.length - 1; i >= 0 ; --i) { clouds[i].touched = false } } } } function playLetterSound(number) { if(number > 9) items.audioVoices.play(GCompris.ApplicationInfo.getAudioFilePath("voices-$CA/$LOCALE/alphabet/" + number + ".$CA")) else items.audioVoices.play( GCompris.ApplicationInfo.getAudioFilePath("voices-$CA/$LOCALE/alphabet/" + Core.getSoundFilenamForChar(number))) } diff --git a/src/activities/planegame/resource/1/Data.qml b/src/activities/planegame/resource/1/Data.qml index 005c3eddc..f33a20aff 100644 --- a/src/activities/planegame/resource/1/Data.qml +++ b/src/activities/planegame/resource/1/Data.qml @@ -1,59 +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("Count numbers upto 15") + objective: qsTr("Count numbers up to 15") difficulty: 1 + //: If the value of variable showNext is true then the next number to be selected is shown as hint, otherwise not. data: [ { data: "0 1 2 3".split(" "), showNext: true }, { data: "0 1 2 3 4 5".split(" "), showNext: true }, { data: "0 1 2 3 4 5 6 7".split(" "), showNext: true }, { data: "0 1 2 3 4 5 6 7 8 9".split(" "), showNext: false }, { data: "0 1 2 3 4 5 6 7 8 9 10 11".split(" "), showNext: false }, { data: "0 1 2 3 4 5 6 7 8 9 10 11 12 13".split(" "), showNext: false }, { data: "0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15".split(" "), showNext: false } ] } diff --git a/src/activities/planegame/resource/2/Data.qml b/src/activities/planegame/resource/2/Data.qml index aa488eb18..654c058fb 100644 --- a/src/activities/planegame/resource/2/Data.qml +++ b/src/activities/planegame/resource/2/Data.qml @@ -1,55 +1,55 @@ - /* 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("Count numbers upto 20") + objective: qsTr("Count numbers up to 20") difficulty: 2 + //: If the value of variable showNext is true then the next number to be selected is shown as hint, otherwise not. data: [ { data: "0 1 2 3 4 5 6 7 8 9 10".split(" "), showNext: true }, { data: "0 1 2 3 4 5 6 7 8 9 10 11 12".split(" "), showNext: true }, { data: "0 1 2 3 4 5 6 7 8 9 10 11 12 13 14".split(" "), showNext: false }, { data: "0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16".split(" "), showNext: false }, { data: "0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18".split(" "), showNext: false }, { data: "0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20".split(" "), showNext: false } ] }