diff --git a/src/activities/penalty/0001-penalty-kick-Randomized-ball-position.patch b/src/activities/penalty/0001-penalty-kick-Randomized-ball-position.patch new file mode 100644 --- /dev/null +++ b/src/activities/penalty/0001-penalty-kick-Randomized-ball-position.patch @@ -0,0 +1,44 @@ +From e657000524b9321b1ec4d8ea98b21258d70c9fc6 Mon Sep 17 00:00:00 2001 +From: Rohit Das +Date: Thu, 10 Aug 2017 00:27:04 +0530 +Subject: [PATCH 1/3] penalty kick: Randomized ball position + +Changed the position of the ball after kicking. Used +random() to generate random values to get x and y +values. The ball now gets positioned at a random +position after every kick inside the goal. + +Signed-off-by: Rohit Das +--- + src/activities/penalty/Penalty.qml | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +diff --git a/src/activities/penalty/Penalty.qml b/src/activities/penalty/Penalty.qml +index 8535564..b9ab4de 100644 +--- a/src/activities/penalty/Penalty.qml ++++ b/src/activities/penalty/Penalty.qml +@@ -283,8 +283,8 @@ ActivityBase { + PropertyChanges { + target: ball; + sourceSize.width: 75 * ApplicationInfo.ratio +- x: background.width * 0.8; +- y: background.height * 0.3 ++ x: background.width * (Math.random() * (0.8 - 0.6) + 0.6); ++ y: background.height * (Math.random() * (0.4 - 0.1) + 0.1) + } + }, + State { +@@ -292,8 +292,8 @@ ActivityBase { + PropertyChanges { + target: ball; + sourceSize.width: 75 * ApplicationInfo.ratio +- x: background.width * 0.2; +- y: background.height * 0.3 ++ x: background.width * (Math.random() * (0.4 - 0.1) + 0.1); ++ y: background.height * (Math.random() * (0.4 - 0.1) + 0.1) + } + }, + State { +-- +2.7.4 + diff --git a/src/activities/penalty/0002-Changes-Removed-dependency-on-mouse-buttons.patch b/src/activities/penalty/0002-Changes-Removed-dependency-on-mouse-buttons.patch new file mode 100644 --- /dev/null +++ b/src/activities/penalty/0002-Changes-Removed-dependency-on-mouse-buttons.patch @@ -0,0 +1,263 @@ +From 9063674ff7186ea03c15fd64789590d8a717e168 Mon Sep 17 00:00:00 2001 +From: Rohit Das +Date: Thu, 10 Aug 2017 21:02:28 +0530 +Subject: [PATCH 2/3] Changes: Removed dependency on mouse buttons + +Mouse buttons won't be present in tabs. So instead +tapping on the corresponding side of the goals will +do, irrespective of the button clicked. Put three +MouseArea elements on the left, right and top of the +goal. + +Signed-off-by: Rohit Das +--- + src/activities/penalty/Penalty.qml | 217 ++++++++++++++++++++++++++++--------- + 1 file changed, 168 insertions(+), 49 deletions(-) + +diff --git a/src/activities/penalty/Penalty.qml b/src/activities/penalty/Penalty.qml +index b9ab4de..55c12d2 100644 +--- a/src/activities/penalty/Penalty.qml ++++ b/src/activities/penalty/Penalty.qml +@@ -45,6 +45,167 @@ ActivityBase { + activity.stop.connect(stop) + } + ++ //To enable tapping/clicking on left side of goal ++ Rectangle{ ++ id: maleft ++ anchors.fill: parent.left ++ width: 475 ++ height: 300 ++ x: 100 ++ y: 50 ++ color: "transparent" ++ ++ MouseArea { ++ anchors.fill: parent ++ acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MidButton ++ onClicked: { ++ instruction.text = "" ++ ++ if(ball.state === "FAIL") { ++ Activity.resetLevel() ++ return ++ } ++ ++ /* This is a shoot */ ++ var progress = progressTop ++ if (mouse.button == Qt.LeftButton | mouse.button == Qt.RightButton | mouse.button == Qt.MidButton) { ++ progress = progressLeft ++ } ++ ++ if(progress.ratio > 0) { ++ /* Second click, stop animation */ ++ progress.anim.running = false; ++ ++ /* Play sound */ ++ activity.audioEffects.play("qrc:/gcompris/src/core/resource/sounds/brick.wav") ++ ++ /* Success or not */ ++ if(progress.ratio < 100) { ++ /* Success */ ++ ball.state = "LEFT" ++ } else { ++ /* failure */ ++ ball.state = "FAIL" ++ } ++ timerBonus.start() ++ } else { ++ /* First click, start animation*/ ++ progress.anim.running = true; ++ ++ /* Play sound */ ++ activity.audioEffects.play("qrc:/gcompris/src/core/resource/sounds/flip.wav") ++ } ++ } ++ } ++ } ++ ++ //To enable tapping/clicking on top of goal ++ Rectangle{ ++ id: matop ++ width: 600 ++ height: 175 ++ x: 575 ++ y: 50 ++ color: "transparent" ++ ++ MouseArea { ++ anchors.fill: parent ++ acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MidButton ++ onClicked: { ++ instruction.text = "" ++ ++ if(ball.state === "FAIL") { ++ Activity.resetLevel() ++ return ++ } ++ ++ /* This is a shoot */ ++ var progress = progressTop ++ if (mouse.button == Qt.LeftButton | mouse.button == Qt.RightButton | mouse.button == Qt.MidButton) { ++ ++ } ++ ++ if(progress.ratio > 0) { ++ /* Second click, stop animation */ ++ progress.anim.running = false; ++ ++ /* Play sound */ ++ activity.audioEffects.play("qrc:/gcompris/src/core/resource/sounds/brick.wav") ++ ++ /* Success or not */ ++ if(progress.ratio < 100) { ++ /* Success */ ++ ball.state = "CENTER" ++ } else { ++ /* failure */ ++ ball.state = "FAIL" ++ } ++ timerBonus.start() ++ } else { ++ /* First click, start animation*/ ++ progress.anim.running = true; ++ ++ /* Play sound */ ++ activity.audioEffects.play("qrc:/gcompris/src/core/resource/sounds/flip.wav") ++ } ++ } ++ } ++ } ++ ++ //To enable tapping/clicking on right side of goal ++ Rectangle{ ++ id: maright ++ anchors.fill: parent.right ++ width: 475 ++ height: 300 ++ x: 800 ++ y: 50 ++ color: "transparent" ++ ++ MouseArea { ++ anchors.fill: parent ++ acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MidButton ++ onClicked: { ++ instruction.text = "" ++ ++ if(ball.state === "FAIL") { ++ Activity.resetLevel() ++ return ++ } ++ ++ /* This is a shoot */ ++ var progress = progressTop ++ if (mouse.button == Qt.LeftButton | mouse.button == Qt.RightButton | mouse.button == Qt.MidButton) { ++ progress = progressRight ++ } ++ ++ if(progress.ratio > 0) { ++ /* Second click, stop animation */ ++ progress.anim.running = false; ++ ++ /* Play sound */ ++ activity.audioEffects.play("qrc:/gcompris/src/core/resource/sounds/brick.wav") ++ ++ /* Success or not */ ++ if(progress.ratio < 100) { ++ /* Success */ ++ ball.state = "RIGHT" ++ } else { ++ /* failure */ ++ ball.state = "FAIL" ++ } ++ timerBonus.start() ++ } else { ++ /* First click, start animation*/ ++ progress.anim.running = true; ++ ++ /* Play sound */ ++ activity.audioEffects.play("qrc:/gcompris/src/core/resource/sounds/flip.wav") ++ } ++ } ++ } ++ } ++ + // Add here the QML items you need to access in javascript + QtObject { + id: items +@@ -275,7 +436,7 @@ ActivityBase { + } + PropertyChanges { + target: instruction +- text: qsTr("Double click or double tap on the ball to kick it.") ++ text: qsTr("Double click or double tap on the side of the goal you want to put the ball in.") + } + }, + State { +@@ -320,56 +481,14 @@ ActivityBase { + } + ] + +- MouseArea { ++ MouseArea{ + anchors.fill: parent + acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MidButton +- onClicked: { +- instruction.text = "" +- +- if(ball.state === "FAIL") { +- Activity.resetLevel() +- return +- } +- +- /* This is a shoot */ +- var progress = progressTop +- if (mouse.button == Qt.LeftButton) { +- progress = progressLeft +- } else if (mouse.button == Qt.RightButton) { +- progress = progressRight +- } else if (mouse.button == Qt.MidButton) { +- progress = progressTop +- } +- +- if(progress.ratio > 0) { +- /* Second click, stop animation */ +- progress.anim.running = false; +- +- /* Play sound */ +- activity.audioEffects.play("qrc:/gcompris/src/core/resource/sounds/brick.wav") +- +- /* Success or not */ +- if(progress.ratio < 100) { +- /* Success */ +- if(progress === progressLeft) { +- ball.state = "LEFT" +- } else if(progress === progressRight) { +- ball.state = "RIGHT" +- } else { +- ball.state = "CENTER" +- } +- } else { +- /* failure */ +- ball.state = "FAIL" +- } +- timerBonus.start() +- } else { +- /* First click, start animation*/ +- progress.anim.running = true; +- +- /* Play sound */ +- activity.audioEffects.play("qrc:/gcompris/src/core/resource/sounds/flip.wav") +- } ++ onClicked:{ ++ ball.state = "INITIAL" ++ progressRight.ratio = 0 ++ progressLeft.ratio = 0 ++ progressTop.ratio = 0 + } + } + } +-- +2.7.4 + diff --git a/src/activities/penalty/0003-Changed-Removed-error-caused-by-patch-D7231.patch b/src/activities/penalty/0003-Changed-Removed-error-caused-by-patch-D7231.patch new file mode 100644 --- /dev/null +++ b/src/activities/penalty/0003-Changed-Removed-error-caused-by-patch-D7231.patch @@ -0,0 +1,55 @@ +From d86dca1f3fb315f57e6ee37bced1ce8f22f20c65 Mon Sep 17 00:00:00 2001 +From: Rohit Das +Date: Wed, 16 Aug 2017 00:08:46 +0530 +Subject: [PATCH 3/3] Changed: Removed error caused by patch D7231 + +Signed-off-by: Rohit Das +--- + src/activities/penalty/ActivityInfo.qml | 5 ++--- + src/activities/penalty/Penalty.qml | 4 ++-- + 2 files changed, 4 insertions(+), 5 deletions(-) + +diff --git a/src/activities/penalty/ActivityInfo.qml b/src/activities/penalty/ActivityInfo.qml +index e5530b3..40ee84a 100644 +--- a/src/activities/penalty/ActivityInfo.qml ++++ b/src/activities/penalty/ActivityInfo.qml +@@ -24,12 +24,11 @@ ActivityInfo { + author: "Stephane Mankowski <stephane@mankowski.fr>" + demo: true + title: qsTr("Penalty kick") +- description: qsTr("Double click or double tap on the ball to score a goal.") ++ description: qsTr("Double click or double tap on the side of the goal to score.") + // intro: "Double click or double tap on the ball to score a goal." + goal: "" + prerequisite: "" +- manual: qsTr("Double click or double tap on the ball to kick it. " + +- "You can double click the left right or middle mouse button. " + ++ manual: qsTr("Double click or double tap on the side of the goal to kick it in. " + + "If you lose, Tux catches the ball. You must click on it to " + + "bring it back to its former position") + credit: "" +diff --git a/src/activities/penalty/Penalty.qml b/src/activities/penalty/Penalty.qml +index 55c12d2..e3bba68 100644 +--- a/src/activities/penalty/Penalty.qml ++++ b/src/activities/penalty/Penalty.qml +@@ -48,7 +48,7 @@ ActivityBase { + //To enable tapping/clicking on left side of goal + Rectangle{ + id: maleft +- anchors.fill: parent.left ++ //anchors.fill: parent.left + width: 475 + height: 300 + x: 100 +@@ -155,7 +155,7 @@ ActivityBase { + //To enable tapping/clicking on right side of goal + Rectangle{ + id: maright +- anchors.fill: parent.right ++ //anchors.fill: parent.right + width: 475 + height: 300 + x: 800 +-- +2.7.4 + diff --git a/src/activities/penalty/Penalty.qml b/src/activities/penalty/Penalty.qml --- a/src/activities/penalty/Penalty.qml +++ b/src/activities/penalty/Penalty.qml @@ -39,168 +39,133 @@ anchors.fill: parent signal start signal stop + property string bState: "" //To set ball.state from MouseArea clicked Component.onCompleted: { activity.start.connect(start) activity.stop.connect(stop) } + function ballState(){ //Function to maintain ball state on being kicked + instruction.text = "" + + if(ball.state === "FAIL") { + Activity.resetLevel() + return + } + + /* This is a shoot */ + var progress = progressTop + if (bState == "LEFT") { + progress = progressLeft + } + else if(bState == "CENTER"){ + progress = progressTop + } + else { + progress = progressRight + } + + if(progress.ratio > 0) { + /* Second click, stop animation */ + progress.anim.running = false; + + /* Play sound */ + activity.audioEffects.play("qrc:/gcompris/src/core/resource/sounds/brick.wav") + + /* Success or not */ + if(progress.ratio < 100) { + /* Success */ + ball.state = background.bState + } else { + /* failure */ + ball.state = "FAIL" + } + timerBonus.start() + } else { + /* First click, start animation*/ + progress.anim.running = true; + + /* Play sound */ + activity.audioEffects.play("qrc:/gcompris/src/core/resource/sounds/flip.wav") + } + } + //To enable tapping/clicking on left side of goal - Rectangle{ - id: maleft + Rectangle { + id: rectLeft //anchors.fill: parent.left - width: 475 - height: 300 - x: 100 - y: 50 - color: "transparent" + width: parent.width * 0.36 + height: width * 0.63 + anchors.left: parent.left + anchors.top: parent.top + anchors.leftMargin: 110 + anchors.topMargin: 50 + color: "red" MouseArea { + id: maleft anchors.fill: parent acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MidButton onClicked: { - instruction.text = "" - - if(ball.state === "FAIL") { - Activity.resetLevel() - return - } - - /* This is a shoot */ - var progress = progressTop - if (mouse.button == Qt.LeftButton | mouse.button == Qt.RightButton | mouse.button == Qt.MidButton) { - progress = progressLeft - } - - if(progress.ratio > 0) { - /* Second click, stop animation */ - progress.anim.running = false; - - /* Play sound */ - activity.audioEffects.play("qrc:/gcompris/src/core/resource/sounds/brick.wav") - - /* Success or not */ - if(progress.ratio < 100) { - /* Success */ - ball.state = "LEFT" - } else { - /* failure */ - ball.state = "FAIL" + if(mouse.button){ + if (mouse.button == Qt.LeftButton | mouse.button == Qt.RightButton | mouse.button == Qt.MidButton) { + background.bState = "LEFT" + ballState() } - timerBonus.start() - } else { - /* First click, start animation*/ - progress.anim.running = true; - - /* Play sound */ - activity.audioEffects.play("qrc:/gcompris/src/core/resource/sounds/flip.wav") } } } } //To enable tapping/clicking on top of goal - Rectangle{ - id: matop - width: 600 - height: 175 - x: 575 - y: 50 - color: "transparent" + Rectangle { + id: rectTop + width: parent.width * 0.20 + height: width * 0.55 + anchors.top: parent.top + anchors.left: parent.left + anchors.leftMargin: 575 + anchors.topMargin: 50 + color: "white" MouseArea { + id: matop anchors.fill: parent acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MidButton onClicked: { - instruction.text = "" - - if(ball.state === "FAIL") { - Activity.resetLevel() - return - } - - /* This is a shoot */ - var progress = progressTop - if (mouse.button == Qt.LeftButton | mouse.button == Qt.RightButton | mouse.button == Qt.MidButton) { - - } - - if(progress.ratio > 0) { - /* Second click, stop animation */ - progress.anim.running = false; - - /* Play sound */ - activity.audioEffects.play("qrc:/gcompris/src/core/resource/sounds/brick.wav") - - /* Success or not */ - if(progress.ratio < 100) { - /* Success */ - ball.state = "CENTER" - } else { - /* failure */ - ball.state = "FAIL" + if(mouse.button){ + if (mouse.button == Qt.LeftButton | mouse.button == Qt.RightButton | mouse.button == Qt.MidButton) { + background.bState = "CENTER" + ballState() } - timerBonus.start() - } else { - /* First click, start animation*/ - progress.anim.running = true; - - /* Play sound */ - activity.audioEffects.play("qrc:/gcompris/src/core/resource/sounds/flip.wav") } } } } //To enable tapping/clicking on right side of goal - Rectangle{ - id: maright + Rectangle { + id: rectRight //anchors.fill: parent.right - width: 475 - height: 300 - x: 800 - y: 50 - color: "transparent" + width: parent.width * 0.36 + height: width * 0.63 + anchors.right: parent.right + anchors.top: parent.top + anchors.rightMargin: 90 + anchors.topMargin: 50 + color: "blue" MouseArea { + id: maright anchors.fill: parent acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MidButton onClicked: { - instruction.text = "" - - if(ball.state === "FAIL") { - Activity.resetLevel() - return - } - - /* This is a shoot */ - var progress = progressTop - if (mouse.button == Qt.LeftButton | mouse.button == Qt.RightButton | mouse.button == Qt.MidButton) { - progress = progressRight - } - - if(progress.ratio > 0) { - /* Second click, stop animation */ - progress.anim.running = false; - - /* Play sound */ - activity.audioEffects.play("qrc:/gcompris/src/core/resource/sounds/brick.wav") - - /* Success or not */ - if(progress.ratio < 100) { - /* Success */ - ball.state = "RIGHT" - } else { - /* failure */ - ball.state = "FAIL" + if(mouse.button){ + if (mouse.button == Qt.LeftButton | mouse.button == Qt.RightButton | mouse.button == Qt.MidButton) { + background.bState = "RIGHT" + ballState() } - timerBonus.start() - } else { - /* First click, start animation*/ - progress.anim.running = true; - - /* Play sound */ - activity.audioEffects.play("qrc:/gcompris/src/core/resource/sounds/flip.wav") } } } @@ -444,8 +409,8 @@ PropertyChanges { target: ball; sourceSize.width: 75 * ApplicationInfo.ratio - x: background.width * (Math.random() * (0.8 - 0.6) + 0.6); - y: background.height * (Math.random() * (0.4 - 0.1) + 0.1) + x: background.width * 0.7; + y: background.height * 0.3 } }, State { @@ -453,8 +418,8 @@ PropertyChanges { target: ball; sourceSize.width: 75 * ApplicationInfo.ratio - x: background.width * (Math.random() * (0.4 - 0.1) + 0.1); - y: background.height * (Math.random() * (0.4 - 0.1) + 0.1) + x: background.width * 0.2; + y: background.height * 0.3 } }, State {