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/ActivityInfo.qml b/src/activities/penalty/ActivityInfo.qml --- a/src/activities/penalty/ActivityInfo.qml +++ b/src/activities/penalty/ActivityInfo.qml @@ -24,12 +24,11 @@ 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 --- a/src/activities/penalty/Penalty.qml +++ b/src/activities/penalty/Penalty.qml @@ -45,6 +45,123 @@ activity.stop.connect(stop) } + function changeBallState(saveBallState) { + instruction.text = "" + + if(ball.state === "FAIL") { + Activity.resetLevel() + return + } + + /* This is a shoot */ + var progress = progressTop + if (saveBallState == "LEFT") { + progress = progressLeft + } + else if(saveBallState == "RIGHT"){ + 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 = saveBallState + } 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: rectLeft + width: parent.width * 0.36 + height: width * 0.63 + anchors.left: parent.left + anchors.top: parent.top + anchors.leftMargin: 110 + anchors.topMargin: 50 + color: "transparent" + + MouseArea { + id: maleft + anchors.fill: parent + acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MidButton + onClicked: { + if(mouse.button) { + if (mouse.button) { + changeBallState("LEFT") + } + } + } + } + } + + //To enable tapping/clicking on top of goal + 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: "transparent" + + MouseArea { + id: matop + anchors.fill: parent + acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MidButton + onClicked: { + if(mouse.button) { + if (mouse.button) { + changeBallState("CENTER") + } + } + } + } + } + + //To enable tapping/clicking on right side of goal + Rectangle { + id: rectRight + width: parent.width * 0.36 + height: width * 0.63 + anchors.right: parent.right + anchors.top: parent.top + anchors.rightMargin: 90 + anchors.topMargin: 50 + color: "transparent" + + MouseArea { + id: maright + anchors.fill: parent + acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MidButton + onClicked: { + if(mouse.button) { + if (mouse.button) { + changeBallState("RIGHT") + } + } + } + } + } + // Add here the QML items you need to access in javascript QtObject { id: items @@ -275,7 +392,7 @@ } 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 { @@ -283,7 +400,7 @@ PropertyChanges { target: ball; sourceSize.width: 75 * ApplicationInfo.ratio - x: background.width * 0.8; + x: background.width * 0.7; y: background.height * 0.3 } }, @@ -320,56 +437,14 @@ } ] - 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 } } }