summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKimmo Ollila <kimmo.ollila@digia.com>2013-04-05 12:29:58 +0300
committerKimmo Ollila <kimmo.ollila@digia.com>2013-04-05 12:34:29 +0300
commitfc1b1602303cf2c9d12027c2f73a6a1fb55a78af (patch)
treea6500bd6131ce584ca6d51d4253af484d48cd81f
parentcf415963c09c6e2fc40ec38a0afa8b4958cdc14d (diff)
Added samegame demo and device masks, minor tweaks to the scene
Change-Id: I7fda03501ff44d57d6ea3f7d97ecc9bae2ef9f8b Reviewed-by: Kimmo Ollila <kimmo.ollila@digia.com>
-rw-r--r--QtDemo/qml/QtDemo/Slide.qml53
-rw-r--r--QtDemo/qml/QtDemo/demos/particledemo/particle.pngbin0 -> 861 bytes
-rw-r--r--QtDemo/qml/QtDemo/demos/particledemo/particledemo.qml48
-rw-r--r--QtDemo/qml/QtDemo/demos/samegame/content/Block.qml114
-rw-r--r--QtDemo/qml/QtDemo/demos/samegame/content/BlockEmitter.qml57
-rw-r--r--QtDemo/qml/QtDemo/demos/samegame/content/Button.qml70
-rw-r--r--QtDemo/qml/QtDemo/demos/samegame/content/GameArea.qml226
-rw-r--r--QtDemo/qml/QtDemo/demos/samegame/content/LogoAnimation.qml102
-rw-r--r--QtDemo/qml/QtDemo/demos/samegame/content/MenuEmitter.qml53
-rw-r--r--QtDemo/qml/QtDemo/demos/samegame/content/PaintEmitter.qml98
-rw-r--r--QtDemo/qml/QtDemo/demos/samegame/content/PrimaryPack.qml122
-rw-r--r--QtDemo/qml/QtDemo/demos/samegame/content/PuzzleBlock.qml111
-rw-r--r--QtDemo/qml/QtDemo/demos/samegame/content/SamegameText.qml49
-rw-r--r--QtDemo/qml/QtDemo/demos/samegame/content/SimpleBlock.qml108
-rw-r--r--QtDemo/qml/QtDemo/demos/samegame/content/SmokeText.qml83
-rw-r--r--QtDemo/qml/QtDemo/demos/samegame/content/gfx/background-puzzle.pngbin0 -> 86666 bytes
-rw-r--r--QtDemo/qml/QtDemo/demos/samegame/content/gfx/background.pngbin0 -> 101018 bytes
-rw-r--r--QtDemo/qml/QtDemo/demos/samegame/content/gfx/bar.pngbin0 -> 10970 bytes
-rw-r--r--QtDemo/qml/QtDemo/demos/samegame/content/gfx/blue-puzzle.pngbin0 -> 2219 bytes
-rw-r--r--QtDemo/qml/QtDemo/demos/samegame/content/gfx/blue.pngbin0 -> 1018 bytes
-rw-r--r--QtDemo/qml/QtDemo/demos/samegame/content/gfx/bubble-highscore.pngbin0 -> 2276 bytes
-rw-r--r--QtDemo/qml/QtDemo/demos/samegame/content/gfx/bubble-puzzle.pngbin0 -> 2811 bytes
-rw-r--r--QtDemo/qml/QtDemo/demos/samegame/content/gfx/but-game-1.pngbin0 -> 2728 bytes
-rw-r--r--QtDemo/qml/QtDemo/demos/samegame/content/gfx/but-game-2.pngbin0 -> 3378 bytes
-rw-r--r--QtDemo/qml/QtDemo/demos/samegame/content/gfx/but-game-3.pngbin0 -> 1423 bytes
-rw-r--r--QtDemo/qml/QtDemo/demos/samegame/content/gfx/but-game-4.pngbin0 -> 2096 bytes
-rw-r--r--QtDemo/qml/QtDemo/demos/samegame/content/gfx/but-game-new.pngbin0 -> 3662 bytes
-rw-r--r--QtDemo/qml/QtDemo/demos/samegame/content/gfx/but-menu.pngbin0 -> 2391 bytes
-rw-r--r--QtDemo/qml/QtDemo/demos/samegame/content/gfx/but-puzzle-next.pngbin0 -> 3658 bytes
-rw-r--r--QtDemo/qml/QtDemo/demos/samegame/content/gfx/but-quit.pngbin0 -> 2100 bytes
-rw-r--r--QtDemo/qml/QtDemo/demos/samegame/content/gfx/green-puzzle.pngbin0 -> 2271 bytes
-rw-r--r--QtDemo/qml/QtDemo/demos/samegame/content/gfx/green.pngbin0 -> 1024 bytes
-rw-r--r--QtDemo/qml/QtDemo/demos/samegame/content/gfx/icon-fail.pngbin0 -> 6549 bytes
-rw-r--r--QtDemo/qml/QtDemo/demos/samegame/content/gfx/icon-ok.pngbin0 -> 7190 bytes
-rw-r--r--QtDemo/qml/QtDemo/demos/samegame/content/gfx/icon-time.pngbin0 -> 1159 bytes
-rw-r--r--QtDemo/qml/QtDemo/demos/samegame/content/gfx/logo-a.pngbin0 -> 1814 bytes
-rw-r--r--QtDemo/qml/QtDemo/demos/samegame/content/gfx/logo-e.pngbin0 -> 1725 bytes
-rw-r--r--QtDemo/qml/QtDemo/demos/samegame/content/gfx/logo-g.pngbin0 -> 1765 bytes
-rw-r--r--QtDemo/qml/QtDemo/demos/samegame/content/gfx/logo-m.pngbin0 -> 1743 bytes
-rw-r--r--QtDemo/qml/QtDemo/demos/samegame/content/gfx/logo-s.pngbin0 -> 1791 bytes
-rw-r--r--QtDemo/qml/QtDemo/demos/samegame/content/gfx/logo.pngbin0 -> 3608 bytes
-rw-r--r--QtDemo/qml/QtDemo/demos/samegame/content/gfx/particle-brick.pngbin0 -> 861 bytes
-rw-r--r--QtDemo/qml/QtDemo/demos/samegame/content/gfx/particle-paint.pngbin0 -> 714 bytes
-rw-r--r--QtDemo/qml/QtDemo/demos/samegame/content/gfx/particle-smoke.pngbin0 -> 5409 bytes
-rw-r--r--QtDemo/qml/QtDemo/demos/samegame/content/gfx/red-puzzle.pngbin0 -> 2218 bytes
-rw-r--r--QtDemo/qml/QtDemo/demos/samegame/content/gfx/red.pngbin0 -> 1018 bytes
-rw-r--r--QtDemo/qml/QtDemo/demos/samegame/content/gfx/text-highscore-new.pngbin0 -> 6767 bytes
-rw-r--r--QtDemo/qml/QtDemo/demos/samegame/content/gfx/text-highscore.pngbin0 -> 3179 bytes
-rw-r--r--QtDemo/qml/QtDemo/demos/samegame/content/gfx/text-no-winner.pngbin0 -> 6321 bytes
-rw-r--r--QtDemo/qml/QtDemo/demos/samegame/content/gfx/text-p1-go.pngbin0 -> 5395 bytes
-rw-r--r--QtDemo/qml/QtDemo/demos/samegame/content/gfx/text-p1-won.pngbin0 -> 5618 bytes
-rw-r--r--QtDemo/qml/QtDemo/demos/samegame/content/gfx/text-p1.pngbin0 -> 1751 bytes
-rw-r--r--QtDemo/qml/QtDemo/demos/samegame/content/gfx/text-p2-go.pngbin0 -> 5874 bytes
-rw-r--r--QtDemo/qml/QtDemo/demos/samegame/content/gfx/text-p2-won.pngbin0 -> 6177 bytes
-rw-r--r--QtDemo/qml/QtDemo/demos/samegame/content/gfx/text-p2.pngbin0 -> 2381 bytes
-rw-r--r--QtDemo/qml/QtDemo/demos/samegame/content/gfx/yellow-puzzle.pngbin0 -> 2239 bytes
-rw-r--r--QtDemo/qml/QtDemo/demos/samegame/content/gfx/yellow.pngbin0 -> 1008 bytes
-rw-r--r--QtDemo/qml/QtDemo/demos/samegame/content/levels/TemplateBase.qml70
-rw-r--r--QtDemo/qml/QtDemo/demos/samegame/content/levels/level0.qml59
-rw-r--r--QtDemo/qml/QtDemo/demos/samegame/content/levels/level1.qml59
-rw-r--r--QtDemo/qml/QtDemo/demos/samegame/content/levels/level2.qml61
-rw-r--r--QtDemo/qml/QtDemo/demos/samegame/content/levels/level3.qml60
-rw-r--r--QtDemo/qml/QtDemo/demos/samegame/content/levels/level4.qml58
-rw-r--r--QtDemo/qml/QtDemo/demos/samegame/content/levels/level5.qml59
-rw-r--r--QtDemo/qml/QtDemo/demos/samegame/content/levels/level6.qml60
-rw-r--r--QtDemo/qml/QtDemo/demos/samegame/content/levels/level7.qml58
-rw-r--r--QtDemo/qml/QtDemo/demos/samegame/content/levels/level8.qml59
-rw-r--r--QtDemo/qml/QtDemo/demos/samegame/content/levels/level9.qml62
-rw-r--r--QtDemo/qml/QtDemo/demos/samegame/content/samegame.js581
-rw-r--r--QtDemo/qml/QtDemo/demos/samegame/samegame.qml371
-rw-r--r--QtDemo/qml/QtDemo/demos/samegame/samegame.qrc72
-rw-r--r--QtDemo/qml/QtDemo/demos/samegame/settings.js56
-rw-r--r--QtDemo/qml/QtDemo/engine.js22
-rw-r--r--QtDemo/qml/QtDemo/images/Laptop_mask.pngbin0 -> 75302 bytes
-rw-r--r--QtDemo/qml/QtDemo/images/MedicalDevice_mask.pngbin0 -> 141980 bytes
-rw-r--r--QtDemo/qml/QtDemo/images/Tablet_mask.pngbin0 -> 177597 bytes
-rw-r--r--QtDemo/qml/QtDemo/images/iPhone_mask.pngbin0 -> 157967 bytes
-rw-r--r--QtDemo/qml/QtDemo/main.qml39
78 files changed, 3072 insertions, 28 deletions
diff --git a/QtDemo/qml/QtDemo/Slide.qml b/QtDemo/qml/QtDemo/Slide.qml
index 7ad07df..5aca1e8 100644
--- a/QtDemo/qml/QtDemo/Slide.qml
+++ b/QtDemo/qml/QtDemo/Slide.qml
@@ -6,41 +6,68 @@ Rectangle {
width: 1280
height: 800
color: "transparent"
- border {color: borderColor; width:3}
+ border {color: app.showDebugRects ? borderColor : "transparent"; width:3}
property int uid: 0
property color borderColor: "black"
property string url: ""
+ property int device: 0
property bool loaded: false
Rectangle{
id: demoContainer
anchors.centerIn: parent
- width: 320
- height: 480
+ width: device === 0 ? 320 : device !== 3 ? 700 : 620
+ height: device === 0 ? 480 : device !== 3 ? 480 : 400
color: "black"
clip: true
}
+ ShaderEffectSource {
+ id: disabledImage
+ anchors.fill: demoContainer
+ sourceItem: demoContainer
+ live: false
+ visible: !slide.loaded
+ }
+
+ Image {
+ id: deviceMaskImage
+ anchors.centerIn: parent
+ anchors.verticalCenterOffset: device < 2 ? 45 : device === 2 ? 90 : device !== 3 ? 0: 50
+ anchors.horizontalCenterOffset: -2
+ source: device === 0 ? "images/iPhone_mask.png" :
+ device === 1 ? "images/Tablet_mask.png" :
+ device === 2 ? "images/MedicalDevice_mask.png" :
+ device === 3 ? "images/Laptop_mask.png" :
+ ""
+ width: device === 0 ? 375 : device === 1 ? 838 : device === 2 ? 838 : 867
+ height: device === 0 ? 835 : device === 1 ? 589 : device === 2 ? 762 : 520
+ sourceSize: device === 0 ? Qt.size(375, 835) : device === 1 ? Qt.size(839, 589) : device === 2 ? Qt.size(838, 762) : Qt.size(867, 520)
+ }
+
function loadDemo(){
if (!slide.url || slide.loaded) return;
- slide.loaded = true
var component = Qt.createComponent(slide.url);
var incubator = component.incubateObject(demoContainer, {
x: 0,
y: 0,
objectName: "demoApp"
});
- // if (incubator.status !== Component.Ready) {
- // incubator.onStatusChanged = function(status) {
- // if (status === Component.Ready) {
- // print ("Object", incubator.object, "is now ready!");
- // }
- // }
- // } else {
- // print ("Object", incubator.object, "is ready immediately!");
- // }
+ if (incubator.status !== Component.Ready) {
+ incubator.onStatusChanged = function(status) {
+ if (status === Component.Ready) {
+ print ("Object", incubator.object, "is now ready!");
+ disabledImage.scheduleUpdate()
+ slide.loaded = true
+ }
+ }
+ } else {
+ print ("Object", incubator.object, "is ready immediately!");
+ disabledImage.scheduleUpdate()
+ slide.loaded = true
+ }
}
function releaseDemo(){
diff --git a/QtDemo/qml/QtDemo/demos/particledemo/particle.png b/QtDemo/qml/QtDemo/demos/particledemo/particle.png
new file mode 100644
index 0000000..5c83896
--- /dev/null
+++ b/QtDemo/qml/QtDemo/demos/particledemo/particle.png
Binary files differ
diff --git a/QtDemo/qml/QtDemo/demos/particledemo/particledemo.qml b/QtDemo/qml/QtDemo/demos/particledemo/particledemo.qml
new file mode 100644
index 0000000..3ee4b0f
--- /dev/null
+++ b/QtDemo/qml/QtDemo/demos/particledemo/particledemo.qml
@@ -0,0 +1,48 @@
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Rectangle {
+ width: 800
+ height: 480
+ color: "blue"
+
+ ParticleSystem {
+ id: system
+ width: 640
+ height: 480
+ running: true
+
+ Emitter {
+ id: emitter
+ lifeSpan: 500
+ emitRate: 20
+ size: 12
+ endSize: 30
+ sizeVariation: .5
+ enabled: mouseArea.pressed
+ velocity: AngleDirection{angle:0; angleVariation: 360; magnitude:100}
+ acceleration: AngleDirection{angle:0; angleVariation: 360; magnitude: 100}
+ shape: EllipseShape{fill:true}
+ }
+
+ ImageParticle {
+ source: "particle.png"
+ alpha: 0.0
+ }
+ }
+
+ MouseArea {
+ id: mouseArea
+ anchors.fill: parent
+ onPositionChanged: {
+ emitter.x=mouse.x
+ emitter.y=mouse.y
+ }
+
+ onPressed: {
+ emitter.x=mouse.x
+ emitter.y=mouse.y
+ emitter.burst(10)
+ }
+ }
+}
diff --git a/QtDemo/qml/QtDemo/demos/samegame/content/Block.qml b/QtDemo/qml/QtDemo/demos/samegame/content/Block.qml
new file mode 100644
index 0000000..0b10b7f
--- /dev/null
+++ b/QtDemo/qml/QtDemo/demos/samegame/content/Block.qml
@@ -0,0 +1,114 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Item {
+ id: block
+ property bool dying: false
+ property bool spawned: false
+ property int type: 0
+ property ParticleSystem particleSystem
+
+ Behavior on x {
+ enabled: spawned;
+ SpringAnimation{ spring: 2; damping: 0.2 }
+ }
+ Behavior on y {
+ SpringAnimation{ spring: 2; damping: 0.2 }
+ }
+
+ Image {
+ id: img
+ source: {
+ if (type == 0){
+ "gfx/red.png";
+ } else if (type == 1) {
+ "gfx/blue.png";
+ } else if (type == 2) {
+ "gfx/green.png";
+ } else {
+ "gfx/yellow.png";
+ }
+ }
+ opacity: 0
+ Behavior on opacity { NumberAnimation { duration: 200 } }
+ anchors.fill: parent
+ }
+
+ //Foreground particles
+ BlockEmitter {
+ id: particles
+ system: particleSystem
+ group: {
+ if (type == 0){
+ "red";
+ } else if (type == 1) {
+ "blue";
+ } else if (type == 2) {
+ "green";
+ } else {
+ "yellow";
+ }
+ }
+ anchors.fill: parent
+ }
+
+ //Paint particles on the background
+ PaintEmitter {
+ id: particles2
+ system: particleSystem
+ }
+
+ states: [
+ State {
+ name: "AliveState"; when: spawned == true && dying == false
+ PropertyChanges { target: img; opacity: 1 }
+ },
+
+ State {
+ name: "DeathState"; when: dying == true
+ StateChangeScript { script: {particleSystem.paused = false; particles.pulse(100); particles2.pulse(100);} }
+ PropertyChanges { target: img; opacity: 0 }
+ StateChangeScript { script: block.destroy(1000); }
+ }
+ ]
+}
diff --git a/QtDemo/qml/QtDemo/demos/samegame/content/BlockEmitter.qml b/QtDemo/qml/QtDemo/demos/samegame/content/BlockEmitter.qml
new file mode 100644
index 0000000..ba6261c
--- /dev/null
+++ b/QtDemo/qml/QtDemo/demos/samegame/content/BlockEmitter.qml
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+import "../settings.js" as Settings
+
+Emitter {
+ property Item block: parent
+ velocity: TargetDirection{targetX: block.width/2; targetY: block.height/2; magnitude: -40; magnitudeVariation: 40}
+ acceleration: TargetDirection{targetX: block.width/2; targetY: block.height/2; magnitude: -100;}
+ shape: EllipseShape{fill:true}
+ enabled: false;
+ lifeSpan: 700; lifeSpanVariation: 100
+ emitRate: 1000
+ maximumEmitted: 100 //only fires 0.1s bursts (still 2x old number)
+ size: Settings.blockSize * 0.85
+ endSize: Settings.blockSize * 0.85 /2
+}
diff --git a/QtDemo/qml/QtDemo/demos/samegame/content/Button.qml b/QtDemo/qml/QtDemo/demos/samegame/content/Button.qml
new file mode 100644
index 0000000..4b825ba
--- /dev/null
+++ b/QtDemo/qml/QtDemo/demos/samegame/content/Button.qml
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Item {
+ property alias imgSrc: image.source
+ property alias system: emitter.system
+ property alias group: emitter.group
+ signal clicked
+ property bool rotatedButton: false
+
+ width: image.width
+ height: image.sourceSize.height
+ Image {
+ id: image
+ height: parent.height
+ width: height/sourceSize.height * sourceSize.width
+
+ anchors.horizontalCenter: parent.horizontalCenter
+ rotation: rotatedButton ? ((Math.random() * 3 + 2) * (Math.random() <= 0.5 ? -1 : 1)) : 0
+ MenuEmitter {
+ id: emitter
+ anchors.fill: parent
+ //shape: MaskShape {source: image.source}
+ }
+ }
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {parent.clicked(); emitter.burst(400);}
+ }
+}
diff --git a/QtDemo/qml/QtDemo/demos/samegame/content/GameArea.qml b/QtDemo/qml/QtDemo/demos/samegame/content/GameArea.qml
new file mode 100644
index 0000000..6e72161
--- /dev/null
+++ b/QtDemo/qml/QtDemo/demos/samegame/content/GameArea.qml
@@ -0,0 +1,226 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+import "samegame.js" as Logic
+
+Item {
+ id: gameCanvas
+ property bool gameOver: true
+ property int score: 0
+ property int highScore: 0
+ property int moves: 0
+ property string mode: ""
+ property ParticleSystem ps: particleSystem
+ //For easy theming
+ property alias backgroundVisible: bg.visible
+ property string background: "gfx/background.png"
+ property string blockFile: "Block.qml"
+ onBlockFileChanged: Logic.changeBlock(blockFile);
+ property alias particlePack: auxLoader.source
+ //For multiplayer
+ property int score2: 0
+ property int curTurn: 1
+ property bool autoTurnChange: false
+ signal swapPlayers
+ property bool swapping: false
+ //onSwapPlayers: if (autoTurnChange) Logic.turnChange();//Now implemented below
+ //For puzzle
+ property url level
+ property bool puzzleWon: false
+ signal puzzleLost //Since root is tracking the puzzle progress
+ function showPuzzleEnd (won) {
+ if (won) {
+ smokeParticle.color = Qt.rgba(0,1,0,0);
+ puzzleWin.play();
+ } else {
+ smokeParticle.color = Qt.rgba(1,0,0,0);
+ puzzleFail.play();
+ puzzleLost();
+ }
+ }
+ function showPuzzleGoal (str) {
+ puzzleTextBubble.opacity = 1;
+ puzzleTextLabel.text = str;
+ }
+ Image {
+ id: bg
+ z: -1
+ anchors.fill: parent
+ source: background;
+ fillMode: Image.PreserveAspectCrop
+ }
+
+ MouseArea {
+ anchors.fill: parent; onClicked: {
+ if (puzzleTextBubble.opacity == 1) {
+ puzzleTextBubble.opacity = 0;
+ Logic.finishLoadingMap();
+ } else if (!swapping) {
+ Logic.handleClick(mouse.x,mouse.y);
+ }
+ }
+ }
+
+ Image {
+ id: highScoreTextBubble
+ opacity: mode == "arcade" && gameOver && gameCanvas.score == gameCanvas.highScore ? 1 : 0
+ Behavior on opacity { NumberAnimation {} }
+ anchors.centerIn: parent
+ z: 10
+ source: "gfx/bubble-highscore.png"
+ Image {
+ anchors.centerIn: parent
+ source: "gfx/text-highscore-new.png"
+ rotation: -10
+ }
+ }
+
+ Image {
+ id: puzzleTextBubble
+ anchors.centerIn: parent
+ opacity: 0
+ Behavior on opacity { NumberAnimation {} }
+ z: 10
+ source: "gfx/bubble-puzzle.png"
+ Connections {
+ target: gameCanvas
+ onModeChanged: if (mode != "puzzle" && puzzleTextBubble.opacity > 0) puzzleTextBubble.opacity = 0;
+ }
+ Text {
+ id: puzzleTextLabel
+ width: parent.width - 24
+ anchors.centerIn: parent
+ horizontalAlignment: Text.AlignHCenter
+ color: "white"
+ font.pixelSize: 24
+ font.bold: true
+ wrapMode: Text.WordWrap
+ }
+ }
+ onModeChanged: {
+ p1WonImg.opacity = 0;
+ p2WonImg.opacity = 0;
+ }
+ SmokeText { id: puzzleWin; source: "gfx/icon-ok.png"; system: particleSystem }
+ SmokeText { id: puzzleFail; source: "gfx/icon-fail.png"; system: particleSystem }
+
+ onSwapPlayers: {
+ smokeParticle.color = "yellow"
+ Logic.turnChange();
+ if (curTurn == 1) {
+ p1Text.play();
+ } else {
+ p2Text.play();
+ }
+ clickDelay.running = true;
+ }
+ SequentialAnimation {
+ id: clickDelay
+ ScriptAction { script: gameCanvas.swapping = true; }
+ PauseAnimation { duration: 750 }
+ ScriptAction { script: gameCanvas.swapping = false; }
+ }
+
+ SmokeText {
+ id: p1Text; source: "gfx/text-p1-go.png";
+ system: particleSystem; playerNum: 1
+ opacity: p1WonImg.opacity + p2WonImg.opacity > 0 ? 0 : 1
+ }
+
+ SmokeText {
+ id: p2Text; source: "gfx/text-p2-go.png";
+ system: particleSystem; playerNum: 2
+ opacity: p1WonImg.opacity + p2WonImg.opacity > 0 ? 0 : 1
+ }
+
+ onGameOverChanged: {
+ if (gameCanvas.mode == "multiplayer") {
+ if (gameCanvas.score >= gameCanvas.score2) {
+ p1WonImg.opacity = 1;
+ } else {
+ p2WonImg.opacity = 1;
+ }
+ }
+ }
+ Image {
+ id: p1WonImg
+ source: "gfx/text-p1-won.png"
+ anchors.centerIn: parent
+ opacity: 0
+ Behavior on opacity { NumberAnimation {} }
+ z: 10
+ }
+ Image {
+ id: p2WonImg
+ source: "gfx/text-p2-won.png"
+ anchors.centerIn: parent
+ opacity: 0
+ Behavior on opacity { NumberAnimation {} }
+ z: 10
+ }
+
+ ParticleSystem{
+ id: particleSystem;
+ anchors.fill: parent
+ z: 5
+ ImageParticle {
+ id: smokeParticle
+ groups: ["smoke"]
+ source: "gfx/particle-smoke.png"
+ alpha: 0.1
+ alphaVariation: 0.1
+ color: "yellow"
+ }
+ Loader {
+ id: auxLoader
+ anchors.fill: parent
+ source: "PrimaryPack.qml"
+ onItemChanged: {
+ if (item && "particleSystem" in item)
+ item.particleSystem = particleSystem
+ if (item && "gameArea" in item)
+ item.gameArea = gameCanvas
+ }
+ }
+ }
+}
+
diff --git a/QtDemo/qml/QtDemo/demos/samegame/content/LogoAnimation.qml b/QtDemo/qml/QtDemo/demos/samegame/content/LogoAnimation.qml
new file mode 100644
index 0000000..fb050e7
--- /dev/null
+++ b/QtDemo/qml/QtDemo/demos/samegame/content/LogoAnimation.qml
@@ -0,0 +1,102 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Item {
+ id: container //Positioned where the 48x48 S/G should be
+ property alias running: mainAnim.running
+ property ParticleSystem particleSystem
+ property int dur: 500
+ signal boomTime
+ Image {
+ id: s1
+ source: "gfx/logo-s.png"
+ y: 0
+ }
+ Image {
+ id: g1
+ source: "gfx/logo-g.png"
+ y: -128
+ }
+ Column {
+ Repeater {
+ model: 2
+ Item {
+ width: 48
+ height: 48
+ BlockEmitter {
+ id: emitter
+ anchors.fill: parent
+ group: "red"
+ system: particleSystem
+ Connections {
+ target: container
+ onBoomTime: emitter.pulse(100);
+ }
+ }
+ }
+ }
+ }
+ SequentialAnimation {
+ id: mainAnim
+ running: true
+ loops: -1
+ PropertyAction { target: g1; property: "y"; value: -128}
+ PropertyAction { target: g1; property: "opacity"; value: 1}
+ PropertyAction { target: s1; property: "y"; value: 0}
+ PropertyAction { target: s1; property: "opacity"; value: 1}
+ NumberAnimation { target: g1; property: "y"; from: -96; to: -48; duration: dur}
+ ParallelAnimation {
+ NumberAnimation { target: g1; property: "y"; from: -48; to: 0; duration: dur}
+ NumberAnimation { target: s1; property: "y"; from: 0; to: 48; duration: dur }
+ }
+ PauseAnimation { duration: dur }
+ ScriptAction { script: container.boomTime(); }
+ ParallelAnimation {
+ NumberAnimation { target: g1; property: "opacity"; to: 0; duration: dur }
+ NumberAnimation { target: s1; property: "opacity"; to: 0; duration: dur }
+ }
+ PropertyAction { target: s1; property: "y"; value: -128}
+ PropertyAction { target: s1; property: "opacity"; value: 1}
+ NumberAnimation { target: s1; property: "y"; from: -96; to: 0; duration: dur * 2}
+ }
+}
diff --git a/QtDemo/qml/QtDemo/demos/samegame/content/MenuEmitter.qml b/QtDemo/qml/QtDemo/demos/samegame/content/MenuEmitter.qml
new file mode 100644
index 0000000..93089fc
--- /dev/null
+++ b/QtDemo/qml/QtDemo/demos/samegame/content/MenuEmitter.qml
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Emitter {
+ anchors.fill: parent
+ velocity: AngleDirection{angleVariation: 360; magnitude: 140; magnitudeVariation: 40}
+ enabled: false;
+ lifeSpan: 500;
+ emitRate: 1
+ size: 28
+ endSize: 14
+ group: "yellow"
+}
diff --git a/QtDemo/qml/QtDemo/demos/samegame/content/PaintEmitter.qml b/QtDemo/qml/QtDemo/demos/samegame/content/PaintEmitter.qml
new file mode 100644
index 0000000..fe758af
--- /dev/null
+++ b/QtDemo/qml/QtDemo/demos/samegame/content/PaintEmitter.qml
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+import "../settings.js" as Settings
+
+Emitter {
+ property Item block: parent
+ anchors.fill: parent
+ shape: EllipseShape { fill: true }
+ group: {
+ if (block.type == 0){
+ "redspots";
+ } else if (block.type == 1) {
+ "bluespots";
+ } else if (block.type == 2) {
+ "greenspots";
+ } else {
+ "yellowspots";
+ }
+ }
+ size: Settings.blockSize * 2
+ endSize: Settings.blockSize/2
+ lifeSpan: 30000
+ enabled: false
+ emitRate: 60
+ maximumEmitted: 60
+ velocity: PointDirection{ y: 4; yVariation: 4 }
+ /* Possibly better, but dependent on gerrit change,28212
+ property real mainIntensity: 0.8
+ property real subIntensity: 0.1
+ property real colorVariation: 0.005
+ onEmitParticles: {//One group, many colors, for better stacking
+ for (var i=0; i<particles.length; i++) {
+ var particle = particles[i];
+ if (block.type == 0) {
+ particle.red = mainIntensity + (Math.random() * colorVariation * 2 - colorVariation);
+ particle.green = subIntensity + (Math.random() * colorVariation * 2 - colorVariation);
+ particle.blue = subIntensity + (Math.random() * colorVariation * 2 - colorVariation);
+ } else if (block.type == 1) {
+ particle.red = subIntensity + (Math.random() * colorVariation * 2 - colorVariation);
+ particle.green = subIntensity + (Math.random() * colorVariation * 2 - colorVariation);
+ particle.blue = mainIntensity + (Math.random() * colorVariation * 2 - colorVariation);
+ } else if (block.type == 2) {
+ particle.red = subIntensity + (Math.random() * colorVariation * 2 - colorVariation);
+ particle.green = mainIntensity + (Math.random() * colorVariation * 2 - colorVariation);
+ particle.blue = subIntensity + (Math.random() * colorVariation * 2 - colorVariation);
+ } else if (block.type == 3) {
+ particle.red = mainIntensity + (Math.random() * colorVariation * 2 - colorVariation);
+ particle.green = mainIntensity + (Math.random() * colorVariation * 2 - colorVariation);
+ particle.blue = subIntensity + (Math.random() * colorVariation * 2 - colorVariation);
+ } else {
+ particle.red = mainIntensity + (Math.random() * colorVariation * 2 - colorVariation);
+ particle.green = mainIntensity + (Math.random() * colorVariation * 2 - colorVariation);
+ particle.blue = mainIntensity + (Math.random() * colorVariation * 2 - colorVariation);
+ }
+ }
+ }
+ */
+}
diff --git a/QtDemo/qml/QtDemo/demos/samegame/content/PrimaryPack.qml b/QtDemo/qml/QtDemo/demos/samegame/content/PrimaryPack.qml
new file mode 100644
index 0000000..3fe7fb1
--- /dev/null
+++ b/QtDemo/qml/QtDemo/demos/samegame/content/PrimaryPack.qml
@@ -0,0 +1,122 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Item {
+ id: container
+ property ParticleSystem particleSystem
+ property GameArea gameArea
+ onGameAreaChanged: bgstacker.parent = gameArea;//Move to direct child of game canvas
+ Item {
+ id: bgstacker
+ z: 0
+ ImageParticle {
+ groups: ["yellowspots"]
+ color: Qt.darker("yellow");//Actually want desaturated...
+ system: particleSystem
+ source: "gfx/particle-paint.png"
+ colorVariation: 0.2
+ alpha: 0.2
+ entryEffect: ImageParticle.None
+ }
+ ImageParticle {
+ groups: ["redspots"]
+ system: particleSystem
+ color: Qt.darker("red");//Actually want desaturated...
+ source: "gfx/particle-paint.png"
+ colorVariation: 0.2
+ alpha: 0.2
+ entryEffect: ImageParticle.None
+ }
+ ImageParticle {
+ groups: ["greenspots"]
+ system: particleSystem
+ color: Qt.darker("green");//Actually want desaturated...
+ source: "gfx/particle-paint.png"
+ colorVariation: 0.2
+ alpha: 0.2
+ entryEffect: ImageParticle.None
+ }
+ ImageParticle {
+ groups: ["bluespots"]
+ system: particleSystem
+ color: Qt.darker("blue");//Actually want desaturated...
+ source: "gfx/particle-paint.png"
+ colorVariation: 0.2
+ alpha: 0.2
+ entryEffect: ImageParticle.None
+ }
+ }
+ ImageParticle {
+ groups: ["yellow"]
+ system: particleSystem
+ color: Qt.darker("yellow");//Actually want desaturated...
+ source: "gfx/particle-brick.png"
+ colorVariation: 0.4
+ alpha: 0.1
+ }
+ ImageParticle {
+ groups: ["red"]
+ system: particleSystem
+ color: Qt.darker("red");//Actually want desaturated...
+ source: "gfx/particle-brick.png"
+ colorVariation: 0.4
+ alpha: 0.1
+ }
+ ImageParticle {
+ groups: ["green"]
+ system: particleSystem
+ color: Qt.darker("green");//Actually want desaturated...
+ source: "gfx/particle-brick.png"
+ colorVariation: 0.4
+ alpha: 0.1
+ }
+ ImageParticle {
+ groups: ["blue"]
+ system: particleSystem
+ color: Qt.darker("blue");//Actually want desaturated...
+ source: "gfx/particle-brick.png"
+ colorVariation: 0.4
+ alpha: 0.1
+ }
+}
diff --git a/QtDemo/qml/QtDemo/demos/samegame/content/PuzzleBlock.qml b/QtDemo/qml/QtDemo/demos/samegame/content/PuzzleBlock.qml
new file mode 100644
index 0000000..4f5b043
--- /dev/null
+++ b/QtDemo/qml/QtDemo/demos/samegame/content/PuzzleBlock.qml
@@ -0,0 +1,111 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Item {
+ id: block
+ property bool dying: false
+ property bool spawned: false
+ property int type: 0
+ property ParticleSystem particleSystem
+
+ Behavior on x {
+ enabled: spawned;
+ NumberAnimation{ easing.type: Easing.OutBounce }
+ }
+ Behavior on y {
+ NumberAnimation{ easing.type: Easing.InQuad }
+ }
+
+ Image {
+ id: img
+ source: {
+ if (type == 0){
+ "gfx/red-puzzle.png";
+ } else if (type == 1) {
+ "gfx/blue-puzzle.png";
+ } else if (type == 2) {
+ "gfx/green-puzzle.png";
+ } else {
+ "gfx/yellow-puzzle.png";
+ }
+ }
+ opacity: 0
+ Behavior on opacity { NumberAnimation { duration: 200 } }
+ anchors.centerIn: parent
+ anchors.verticalCenterOffset: -4
+ anchors.horizontalCenterOffset: 4
+ }
+
+ //Foreground particles
+ BlockEmitter {
+ id: particles
+ system: particleSystem
+ group: {
+ if (type == 0){
+ "red";
+ } else if (type == 1) {
+ "blue";
+ } else if (type == 2) {
+ "green";
+ } else {
+ "yellow";
+ }
+ }
+ anchors.fill: parent
+ }
+
+ states: [
+ State {
+ name: "AliveState"; when: spawned == true && dying == false
+ PropertyChanges { target: img; opacity: 1 }
+ },
+
+ State {
+ name: "DeathState"; when: dying == true
+ PropertyChanges { target: img; scale: 2 }
+ StateChangeScript { script: particles.pulse(200); }
+ PropertyChanges { target: img; opacity: 0 }
+ StateChangeScript { script: block.destroy(1000); }
+ }
+ ]
+}
diff --git a/QtDemo/qml/QtDemo/demos/samegame/content/SamegameText.qml b/QtDemo/qml/QtDemo/demos/samegame/content/SamegameText.qml
new file mode 100644
index 0000000..28c85f9
--- /dev/null
+++ b/QtDemo/qml/QtDemo/demos/samegame/content/SamegameText.qml
@@ -0,0 +1,49 @@
+/***************************************************************************
+**
+** Copyright (C) 2012 Research In Motion
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "../settings.js" as Settings
+
+Text {
+ font.pixelSize: Settings.fontPixelSize;
+ color: "white";
+ textFormat: Text.StyledText;
+ Behavior on opacity { NumberAnimation {} }
+}
diff --git a/QtDemo/qml/QtDemo/demos/samegame/content/SimpleBlock.qml b/QtDemo/qml/QtDemo/demos/samegame/content/SimpleBlock.qml
new file mode 100644
index 0000000..5ae4782
--- /dev/null
+++ b/QtDemo/qml/QtDemo/demos/samegame/content/SimpleBlock.qml
@@ -0,0 +1,108 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Item {
+ id: block
+ property bool dying: false
+ property bool spawned: false
+ property int type: 0
+ property ParticleSystem particleSystem
+
+ Behavior on x {
+ enabled: spawned;
+ SpringAnimation{ spring: 2; damping: 0.2 }
+ }
+ Behavior on y {
+ SpringAnimation{ spring: 2; damping: 0.2 }
+ }
+
+ Image {
+ id: img
+ source: {
+ if (type == 0){
+ "gfx/red.png";
+ } else if (type == 1) {
+ "gfx/blue.png";
+ } else if (type == 2) {
+ "gfx/green.png";
+ } else {
+ "gfx/yellow.png";
+ }
+ }
+ opacity: 0
+ Behavior on opacity { NumberAnimation { duration: 200 } }
+ anchors.fill: parent
+ }
+
+ //Foreground particles
+ BlockEmitter {
+ id: particles
+ system: particleSystem
+ group: {
+ if (type == 0){
+ "red";
+ } else if (type == 1) {
+ "blue";
+ } else if (type == 2) {
+ "green";
+ } else {
+ "yellow";
+ }
+ }
+ anchors.fill: parent
+ }
+
+ states: [
+ State {
+ name: "AliveState"; when: spawned == true && dying == false
+ PropertyChanges { target: img; opacity: 1 }
+ },
+
+ State {
+ name: "DeathState"; when: dying == true
+ StateChangeScript { script: {particleSystem.paused = false; particles.pulse(100); } }
+ PropertyChanges { target: img; opacity: 0 }
+ StateChangeScript { script: block.destroy(1000); }
+ }
+ ]
+}
diff --git a/QtDemo/qml/QtDemo/demos/samegame/content/SmokeText.qml b/QtDemo/qml/QtDemo/demos/samegame/content/SmokeText.qml
new file mode 100644
index 0000000..46bc509
--- /dev/null
+++ b/QtDemo/qml/QtDemo/demos/samegame/content/SmokeText.qml
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Item {
+ z: 10
+ property alias source: img.source
+ property alias system: emitter.system
+ property int playerNum: 1
+ function play() {
+ anim.running = true;
+ }
+ anchors.centerIn: parent
+ Image {
+ opacity: 0
+ id: img
+ anchors.centerIn: parent
+ rotation: playerNum == 1 ? -8 : -5
+ Emitter {
+ id: emitter
+ group: "smoke"
+ anchors.fill: parent
+ shape: MaskShape { source: img.source }
+ enabled: false
+ emitRate: 1000
+ lifeSpan: 600
+ size: 64
+ endSize: 32
+ velocity: AngleDirection { angleVariation: 360; magnitudeVariation: 160 }
+ }
+ }
+ SequentialAnimation {
+ id: anim
+ running: false
+ PauseAnimation { duration: 500}
+ ParallelAnimation {
+ NumberAnimation { target: img; property: "opacity"; from: 0.1; to: 1.0 }
+ NumberAnimation { target: img; property: "scale"; from: 0.1; to: 1.0 }
+ }
+ PauseAnimation { duration: 250}
+ ScriptAction { script: emitter.pulse(100); }
+ NumberAnimation { target: img; property: "opacity"; from: 1.0; to: 0.0 }
+ }
+}
diff --git a/QtDemo/qml/QtDemo/demos/samegame/content/gfx/background-puzzle.png b/QtDemo/qml/QtDemo/demos/samegame/content/gfx/background-puzzle.png
new file mode 100644
index 0000000..c2eca5f
--- /dev/null
+++ b/QtDemo/qml/QtDemo/demos/samegame/content/gfx/background-puzzle.png
Binary files differ
diff --git a/QtDemo/qml/QtDemo/demos/samegame/content/gfx/background.png b/QtDemo/qml/QtDemo/demos/samegame/content/gfx/background.png
new file mode 100644
index 0000000..60f57b6
--- /dev/null
+++ b/QtDemo/qml/QtDemo/demos/samegame/content/gfx/background.png
Binary files differ
diff --git a/QtDemo/qml/QtDemo/demos/samegame/content/gfx/bar.png b/QtDemo/qml/QtDemo/demos/samegame/content/gfx/bar.png
new file mode 100644
index 0000000..4953cd6
--- /dev/null
+++ b/QtDemo/qml/QtDemo/demos/samegame/content/gfx/bar.png
Binary files differ
diff --git a/QtDemo/qml/QtDemo/demos/samegame/content/gfx/blue-puzzle.png b/QtDemo/qml/QtDemo/demos/samegame/content/gfx/blue-puzzle.png
new file mode 100644
index 0000000..e550d59
--- /dev/null
+++ b/QtDemo/qml/QtDemo/demos/samegame/content/gfx/blue-puzzle.png
Binary files differ
diff --git a/QtDemo/qml/QtDemo/demos/samegame/content/gfx/blue.png b/QtDemo/qml/QtDemo/demos/samegame/content/gfx/blue.png
new file mode 100644
index 0000000..b8161c0
--- /dev/null
+++ b/QtDemo/qml/QtDemo/demos/samegame/content/gfx/blue.png
Binary files differ
diff --git a/QtDemo/qml/QtDemo/demos/samegame/content/gfx/bubble-highscore.png b/QtDemo/qml/QtDemo/demos/samegame/content/gfx/bubble-highscore.png
new file mode 100644
index 0000000..c4e38df
--- /dev/null
+++ b/QtDemo/qml/QtDemo/demos/samegame/content/gfx/bubble-highscore.png
Binary files differ
diff --git a/QtDemo/qml/QtDemo/demos/samegame/content/gfx/bubble-puzzle.png b/QtDemo/qml/QtDemo/demos/samegame/content/gfx/bubble-puzzle.png
new file mode 100644
index 0000000..278556b
--- /dev/null
+++ b/QtDemo/qml/QtDemo/demos/samegame/content/gfx/bubble-puzzle.png
Binary files differ
diff --git a/QtDemo/qml/QtDemo/demos/samegame/content/gfx/but-game-1.png b/QtDemo/qml/QtDemo/demos/samegame/content/gfx/but-game-1.png
new file mode 100644
index 0000000..3343b7f
--- /dev/null
+++ b/QtDemo/qml/QtDemo/demos/samegame/content/gfx/but-game-1.png
Binary files differ
diff --git a/QtDemo/qml/QtDemo/demos/samegame/content/gfx/but-game-2.png b/QtDemo/qml/QtDemo/demos/samegame/content/gfx/but-game-2.png
new file mode 100644
index 0000000..afba106
--- /dev/null
+++ b/QtDemo/qml/QtDemo/demos/samegame/content/gfx/but-game-2.png
Binary files differ
diff --git a/QtDemo/qml/QtDemo/demos/samegame/content/gfx/but-game-3.png b/QtDemo/qml/QtDemo/demos/samegame/content/gfx/but-game-3.png
new file mode 100644
index 0000000..adea77a
--- /dev/null
+++ b/QtDemo/qml/QtDemo/demos/samegame/content/gfx/but-game-3.png
Binary files differ
diff --git a/QtDemo/qml/QtDemo/demos/samegame/content/gfx/but-game-4.png b/QtDemo/qml/QtDemo/demos/samegame/content/gfx/but-game-4.png
new file mode 100644
index 0000000..18c922b
--- /dev/null
+++ b/QtDemo/qml/QtDemo/demos/samegame/content/gfx/but-game-4.png
Binary files differ
diff --git a/QtDemo/qml/QtDemo/demos/samegame/content/gfx/but-game-new.png b/QtDemo/qml/QtDemo/demos/samegame/content/gfx/but-game-new.png
new file mode 100644
index 0000000..257e182
--- /dev/null
+++ b/QtDemo/qml/QtDemo/demos/samegame/content/gfx/but-game-new.png
Binary files differ
diff --git a/QtDemo/qml/QtDemo/demos/samegame/content/gfx/but-menu.png b/QtDemo/qml/QtDemo/demos/samegame/content/gfx/but-menu.png
new file mode 100644
index 0000000..8440e87
--- /dev/null
+++ b/QtDemo/qml/QtDemo/demos/samegame/content/gfx/but-menu.png
Binary files differ
diff --git a/QtDemo/qml/QtDemo/demos/samegame/content/gfx/but-puzzle-next.png b/QtDemo/qml/QtDemo/demos/samegame/content/gfx/but-puzzle-next.png
new file mode 100644
index 0000000..7e3ed41
--- /dev/null
+++ b/QtDemo/qml/QtDemo/demos/samegame/content/gfx/but-puzzle-next.png
Binary files differ
diff --git a/QtDemo/qml/QtDemo/demos/samegame/content/gfx/but-quit.png b/QtDemo/qml/QtDemo/demos/samegame/content/gfx/but-quit.png
new file mode 100644
index 0000000..95c77ce
--- /dev/null
+++ b/QtDemo/qml/QtDemo/demos/samegame/content/gfx/but-quit.png
Binary files differ
diff --git a/QtDemo/qml/QtDemo/demos/samegame/content/gfx/green-puzzle.png b/QtDemo/qml/QtDemo/demos/samegame/content/gfx/green-puzzle.png
new file mode 100644
index 0000000..581f76f
--- /dev/null
+++ b/QtDemo/qml/QtDemo/demos/samegame/content/gfx/green-puzzle.png
Binary files differ
diff --git a/QtDemo/qml/QtDemo/demos/samegame/content/gfx/green.png b/QtDemo/qml/QtDemo/demos/samegame/content/gfx/green.png
new file mode 100644
index 0000000..da4cca5
--- /dev/null
+++ b/QtDemo/qml/QtDemo/demos/samegame/content/gfx/green.png
Binary files differ
diff --git a/QtDemo/qml/QtDemo/demos/samegame/content/gfx/icon-fail.png b/QtDemo/qml/QtDemo/demos/samegame/content/gfx/icon-fail.png
new file mode 100644
index 0000000..4072611
--- /dev/null
+++ b/QtDemo/qml/QtDemo/demos/samegame/content/gfx/icon-fail.png
Binary files differ
diff --git a/QtDemo/qml/QtDemo/demos/samegame/content/gfx/icon-ok.png b/QtDemo/qml/QtDemo/demos/samegame/content/gfx/icon-ok.png
new file mode 100644
index 0000000..15a8442
--- /dev/null
+++ b/QtDemo/qml/QtDemo/demos/samegame/content/gfx/icon-ok.png
Binary files differ
diff --git a/QtDemo/qml/QtDemo/demos/samegame/content/gfx/icon-time.png b/QtDemo/qml/QtDemo/demos/samegame/content/gfx/icon-time.png
new file mode 100644
index 0000000..9490e49
--- /dev/null
+++ b/QtDemo/qml/QtDemo/demos/samegame/content/gfx/icon-time.png
Binary files differ
diff --git a/QtDemo/qml/QtDemo/demos/samegame/content/gfx/logo-a.png b/QtDemo/qml/QtDemo/demos/samegame/content/gfx/logo-a.png
new file mode 100644
index 0000000..20c20ba
--- /dev/null
+++ b/QtDemo/qml/QtDemo/demos/samegame/content/gfx/logo-a.png
Binary files differ
diff --git a/QtDemo/qml/QtDemo/demos/samegame/content/gfx/logo-e.png b/QtDemo/qml/QtDemo/demos/samegame/content/gfx/logo-e.png
new file mode 100644
index 0000000..dd663f1
--- /dev/null
+++ b/QtDemo/qml/QtDemo/demos/samegame/content/gfx/logo-e.png
Binary files differ
diff --git a/QtDemo/qml/QtDemo/demos/samegame/content/gfx/logo-g.png b/QtDemo/qml/QtDemo/demos/samegame/content/gfx/logo-g.png
new file mode 100644
index 0000000..a319bf9
--- /dev/null
+++ b/QtDemo/qml/QtDemo/demos/samegame/content/gfx/logo-g.png
Binary files differ
diff --git a/QtDemo/qml/QtDemo/demos/samegame/content/gfx/logo-m.png b/QtDemo/qml/QtDemo/demos/samegame/content/gfx/logo-m.png
new file mode 100644
index 0000000..6a029b3
--- /dev/null
+++ b/QtDemo/qml/QtDemo/demos/samegame/content/gfx/logo-m.png
Binary files differ
diff --git a/QtDemo/qml/QtDemo/demos/samegame/content/gfx/logo-s.png b/QtDemo/qml/QtDemo/demos/samegame/content/gfx/logo-s.png
new file mode 100644
index 0000000..963b175
--- /dev/null
+++ b/QtDemo/qml/QtDemo/demos/samegame/content/gfx/logo-s.png
Binary files differ
diff --git a/QtDemo/qml/QtDemo/demos/samegame/content/gfx/logo.png b/QtDemo/qml/QtDemo/demos/samegame/content/gfx/logo.png
new file mode 100644
index 0000000..e900edd
--- /dev/null
+++ b/QtDemo/qml/QtDemo/demos/samegame/content/gfx/logo.png
Binary files differ
diff --git a/QtDemo/qml/QtDemo/demos/samegame/content/gfx/particle-brick.png b/QtDemo/qml/QtDemo/demos/samegame/content/gfx/particle-brick.png
new file mode 100644
index 0000000..5c83896
--- /dev/null
+++ b/QtDemo/qml/QtDemo/demos/samegame/content/gfx/particle-brick.png
Binary files differ
diff --git a/QtDemo/qml/QtDemo/demos/samegame/content/gfx/particle-paint.png b/QtDemo/qml/QtDemo/demos/samegame/content/gfx/particle-paint.png
new file mode 100644
index 0000000..9bd0a2a
--- /dev/null
+++ b/QtDemo/qml/QtDemo/demos/samegame/content/gfx/particle-paint.png
Binary files differ
diff --git a/QtDemo/qml/QtDemo/demos/samegame/content/gfx/particle-smoke.png b/QtDemo/qml/QtDemo/demos/samegame/content/gfx/particle-smoke.png
new file mode 100644
index 0000000..b27f954
--- /dev/null
+++ b/QtDemo/qml/QtDemo/demos/samegame/content/gfx/particle-smoke.png
Binary files differ
diff --git a/QtDemo/qml/QtDemo/demos/samegame/content/gfx/red-puzzle.png b/QtDemo/qml/QtDemo/demos/samegame/content/gfx/red-puzzle.png
new file mode 100644
index 0000000..9ceb17e
--- /dev/null
+++ b/QtDemo/qml/QtDemo/demos/samegame/content/gfx/red-puzzle.png
Binary files differ
diff --git a/QtDemo/qml/QtDemo/demos/samegame/content/gfx/red.png b/QtDemo/qml/QtDemo/demos/samegame/content/gfx/red.png
new file mode 100644
index 0000000..681810f
--- /dev/null
+++ b/QtDemo/qml/QtDemo/demos/samegame/content/gfx/red.png
Binary files differ
diff --git a/QtDemo/qml/QtDemo/demos/samegame/content/gfx/text-highscore-new.png b/QtDemo/qml/QtDemo/demos/samegame/content/gfx/text-highscore-new.png
new file mode 100644
index 0000000..50f7fcd
--- /dev/null
+++ b/QtDemo/qml/QtDemo/demos/samegame/content/gfx/text-highscore-new.png
Binary files differ
diff --git a/QtDemo/qml/QtDemo/demos/samegame/content/gfx/text-highscore.png b/QtDemo/qml/QtDemo/demos/samegame/content/gfx/text-highscore.png
new file mode 100644
index 0000000..7198c27
--- /dev/null
+++ b/QtDemo/qml/QtDemo/demos/samegame/content/gfx/text-highscore.png
Binary files differ
diff --git a/QtDemo/qml/QtDemo/demos/samegame/content/gfx/text-no-winner.png b/QtDemo/qml/QtDemo/demos/samegame/content/gfx/text-no-winner.png
new file mode 100644
index 0000000..b4a6685
--- /dev/null
+++ b/QtDemo/qml/QtDemo/demos/samegame/content/gfx/text-no-winner.png
Binary files differ
diff --git a/QtDemo/qml/QtDemo/demos/samegame/content/gfx/text-p1-go.png b/QtDemo/qml/QtDemo/demos/samegame/content/gfx/text-p1-go.png
new file mode 100644
index 0000000..c7bd2a5
--- /dev/null
+++ b/QtDemo/qml/QtDemo/demos/samegame/content/gfx/text-p1-go.png
Binary files differ
diff --git a/QtDemo/qml/QtDemo/demos/samegame/content/gfx/text-p1-won.png b/QtDemo/qml/QtDemo/demos/samegame/content/gfx/text-p1-won.png
new file mode 100644
index 0000000..41c2eb7
--- /dev/null
+++ b/QtDemo/qml/QtDemo/demos/samegame/content/gfx/text-p1-won.png
Binary files differ
diff --git a/QtDemo/qml/QtDemo/demos/samegame/content/gfx/text-p1.png b/QtDemo/qml/QtDemo/demos/samegame/content/gfx/text-p1.png
new file mode 100644
index 0000000..b59c87b
--- /dev/null
+++ b/QtDemo/qml/QtDemo/demos/samegame/content/gfx/text-p1.png
Binary files differ
diff --git a/QtDemo/qml/QtDemo/demos/samegame/content/gfx/text-p2-go.png b/QtDemo/qml/QtDemo/demos/samegame/content/gfx/text-p2-go.png
new file mode 100644
index 0000000..f03cd93
--- /dev/null
+++ b/QtDemo/qml/QtDemo/demos/samegame/content/gfx/text-p2-go.png
Binary files differ
diff --git a/QtDemo/qml/QtDemo/demos/samegame/content/gfx/text-p2-won.png b/QtDemo/qml/QtDemo/demos/samegame/content/gfx/text-p2-won.png
new file mode 100644
index 0000000..116b7f2
--- /dev/null
+++ b/QtDemo/qml/QtDemo/demos/samegame/content/gfx/text-p2-won.png
Binary files differ
diff --git a/QtDemo/qml/QtDemo/demos/samegame/content/gfx/text-p2.png b/QtDemo/qml/QtDemo/demos/samegame/content/gfx/text-p2.png
new file mode 100644
index 0000000..d4f2bc7
--- /dev/null
+++ b/QtDemo/qml/QtDemo/demos/samegame/content/gfx/text-p2.png
Binary files differ
diff --git a/QtDemo/qml/QtDemo/demos/samegame/content/gfx/yellow-puzzle.png b/QtDemo/qml/QtDemo/demos/samegame/content/gfx/yellow-puzzle.png
new file mode 100644
index 0000000..66044c8
--- /dev/null
+++ b/QtDemo/qml/QtDemo/demos/samegame/content/gfx/yellow-puzzle.png
Binary files differ
diff --git a/QtDemo/qml/QtDemo/demos/samegame/content/gfx/yellow.png b/QtDemo/qml/QtDemo/demos/samegame/content/gfx/yellow.png
new file mode 100644
index 0000000..6bc5d38
--- /dev/null
+++ b/QtDemo/qml/QtDemo/demos/samegame/content/gfx/yellow.png
Binary files differ
diff --git a/QtDemo/qml/QtDemo/demos/samegame/content/levels/TemplateBase.qml b/QtDemo/qml/QtDemo/demos/samegame/content/levels/TemplateBase.qml
new file mode 100644
index 0000000..48ea399
--- /dev/null
+++ b/QtDemo/qml/QtDemo/demos/samegame/content/levels/TemplateBase.qml
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle{
+ id: control
+ property int scoreTarget: -1
+ property int timeTarget: -1
+ property int moveTarget: -1
+ property bool mustClear: true
+ property string goalText: "Clear the level..."
+
+ property var startingGrid //If this isn't an array of ints, we will refuse to load the level.
+ /* Ints are 0-4. If not enough ints are there it will be prepadded with 0s to fill the grid
+ (which ruins everything if you have the wrong number of rows).
+ 0 - No block
+ 1 - Red
+ 2 - Blue
+ 3 - Green
+ 4 - Yellow
+ Ideas for future colors, but not supported in this version:
+ 5 - Purple
+ 6 - Cyan
+ 7 - Gray
+ 8 - Black
+ 9 - White
+ */
+
+ width: 320
+ height: 416
+ color: "white" //TODO: Theme support for both setting themes per level, and seeing it in the control!
+}
diff --git a/QtDemo/qml/QtDemo/demos/samegame/content/levels/level0.qml b/QtDemo/qml/QtDemo/demos/samegame/content/levels/level0.qml
new file mode 100644
index 0000000..7ac7ed8
--- /dev/null
+++ b/QtDemo/qml/QtDemo/demos/samegame/content/levels/level0.qml
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+TemplateBase{
+ moveTarget: 3
+ goalText: "1 of 10<br><br>Clear in three moves..."
+ startingGrid: [ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 , 1 , 1 ,
+ 0 , 0 , 0 , 0 , 0 , 1 , 1 , 2 , 1 , 1 ,
+ 0 , 0 , 0 , 1 , 1 , 3 , 3 , 3 , 3 , 3 ,
+ 0 , 1 , 1 , 3 , 3 , 3 , 1 , 3 , 1 , 1 ,
+ 1 , 2 , 3 , 3 , 1 , 1 , 3 , 3 , 3 , 3 ,
+ 1 , 3 , 3 , 2 , 3 , 3 , 3 , 3 , 1 , 1 ,
+ 1 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 ]
+}
diff --git a/QtDemo/qml/QtDemo/demos/samegame/content/levels/level1.qml b/QtDemo/qml/QtDemo/demos/samegame/content/levels/level1.qml
new file mode 100644
index 0000000..0b7a889
--- /dev/null
+++ b/QtDemo/qml/QtDemo/demos/samegame/content/levels/level1.qml
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+TemplateBase{
+ timeTarget: 10
+ goalText: "2 of 10<br><br>Clear in 10 seconds..."
+ startingGrid: [ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
+ 1 , 3 , 3 , 3 , 1 , 1 , 1 , 1 , 2 , 2 ,
+ 1 , 2 , 3 , 3 , 3 , 1 , 1 , 1 , 1 , 2 ,
+ 2 , 2 , 1 , 3 , 3 , 3 , 1 , 1 , 1 , 2 ,
+ 2 , 1 , 1 , 1 , 3 , 3 , 3 , 1 , 2 , 2 ,
+ 1 , 1 , 1 , 1 , 1 , 3 , 3 , 3 , 2 , 1 ]
+}
diff --git a/QtDemo/qml/QtDemo/demos/samegame/content/levels/level2.qml b/QtDemo/qml/QtDemo/demos/samegame/content/levels/level2.qml
new file mode 100644
index 0000000..986f217
--- /dev/null
+++ b/QtDemo/qml/QtDemo/demos/samegame/content/levels/level2.qml
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+TemplateBase{
+ scoreTarget: 1200
+ timeTarget: 60
+ goalText: "3 of 10<br><br>Score over 1200 points in one minute..."
+ mustClear: false
+ startingGrid: [ 3 , 1 , 2 , 1 , 1 , 2 , 1 , 1 , 3 , 3 ,
+ 1 , 3 , 3 , 2 , 3 , 3 , 1 , 1 , 3 , 1 ,
+ 3 , 1 , 3 , 3 , 2 , 3 , 3 , 3 , 1 , 2 ,
+ 3 , 2 , 2 , 1 , 3 , 3 , 2 , 1 , 1 , 2 ,
+ 3 , 1 , 2 , 2 , 2 , 2 , 2 , 1 , 3 , 1 ,
+ 2 , 3 , 1 , 2 , 2 , 3 , 3 , 1 , 3 , 2 ,
+ 3 , 2 , 1 , 1 , 3 , 3 , 3 , 2 , 2 , 1 ,
+ 1 , 2 , 2 , 3 , 2 , 3 , 3 , 3 , 1 , 1 ,
+ 1 , 3 , 3 , 3 , 1 , 2 , 2 , 3 , 3 , 1 ,
+ 3 , 3 , 2 , 1 , 2 , 2 , 1 , 1 , 1 , 3 ,
+ 2 , 1 , 3 , 2 , 3 , 2 , 3 , 2 , 2 , 1 ,
+ 1 , 3 , 1 , 2 , 1 , 2 , 3 , 1 , 2 , 2 ,
+ 1 , 2 , 2 , 2 , 1 , 1 , 2 , 3 , 1 , 2 ]
+}
diff --git a/QtDemo/qml/QtDemo/demos/samegame/content/levels/level3.qml b/QtDemo/qml/QtDemo/demos/samegame/content/levels/level3.qml
new file mode 100644
index 0000000..eff5182
--- /dev/null
+++ b/QtDemo/qml/QtDemo/demos/samegame/content/levels/level3.qml
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+TemplateBase{
+ scoreTarget: 3000
+ timeTarget: 60
+ goalText: "4 of 10<br>Clear the board with over 3000 points in under a minute..."
+ startingGrid: [ 3 , 3 , 1 , 1 , 1 , 2 , 2 , 4 , 3 , 3 ,
+ 4 , 3 , 1 , 4 , 2 , 2 , 2 , 4 , 3 , 4 ,
+ 4 , 3 , 3 , 4 , 1 , 1 , 3 , 3 , 4 , 4 ,
+ 3 , 3 , 3 , 3 , 3 , 1 , 3 , 2 , 2 , 4 ,
+ 4 , 4 , 3 , 4 , 3 , 1 , 4 , 4 , 4 , 4 ,
+ 4 , 4 , 3 , 4 , 1 , 1 , 4 , 4 , 3 , 3 ,
+ 4 , 2 , 2 , 2 , 2 , 2 , 4 , 4 , 4 , 1 ,
+ 4 , 4 , 2 , 4 , 2 , 2 , 1 , 1 , 1 , 1 ,
+ 4 , 4 , 2 , 4 , 2 , 2 , 1 , 4 , 4 , 1 ,
+ 4 , 1 , 1 , 4 , 3 , 3 , 4 , 2 , 4 , 1 ,
+ 4 , 1 , 1 , 2 , 3 , 3 , 4 , 2 , 2 , 1 ,
+ 1 , 1 , 2 , 2 , 2 , 3 , 3 , 3 , 2 , 1 ,
+ 4 , 1 , 1 , 2 , 2 , 3 , 4 , 3 , 4 , 4 ]
+}
diff --git a/QtDemo/qml/QtDemo/demos/samegame/content/levels/level4.qml b/QtDemo/qml/QtDemo/demos/samegame/content/levels/level4.qml
new file mode 100644
index 0000000..4438de1
--- /dev/null
+++ b/QtDemo/qml/QtDemo/demos/samegame/content/levels/level4.qml
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+TemplateBase{
+ goalText: "5 of 10<br><br>Clear the level..."
+ startingGrid: [ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
+ 1 , 3 , 2 , 1 , 1 , 1 , 1 , 3 , 2 , 3 ,
+ 1 , 2 , 3 , 1 , 3 , 2 , 2 , 1 , 1 , 2 ,
+ 3 , 2 , 2 , 2 , 1 , 1 , 1 , 1 , 3 , 3 ,
+ 2 , 1 , 1 , 3 , 2 , 1 , 1 , 2 , 1 , 3 ,
+ 1 , 3 , 3 , 1 , 2 , 1 , 2 , 1 , 3 , 3 ,
+ 1 , 3 , 2 , 2 , 2 , 1 , 1 , 3 , 2 , 3 ,
+ 1 , 1 , 3 , 2 , 3 , 3 , 2 , 1 , 1 , 1 ,
+ 1 , 2 , 2 , 3 , 2 , 2 , 1 , 3 , 1 , 3 ]
+}
diff --git a/QtDemo/qml/QtDemo/demos/samegame/content/levels/level5.qml b/QtDemo/qml/QtDemo/demos/samegame/content/levels/level5.qml
new file mode 100644
index 0000000..ee48217
--- /dev/null
+++ b/QtDemo/qml/QtDemo/demos/samegame/content/levels/level5.qml
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+TemplateBase{
+ moveTarget: 4
+ goalText: "6 of 10<br><br>Clear in four or less moves..."
+ startingGrid: [ 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 ,
+ 4 , 2 , 2 , 2 , 4 , 3 , 3 , 3 , 4 , 4 ,
+ 4 , 2 , 4 , 4 , 4 , 3 , 2 , 3 , 4 , 4 ,
+ 4 , 2 , 2 , 2 , 4 , 3 , 3 , 3 , 4 , 4 ,
+ 4 , 4 , 4 , 2 , 4 , 3 , 4 , 3 , 4 , 4 ,
+ 4 , 2 , 2 , 2 , 4 , 3 , 4 , 3 , 4 , 4 ,
+ 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 ,
+ 4 , 3 , 4 , 3 , 4 , 2 , 2 , 2 , 4 , 3 ,
+ 4 , 3 , 3 , 3 , 4 , 2 , 4 , 4 , 4 , 3 ,
+ 4 , 3 , 3 , 3 , 4 , 2 , 2 , 2 , 4 , 3 ,
+ 4 , 3 , 4 , 3 , 4 , 2 , 4 , 4 , 4 , 4 ,
+ 4 , 3 , 4 , 3 , 4 , 2 , 2 , 2 , 4 , 3 ,
+ 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 ]
+}
diff --git a/QtDemo/qml/QtDemo/demos/samegame/content/levels/level6.qml b/QtDemo/qml/QtDemo/demos/samegame/content/levels/level6.qml
new file mode 100644
index 0000000..2b34baa
--- /dev/null
+++ b/QtDemo/qml/QtDemo/demos/samegame/content/levels/level6.qml
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+TemplateBase{
+ moveTarget: 20
+ timeTarget: 40
+ goalText: "7 of 10<br><br>Clear with 20 moves in 40 seconds (or better)."
+ startingGrid: [ 1 , 3 , 1 , 1 , 1 , 1 , 2 , 1 , 2 , 2 ,
+ 2 , 1 , 2 , 3 , 3 , 1 , 3 , 1 , 1 , 3 ,
+ 3 , 1 , 1 , 1 , 2 , 2 , 3 , 2 , 3 , 1 ,
+ 1 , 3 , 1 , 1 , 3 , 1 , 1 , 1 , 2 , 3 ,
+ 2 , 1 , 1 , 1 , 3 , 2 , 3 , 3 , 2 , 3 ,
+ 3 , 3 , 3 , 3 , 2 , 2 , 3 , 1 , 3 , 2 ,
+ 2 , 2 , 3 , 2 , 2 , 3 , 2 , 2 , 2 , 2 ,
+ 1 , 2 , 1 , 2 , 1 , 3 , 2 , 3 , 2 , 3 ,
+ 1 , 1 , 2 , 3 , 3 , 3 , 3 , 1 , 1 , 2 ,
+ 3 , 3 , 2 , 2 , 2 , 2 , 3 , 1 , 3 , 1 ,
+ 1 , 2 , 3 , 3 , 3 , 1 , 3 , 2 , 1 , 2 ,
+ 1 , 2 , 1 , 1 , 2 , 3 , 1 , 2 , 1 , 3 ,
+ 3 , 1 , 2 , 2 , 1 , 3 , 3 , 1 , 3 , 2 ]
+}
diff --git a/QtDemo/qml/QtDemo/demos/samegame/content/levels/level7.qml b/QtDemo/qml/QtDemo/demos/samegame/content/levels/level7.qml
new file mode 100644
index 0000000..280bbb1
--- /dev/null
+++ b/QtDemo/qml/QtDemo/demos/samegame/content/levels/level7.qml
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+TemplateBase{
+ goalText: "8 of 10<br><br>Clear the grid."
+ startingGrid: [ 2 , 4 , 3 , 2 , 3 , 2 , 3 , 3 , 4 , 3 ,
+ 2 , 2 , 3 , 3 , 1 , 4 , 3 , 3 , 3 , 2 ,
+ 1 , 4 , 2 , 3 , 4 , 3 , 3 , 1 , 1 , 1 ,
+ 2 , 1 , 2 , 4 , 4 , 2 , 2 , 3 , 2 , 1 ,
+ 3 , 4 , 4 , 1 , 3 , 2 , 4 , 2 , 1 , 1 ,
+ 2 , 2 , 3 , 1 , 2 , 4 , 1 , 2 , 1 , 2 ,
+ 1 , 2 , 3 , 2 , 4 , 4 , 3 , 1 , 1 , 2 ,
+ 4 , 4 , 2 , 1 , 2 , 4 , 2 , 2 , 4 , 3 ,
+ 4 , 2 , 4 , 1 , 3 , 4 , 1 , 4 , 2 , 4 ,
+ 4 , 3 , 4 , 1 , 4 , 3 , 1 , 3 , 1 , 1 ,
+ 3 , 3 , 2 , 3 , 2 , 4 , 1 , 2 , 4 , 4 ,
+ 3 , 4 , 2 , 2 , 4 , 3 , 4 , 1 , 3 , 2 ,
+ 4 , 3 , 3 , 4 , 2 , 4 , 1 , 2 , 3 , 2 ]
+}
diff --git a/QtDemo/qml/QtDemo/demos/samegame/content/levels/level8.qml b/QtDemo/qml/QtDemo/demos/samegame/content/levels/level8.qml
new file mode 100644
index 0000000..7661485
--- /dev/null
+++ b/QtDemo/qml/QtDemo/demos/samegame/content/levels/level8.qml
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+TemplateBase{
+ scoreTarget: 1000
+ goalText: "9 of 10<br><br>Score over 1000 points"
+ startingGrid: [ 1 , 4 , 4 , 3 , 2 , 1 , 4 , 2 , 4 , 2 ,
+ 2 , 3 , 4 , 4 , 1 , 1 , 1 , 4 , 4 , 4 ,
+ 1 , 3 , 1 , 2 , 2 , 1 , 2 , 1 , 4 , 2 ,
+ 4 , 3 , 4 , 2 , 1 , 4 , 1 , 2 , 2 , 3 ,
+ 3 , 4 , 2 , 4 , 4 , 3 , 2 , 2 , 2 , 1 ,
+ 4 , 4 , 3 , 2 , 4 , 4 , 2 , 1 , 1 , 1 ,
+ 1 , 2 , 1 , 3 , 4 , 1 , 1 , 3 , 2 , 3 ,
+ 3 , 4 , 2 , 2 , 1 , 3 , 2 , 2 , 4 , 2 ,
+ 2 , 4 , 1 , 2 , 2 , 4 , 3 , 3 , 3 , 1 ,
+ 1 , 2 , 2 , 4 , 1 , 2 , 2 , 3 , 3 , 3 ,
+ 4 , 4 , 1 , 4 , 3 , 1 , 3 , 3 , 3 , 4 ,
+ 1 , 2 , 4 , 1 , 2 , 1 , 1 , 4 , 2 , 1 ,
+ 1 , 2 , 3 , 4 , 2 , 4 , 4 , 2 , 1 , 3 ]
+}
diff --git a/QtDemo/qml/QtDemo/demos/samegame/content/levels/level9.qml b/QtDemo/qml/QtDemo/demos/samegame/content/levels/level9.qml
new file mode 100644
index 0000000..c75d8e5
--- /dev/null
+++ b/QtDemo/qml/QtDemo/demos/samegame/content/levels/level9.qml
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+TemplateBase{
+ scoreTarget: 2000
+ timeTarget: 60
+ moveTarget: 20
+ mustClear: false
+ goalText: "10 of 10<br><br>Score 2000 in one minute with less than 20 moves!"
+ startingGrid: [ 3 , 2 , 3 , 1 , 3 , 3 , 4 , 1 , 3 , 3 ,
+ 2 , 3 , 2 , 1 , 1 , 2 , 2 , 2 , 4 , 1 ,
+ 2 , 4 , 4 , 4 , 3 , 1 , 4 , 4 , 4 , 1 ,
+ 3 , 1 , 3 , 4 , 4 , 2 , 2 , 2 , 2 , 3 ,
+ 2 , 1 , 4 , 4 , 3 , 3 , 1 , 1 , 3 , 2 ,
+ 3 , 2 , 1 , 4 , 3 , 4 , 1 , 3 , 4 , 2 ,
+ 3 , 3 , 1 , 4 , 4 , 4 , 2 , 1 , 2 , 3 ,
+ 2 , 3 , 4 , 3 , 4 , 1 , 1 , 3 , 2 , 4 ,
+ 4 , 4 , 1 , 2 , 4 , 3 , 2 , 2 , 2 , 4 ,
+ 1 , 4 , 2 , 2 , 1 , 1 , 2 , 1 , 1 , 4 ,
+ 1 , 4 , 3 , 3 , 3 , 1 , 3 , 4 , 4 , 2 ,
+ 3 , 4 , 1 , 1 , 2 , 2 , 2 , 3 , 2 , 1 ,
+ 3 , 3 , 4 , 3 , 1 , 1 , 1 , 4 , 4 , 3 ]
+}
diff --git a/QtDemo/qml/QtDemo/demos/samegame/content/samegame.js b/QtDemo/qml/QtDemo/demos/samegame/content/samegame.js
new file mode 100644
index 0000000..96b8167
--- /dev/null
+++ b/QtDemo/qml/QtDemo/demos/samegame/content/samegame.js
@@ -0,0 +1,581 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/* This script file handles the game logic */
+.pragma library
+.import QtQuick.LocalStorage 2.0 as Sql
+.import "../settings.js" as Settings
+
+var maxColumn = 10;
+var maxRow = 13;
+var types = 3;
+var maxIndex = maxColumn*maxRow;
+var board = new Array(maxIndex);
+var blockSrc = "Block.qml";
+var gameDuration;
+var component = Qt.createComponent(blockSrc);
+var gameCanvas;
+var betweenTurns = false;
+
+var puzzleLevel = null;
+var puzzlePath = "";
+
+var gameMode = "arcade"; //Set in new game, then tweaks behavior of other functions
+var gameOver = false;
+
+function changeBlock(src)
+{
+ blockSrc = src;
+ component = Qt.createComponent(blockSrc);
+}
+
+// Index function used instead of a 2D array
+function index(column, row)
+{
+ return column + row * maxColumn;
+}
+
+function timeStr(msecs)
+{
+ var secs = Math.floor(msecs/1000);
+ var m = Math.floor(secs/60);
+ var ret = "" + m + "m " + (secs%60) + "s";
+ return ret;
+}
+
+function cleanUp()
+{
+ if (gameCanvas == undefined)
+ return;
+ // Delete blocks from previous game
+ for (var i = 0; i < maxIndex; i++) {
+ if (board[i] != null)
+ board[i].destroy();
+ board[i] = null;
+ }
+ if (puzzleLevel != null){
+ puzzleLevel.destroy();
+ puzzleLevel = null;
+ }
+ gameCanvas.mode = ""
+}
+
+function startNewGame(gc, mode, map)
+{
+ gameCanvas = gc;
+ if (mode == undefined)
+ gameMode = "arcade";
+ else
+ gameMode = mode;
+ gameOver = false;
+
+ cleanUp();
+
+ gc.gameOver = false;
+ gc.mode = gameMode;
+ // Calculate board size
+ maxColumn = Math.floor(gameCanvas.width/Settings.blockSize);
+ maxRow = Math.floor(gameCanvas.height/Settings.blockSize);
+ maxIndex = maxRow * maxColumn;
+ if (gameMode == "arcade") //Needs to be after board sizing
+ getHighScore();
+
+
+ // Initialize Board
+ board = new Array(maxIndex);
+ gameCanvas.score = 0;
+ gameCanvas.score2 = 0;
+ gameCanvas.moves = 0;
+ gameCanvas.curTurn = 1;
+ if (gameMode == "puzzle")
+ loadMap(map);
+ else//Note that we load them in reverse order for correct visual stacking
+ for (var column = maxColumn - 1; column >= 0; column--)
+ for (var row = maxRow - 1; row >= 0; row--)
+ createBlock(column, row);
+ if (gameMode == "puzzle")
+ getLevelHistory();//Needs to be after map load
+ gameDuration = new Date();
+}
+
+var fillFound; // Set after a floodFill call to the number of blocks found
+var floodBoard; // Set to 1 if the floodFill reaches off that node
+
+// NOTE: Be careful with vars named x,y, as the calling object's x,y are still in scope
+function handleClick(x,y)
+{
+ if (betweenTurns || gameOver || gameCanvas == undefined)
+ return;
+ var column = Math.floor(x/Settings.blockSize);
+ var row = Math.floor(y/Settings.blockSize);
+ if (column >= maxColumn || column < 0 || row >= maxRow || row < 0)
+ return;
+ if (board[index(column, row)] == null)
+ return;
+ // If it's a valid block, remove it and all connected (does nothing if it's not connected)
+ floodFill(column,row, -1);
+ if (fillFound <= 0)
+ return;
+ if (gameMode == "multiplayer" && gameCanvas.curTurn == 2)
+ gameCanvas.score2 += (fillFound - 1) * (fillFound - 1);
+ else
+ gameCanvas.score += (fillFound - 1) * (fillFound - 1);
+ if (gameMode == "multiplayer" && gameCanvas.curTurn == 2)
+ shuffleUp();
+ else
+ shuffleDown();
+ gameCanvas.moves += 1;
+ if (gameMode == "endless")
+ refill();
+ else if (gameMode != "multiplayer")
+ victoryCheck();
+ if (gameMode == "multiplayer" && !gc.gameOver){
+ betweenTurns = true;
+ gameCanvas.swapPlayers();//signal, animate and call turnChange() when ready
+ }
+}
+
+function floodFill(column,row,type)
+{
+ if (board[index(column, row)] == null)
+ return;
+ var first = false;
+ if (type == -1) {
+ first = true;
+ type = board[index(column,row)].type;
+
+ // Flood fill initialization
+ fillFound = 0;
+ floodBoard = new Array(maxIndex);
+ }
+ if (column >= maxColumn || column < 0 || row >= maxRow || row < 0)
+ return;
+ if (floodBoard[index(column, row)] == 1 || (!first && type != board[index(column, row)].type))
+ return;
+ floodBoard[index(column, row)] = 1;
+ floodFill(column + 1, row, type);
+ floodFill(column - 1, row, type);
+ floodFill(column, row + 1, type);
+ floodFill(column, row - 1, type);
+ if (first == true && fillFound == 0)
+ return; // Can't remove single blocks
+ board[index(column, row)].dying = true;
+ board[index(column, row)] = null;
+ fillFound += 1;
+}
+
+function shuffleDown()
+{
+ // Fall down
+ for (var column = 0; column < maxColumn; column++) {
+ var fallDist = 0;
+ for (var row = maxRow - 1; row >= 0; row--) {
+ if (board[index(column,row)] == null) {
+ fallDist += 1;
+ } else {
+ if (fallDist > 0) {
+ var obj = board[index(column, row)];
+ obj.y = (row + fallDist) * Settings.blockSize;
+ board[index(column, row + fallDist)] = obj;
+ board[index(column, row)] = null;
+ }
+ }
+ }
+ }
+ // Fall to the left
+ fallDist = 0;
+ for (column = 0; column < maxColumn; column++) {
+ if (board[index(column, maxRow - 1)] == null) {
+ fallDist += 1;
+ } else {
+ if (fallDist > 0) {
+ for (row = 0; row < maxRow; row++) {
+ obj = board[index(column, row)];
+ if (obj == null)
+ continue;
+ obj.x = (column - fallDist) * Settings.blockSize;
+ board[index(column - fallDist,row)] = obj;
+ board[index(column, row)] = null;
+ }
+ }
+ }
+ }
+}
+
+
+function shuffleUp()
+{
+ // Fall up
+ for (var column = 0; column < maxColumn; column++) {
+ var fallDist = 0;
+ for (var row = 0; row < maxRow; row++) {
+ if (board[index(column,row)] == null) {
+ fallDist += 1;
+ } else {
+ if (fallDist > 0) {
+ var obj = board[index(column, row)];
+ obj.y = (row - fallDist) * Settings.blockSize;
+ board[index(column, row - fallDist)] = obj;
+ board[index(column, row)] = null;
+ }
+ }
+ }
+ }
+ // Fall to the left (or should it be right, so as to be left for P2?)
+ fallDist = 0;
+ for (column = 0; column < maxColumn; column++) {
+ if (board[index(column, 0)] == null) {
+ fallDist += 1;
+ } else {
+ if (fallDist > 0) {
+ for (row = 0; row < maxRow; row++) {
+ obj = board[index(column, row)];
+ if (obj == null)
+ continue;
+ obj.x = (column - fallDist) * Settings.blockSize;
+ board[index(column - fallDist,row)] = obj;
+ board[index(column, row)] = null;
+ }
+ }
+ }
+ }
+}
+
+function turnChange()//called by ui outside
+{
+ betweenTurns = false;
+ if (gameCanvas.curTurn == 1){
+ shuffleUp();
+ gameCanvas.curTurn = 2;
+ victoryCheck();
+ }else{
+ shuffleDown();
+ gameCanvas.curTurn = 1;
+ victoryCheck();
+ }
+}
+
+function refill()
+{
+ for (var column = 0; column < maxColumn; column++) {
+ for (var row = 0; row < maxRow; row++) {
+ if (board[index(column, row)] == null)
+ createBlock(column, row);
+ }
+ }
+}
+
+function victoryCheck()
+{
+ // Awards bonuses for no blocks left
+ var deservesBonus = true;
+ if (board[index(0,maxRow - 1)] != null || board[index(0,0)] != null)
+ deservesBonus = false;
+ // Checks for game over
+ if (deservesBonus){
+ if (gameCanvas.curTurn = 1)
+ gameCanvas.score += 1000;
+ else
+ gameCanvas.score2 += 1000;
+ }
+ gameOver = deservesBonus;
+ if (gameCanvas.curTurn == 1){
+ if (!(floodMoveCheck(0, maxRow - 1, -1)))
+ gameOver = true;
+ }else{
+ if (!(floodMoveCheck(0, 0, -1, true)))
+ gameOver = true;
+ }
+ if (gameMode == "puzzle"){
+ puzzleVictoryCheck(deservesBonus);//Takes it from here
+ return;
+ }
+ if (gameOver) {
+ var winnerScore = Math.max(gameCanvas.score, gameCanvas.score2);
+ if (gameMode == "multiplayer"){
+ gameCanvas.score = winnerScore;
+ saveHighScore(gameCanvas.score2);
+ }
+ saveHighScore(gameCanvas.score);
+ gameDuration = new Date() - gameDuration;
+ gameCanvas.gameOver = true;
+ }
+}
+
+// Only floods up and right, to see if it can find adjacent same-typed blocks
+function floodMoveCheck(column, row, type, goDownInstead)
+{
+ if (column >= maxColumn || column < 0 || row >= maxRow || row < 0)
+ return false;
+ if (board[index(column, row)] == null)
+ return false;
+ var myType = board[index(column, row)].type;
+ if (type == myType)
+ return true;
+ if (goDownInstead)
+ return floodMoveCheck(column + 1, row, myType, goDownInstead) ||
+ floodMoveCheck(column, row + 1, myType, goDownInstead);
+ else
+ return floodMoveCheck(column + 1, row, myType) ||
+ floodMoveCheck(column, row - 1, myType);
+}
+
+function createBlock(column,row,type)
+{
+ // Note that we don't wait for the component to become ready. This will
+ // only work if the block QML is a local file. Otherwise the component will
+ // not be ready immediately. There is a statusChanged signal on the
+ // component you could use if you want to wait to load remote files.
+ if (component.status == 1){
+ if (type == undefined)
+ type = Math.floor(Math.random() * types);
+ if (type < 0 || type > 4) {
+ console.log("Invalid type requested");//TODO: Is this triggered by custom levels much?
+ return;
+ }
+ var dynamicObject = component.createObject(gameCanvas,
+ {"type": type,
+ "x": column*Settings.blockSize,
+ "y": -1*Settings.blockSize,
+ "width": Settings.blockSize,
+ "height": Settings.blockSize,
+ "particleSystem": gameCanvas.ps});
+ if (dynamicObject == null){
+ console.log("error creating block");
+ console.log(component.errorString());
+ return false;
+ }
+ dynamicObject.y = row*Settings.blockSize;
+ dynamicObject.spawned = true;
+
+ board[index(column,row)] = dynamicObject;
+ }else{
+ console.log("error loading block component");
+ console.log(component.errorString());
+ return false;
+ }
+ return true;
+}
+
+function showPuzzleError(str)
+{
+ //TODO: Nice user visible UI?
+ console.log(str);
+}
+
+function loadMap(map)
+{
+ puzzlePath = map;
+ var levelComp = Qt.createComponent(puzzlePath);
+ if (levelComp.status != 1){
+ console.log("Error loading level");
+ showPuzzleError(levelComp.errorString());
+ return;
+ }
+ puzzleLevel = levelComp.createObject();
+ if (puzzleLevel == null || !puzzleLevel.startingGrid instanceof Array) {
+ showPuzzleError("Bugger!");
+ return;
+ }
+ gameCanvas.showPuzzleGoal(puzzleLevel.goalText);
+ //showPuzzleGoal should call finishLoadingMap as the next thing it does, before handling more events
+}
+
+function finishLoadingMap()
+{
+ for (var i in puzzleLevel.startingGrid)
+ if (! (puzzleLevel.startingGrid[i] >= 0 && puzzleLevel.startingGrid[i] <= 9) )
+ puzzleLevel.startingGrid[i] = 0;
+ //TODO: Don't allow loading larger levels, leads to cheating
+ while (puzzleLevel.startingGrid.length > maxIndex) puzzleLevel.startingGrid.shift();
+ while (puzzleLevel.startingGrid.length < maxIndex) puzzleLevel.startingGrid.unshift(0);
+ for (var i in puzzleLevel.startingGrid)
+ if (puzzleLevel.startingGrid[i] > 0)
+ createBlock(i % maxColumn, Math.floor(i / maxColumn), puzzleLevel.startingGrid[i] - 1);
+
+ //### Experimental feature - allow levels to contain arbitrary QML scenes as well!
+ //while (puzzleLevel.children.length)
+ // puzzleLevel.children[0].parent = gameCanvas;
+ gameDuration = new Date(); //Don't start until we finish loading
+}
+
+function puzzleVictoryCheck(clearedAll)//gameOver has also been set if no more moves
+{
+ var won = true;
+ var soFar = new Date() - gameDuration;
+ if (puzzleLevel.scoreTarget != -1 && gameCanvas.score < puzzleLevel.scoreTarget){
+ won = false;
+ } if (puzzleLevel.scoreTarget != -1 && gameCanvas.score >= puzzleLevel.scoreTarget && !puzzleLevel.mustClear){
+ gameOver = true;
+ } if (puzzleLevel.timeTarget != -1 && soFar/1000.0 > puzzleLevel.timeTarget){
+ gameOver = true;
+ } if (puzzleLevel.moveTarget != -1 && gameCanvas.moves >= puzzleLevel.moveTarget){
+ gameOver = true;
+ } if (puzzleLevel.mustClear && gameOver && !clearedAll) {
+ won = false;
+ }
+
+ if (gameOver) {
+ gameCanvas.gameOver = true;
+ gameCanvas.showPuzzleEnd(won);
+
+ if (won) {
+ // Store progress
+ saveLevelHistory();
+ }
+ }
+}
+
+function getHighScore()
+{
+ var db = Sql.LocalStorage.openDatabaseSync(
+ "SameGame",
+ "2.0",
+ "SameGame Local Data",
+ 100
+ );
+ db.transaction(
+ function(tx) {
+ tx.executeSql('CREATE TABLE IF NOT EXISTS Scores(game TEXT, score NUMBER, gridSize TEXT, time NUMBER)');
+ // Only show results for the current grid size
+ var rs = tx.executeSql('SELECT * FROM Scores WHERE gridSize = "'
+ + maxColumn + "x" + maxRow + '" AND game = "' + gameMode + '" ORDER BY score desc');
+ if (rs.rows.length > 0)
+ gameCanvas.highScore = rs.rows.item(0).score;
+ else
+ gameCanvas.highScore = 0;
+ }
+ );
+}
+
+function saveHighScore(score)
+{
+ // Offline storage
+ var db = Sql.LocalStorage.openDatabaseSync(
+ "SameGame",
+ "2.0",
+ "SameGame Local Data",
+ 100
+ );
+ var dataStr = "INSERT INTO Scores VALUES(?, ?, ?, ?)";
+ var data = [
+ gameMode,
+ score,
+ maxColumn + "x" + maxRow,
+ Math.floor(gameDuration / 1000)
+ ];
+ if (score >= gameCanvas.highScore)//Update UI field
+ gameCanvas.highScore = score;
+
+ db.transaction(
+ function(tx) {
+ tx.executeSql('CREATE TABLE IF NOT EXISTS Scores(game TEXT, score NUMBER, gridSize TEXT, time NUMBER)');
+ tx.executeSql(dataStr, data);
+ }
+ );
+}
+
+function getLevelHistory()
+{
+ var db = Sql.LocalStorage.openDatabaseSync(
+ "SameGame",
+ "2.0",
+ "SameGame Local Data",
+ 100
+ );
+ db.transaction(
+ function(tx) {
+ tx.executeSql('CREATE TABLE IF NOT EXISTS Puzzle(level TEXT, score NUMBER, moves NUMBER, time NUMBER)');
+ var rs = tx.executeSql('SELECT * FROM Puzzle WHERE level = "' + puzzlePath + '" ORDER BY score desc');
+ if (rs.rows.length > 0) {
+ gameCanvas.puzzleWon = true;
+ gameCanvas.highScore = rs.rows.item(0).score;
+ } else {
+ gameCanvas.puzzleWon = false;
+ gameCanvas.highScore = 0;
+ }
+ }
+ );
+}
+
+function saveLevelHistory()
+{
+ var db = Sql.LocalStorage.openDatabaseSync(
+ "SameGame",
+ "2.0",
+ "SameGame Local Data",
+ 100
+ );
+ var dataStr = "INSERT INTO Puzzle VALUES(?, ?, ?, ?)";
+ var data = [
+ puzzlePath,
+ gameCanvas.score,
+ gameCanvas.moves,
+ Math.floor(gameDuration / 1000)
+ ];
+ gameCanvas.puzzleWon = true;
+
+ db.transaction(
+ function(tx) {
+ tx.executeSql('CREATE TABLE IF NOT EXISTS Puzzle(level TEXT, score NUMBER, moves NUMBER, time NUMBER)');
+ tx.executeSql(dataStr, data);
+ }
+ );
+}
+
+function nuke() //For "Debug mode"
+{
+ for (var row = 1; row <= 5; row++) {
+ for (var col = 0; col < 5; col++) {
+ if (board[index(col, maxRow - row)] != null) {
+ board[index(col, maxRow - row)].dying = true;
+ board[index(col, maxRow - row)] = null;
+ }
+ }
+ }
+ if (gameMode == "multiplayer" && gameCanvas.curTurn == 2)
+ shuffleUp();
+ else
+ shuffleDown();
+ if (gameMode == "endless")
+ refill();
+ else
+ victoryCheck();
+}
diff --git a/QtDemo/qml/QtDemo/demos/samegame/samegame.qml b/QtDemo/qml/QtDemo/demos/samegame/samegame.qml
new file mode 100644
index 0000000..8712141
--- /dev/null
+++ b/QtDemo/qml/QtDemo/demos/samegame/samegame.qml
@@ -0,0 +1,371 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+import "content/samegame.js" as Logic
+import "settings.js" as Settings
+import "content"
+
+Rectangle {
+ id: root
+ width: 320; height: 480
+ property int acc: 0
+
+
+ function loadPuzzle() {
+ if (gameCanvas.mode != "")
+ Logic.cleanUp();
+ Logic.startNewGame(gameCanvas,"puzzle","levels/level"+acc+".qml")
+ }
+ function nextPuzzle() {
+ acc = (acc + 1) % 10;
+ loadPuzzle();
+ }
+ Timer {
+ id: gameOverTimer
+ interval: 1500
+ running : gameCanvas.gameOver && gameCanvas.mode == "puzzle" //mode will be reset by cleanUp();
+ repeat : false
+ onTriggered: {
+ Logic.cleanUp();
+ nextPuzzle();
+ }
+ }
+
+ Image {
+ source: "content/gfx/background.png"
+ anchors.fill: parent
+ }
+
+ GameArea {
+ id: gameCanvas
+ z: 1
+ y: Settings.headerHeight
+
+ width: parent.width
+ height: parent.height - Settings.headerHeight - Settings.footerHeight
+
+ backgroundVisible: root.state == "in-game"
+ onModeChanged: if (gameCanvas.mode != "puzzle") puzzleWon = false; //UI has stricter constraints on this variable than the game does
+ Age {
+ groups: ["redspots", "greenspots", "bluespots", "yellowspots"]
+ enabled: root.state == ""
+ system: gameCanvas.ps
+ }
+
+ onPuzzleLost: acc--;//So that nextPuzzle() reloads the current one
+
+ }
+
+ Item {
+ id: menu
+ z: 2
+ width: parent.width;
+ anchors.top: parent.top
+ anchors.bottom: bottomBar.top
+
+ LogoAnimation {
+ x: 64
+ y: Settings.headerHeight
+ particleSystem: gameCanvas.ps
+ running: root.state == ""
+ }
+ Row {
+ x: 112
+ y: 20
+ Image { source: "content/gfx/logo-a.png" }
+ Image { source: "content/gfx/logo-m.png" }
+ Image { source: "content/gfx/logo-e.png" }
+ }
+
+ Column {
+ y: 100 + 40
+ spacing: Settings.menuButtonSpacing
+
+ Button {
+ width: root.width
+ rotatedButton: true
+ imgSrc: "content/gfx/but-game-1.png"
+ onClicked: {
+ if (root.state == "in-game")
+ return //Prevent double clicking
+ root.state = "in-game"
+ gameCanvas.blockFile = "Block.qml"
+ gameCanvas.background = "gfx/background.png"
+ arcadeTimer.start();
+ }
+ //Emitted particles don't fade out, because ImageParticle is on the GameArea
+ system: gameCanvas.ps
+ group: "green"
+ Timer {
+ id: arcadeTimer
+ interval: Settings.menuDelay
+ running : false
+ repeat : false
+ onTriggered: Logic.startNewGame(gameCanvas)
+ }
+ }
+
+ Button {
+ width: root.width
+ rotatedButton: true
+ imgSrc: "content/gfx/but-game-2.png"
+ onClicked: {
+ if (root.state == "in-game")
+ return
+ root.state = "in-game"
+ gameCanvas.blockFile = "Block.qml"
+ gameCanvas.background = "gfx/background.png"
+ twopTimer.start();
+ }
+ system: gameCanvas.ps
+ group: "green"
+ Timer {
+ id: twopTimer
+ interval: Settings.menuDelay
+ running : false
+ repeat : false
+ onTriggered: Logic.startNewGame(gameCanvas, "multiplayer")
+ }
+ }
+
+ Button {
+ width: root.width
+ rotatedButton: true
+ imgSrc: "content/gfx/but-game-3.png"
+ onClicked: {
+ if (root.state == "in-game")
+ return
+ root.state = "in-game"
+ gameCanvas.blockFile = "SimpleBlock.qml"
+ gameCanvas.background = "gfx/background.png"
+ endlessTimer.start();
+ }
+ system: gameCanvas.ps
+ group: "blue"
+ Timer {
+ id: endlessTimer
+ interval: Settings.menuDelay
+ running : false
+ repeat : false
+ onTriggered: Logic.startNewGame(gameCanvas, "endless")
+ }
+ }
+
+ Button {
+ width: root.width
+ rotatedButton: true
+ imgSrc: "content/gfx/but-game-4.png"
+ group: "yellow"
+ onClicked: {
+ if (root.state == "in-game")
+ return
+ root.state = "in-game"
+ gameCanvas.blockFile = "PuzzleBlock.qml"
+ gameCanvas.background = "gfx/background.png"
+ puzzleTimer.start();
+ }
+ Timer {
+ id: puzzleTimer
+ interval: Settings.menuDelay
+ running : false
+ repeat : false
+ onTriggered: loadPuzzle();
+ }
+ system: gameCanvas.ps
+ }
+ }
+ }
+
+ Image {
+ id: scoreBar
+ source: "content/gfx/bar.png"
+ width: parent.width
+ z: 6
+ y: -Settings.headerHeight
+ height: Settings.headerHeight
+ Behavior on opacity { NumberAnimation {} }
+ SamegameText {
+ id: arcadeScore
+ anchors { right: parent.right; topMargin: 3; rightMargin: 11; top: parent.top}
+ text: '<font color="#f7d303">P1:</font> ' + gameCanvas.score
+ font.pixelSize: Settings.fontPixelSize
+ textFormat: Text.StyledText
+ color: "white"
+ opacity: gameCanvas.mode == "arcade" ? 1 : 0
+ Behavior on opacity { NumberAnimation {} }
+ }
+ SamegameText {
+ id: arcadeHighScore
+ anchors { left: parent.left; topMargin: 3; leftMargin: 11; top: parent.top}
+ text: '<font color="#f7d303">Highscore:</font> ' + gameCanvas.highScore
+ opacity: gameCanvas.mode == "arcade" ? 1 : 0
+ }
+ SamegameText {
+ id: p1Score
+ anchors { right: parent.right; topMargin: 3; rightMargin: 11; top: parent.top}
+ text: '<font color="#f7d303">P1:</font> ' + gameCanvas.score
+ opacity: gameCanvas.mode == "multiplayer" ? 1 : 0
+ }
+ SamegameText {
+ id: p2Score
+ anchors { left: parent.left; topMargin: 3; leftMargin: 11; top: parent.top}
+ text: '<font color="#f7d303">P2:</font> ' + gameCanvas.score2
+ opacity: gameCanvas.mode == "multiplayer" ? 1 : 0
+ rotation: 180
+ }
+ SamegameText {
+ id: puzzleMoves
+ anchors { left: parent.left; topMargin: 3; leftMargin: 11; top: parent.top}
+ text: '<font color="#f7d303">Moves:</font> ' + gameCanvas.moves
+ opacity: gameCanvas.mode == "puzzle" ? 1 : 0
+ }
+ SamegameText {
+ Image {
+ source: "content/gfx/icon-time.png"
+ x: -20
+ }
+ id: puzzleTime
+ anchors { topMargin: 3; top: parent.top; horizontalCenter: parent.horizontalCenter; horizontalCenterOffset: 20}
+ text: "00:00"
+ opacity: gameCanvas.mode == "puzzle" ? 1 : 0
+ Timer {
+ interval: 1000
+ repeat: true
+ running: gameCanvas.mode == "puzzle" && !gameCanvas.gameOver
+ onTriggered: {
+ var elapsed = Math.floor((new Date() - Logic.gameDuration)/ 1000.0);
+ var mins = Math.floor(elapsed/60.0);
+ var secs = (elapsed % 60);
+ puzzleTime.text = (mins < 10 ? "0" : "") + mins + ":" + (secs < 10 ? "0" : "") + secs;
+ }
+ }
+ }
+ SamegameText {
+ id: puzzleScore
+ anchors { right: parent.right; topMargin: 3; rightMargin: 11; top: parent.top}
+ text: '<font color="#f7d303">Score:</font> ' + gameCanvas.score
+ opacity: gameCanvas.mode == "puzzle" ? 1 : 0
+ }
+ }
+
+ Image {
+ id: bottomBar
+ width: parent.width
+ height: Settings.footerHeight
+ source: "content/gfx/bar.png"
+ y: parent.height - Settings.footerHeight;
+ z: 2
+ Button {
+ id: quitButton
+ height: Settings.toolButtonHeight
+ imgSrc: "content/gfx/but-quit.png"
+ onClicked: {Qt.quit(); }
+ anchors { left: parent.left; verticalCenter: parent.verticalCenter; leftMargin: 11 }
+ }
+ Button {
+ id: menuButton
+ height: Settings.toolButtonHeight
+ imgSrc: "content/gfx/but-menu.png"
+ visible: (root.state == "in-game");
+ onClicked: {root.state = ""; Logic.cleanUp(); gameCanvas.mode = ""}
+ anchors { left: quitButton.right; verticalCenter: parent.verticalCenter; leftMargin: 0 }
+ }
+ Button {
+ id: againButton
+ height: Settings.toolButtonHeight
+ imgSrc: "content/gfx/but-game-new.png"
+ visible: (root.state == "in-game");
+ opacity: gameCanvas.gameOver && (gameCanvas.mode == "arcade" || gameCanvas.mode == "multiplayer")
+ Behavior on opacity{ NumberAnimation {} }
+ onClicked: {if (gameCanvas.gameOver) { Logic.startNewGame(gameCanvas, gameCanvas.mode);}}
+ anchors { right: parent.right; verticalCenter: parent.verticalCenter; rightMargin: 11 }
+ }
+ Button {
+ id: nextButton
+ height: Settings.toolButtonHeight
+ imgSrc: "content/gfx/but-puzzle-next.png"
+ visible: (root.state == "in-game") && gameCanvas.mode == "puzzle" && gameCanvas.puzzleWon
+ opacity: gameCanvas.puzzleWon ? 1 : 0
+ Behavior on opacity{ NumberAnimation {} }
+ onClicked: {if (gameCanvas.puzzleWon) nextPuzzle();}
+ anchors { right: parent.right; verticalCenter: parent.verticalCenter; rightMargin: 11 }
+ }
+ }
+
+ Connections {
+ target: root
+ onStateChanged: stateChangeAnim.running = true
+ }
+ SequentialAnimation {
+ id: stateChangeAnim
+ ParallelAnimation {
+ NumberAnimation { target: bottomBar; property: "y"; to: root.height; duration: Settings.menuDelay/2; easing.type: Easing.OutQuad }
+ NumberAnimation { target: scoreBar; property: "y"; to: -Settings.headerHeight; duration: Settings.menuDelay/2; easing.type: Easing.OutQuad }
+ }
+ ParallelAnimation {
+ NumberAnimation { target: bottomBar; property: "y"; to: root.height - Settings.footerHeight; duration: Settings.menuDelay/2; easing.type: Easing.OutBounce}
+ NumberAnimation { target: scoreBar; property: "y"; to: root.state == "" ? -Settings.headerHeight : 0; duration: Settings.menuDelay/2; easing.type: Easing.OutBounce}
+ }
+ }
+
+ states: [
+ State {
+ name: "in-game"
+ PropertyChanges {
+ target: menu
+ opacity: 0
+ visible: false
+ }
+ }
+ ]
+
+ transitions: [
+ Transition {
+ NumberAnimation {properties: "x,y,opacity"}
+ }
+ ]
+
+ //"Debug mode"
+ focus: true
+ Keys.onAsteriskPressed: Logic.nuke();
+ Keys.onSpacePressed: gameCanvas.puzzleWon = true;
+}
diff --git a/QtDemo/qml/QtDemo/demos/samegame/samegame.qrc b/QtDemo/qml/QtDemo/demos/samegame/samegame.qrc
new file mode 100644
index 0000000..951b9d1
--- /dev/null
+++ b/QtDemo/qml/QtDemo/demos/samegame/samegame.qrc
@@ -0,0 +1,72 @@
+<RCC>
+ <qresource prefix="/demos/samegame">
+ <file>samegame.qml</file>
+ <file>settings.js</file>
+ <file>content/gfx/text-p1-won.png</file>
+ <file>content/gfx/background-puzzle.png</file>
+ <file>content/gfx/background.png</file>
+ <file>content/gfx/bar.png</file>
+ <file>content/gfx/blue-puzzle.png</file>
+ <file>content/gfx/blue.png</file>
+ <file>content/gfx/bubble-highscore.png</file>
+ <file>content/gfx/bubble-puzzle.png</file>
+ <file>content/gfx/but-game-1.png</file>
+ <file>content/gfx/but-game-2.png</file>
+ <file>content/gfx/but-game-3.png</file>
+ <file>content/gfx/but-game-4.png</file>
+ <file>content/gfx/but-game-new.png</file>
+ <file>content/gfx/but-menu.png</file>
+ <file>content/gfx/but-puzzle-next.png</file>
+ <file>content/gfx/but-quit.png</file>
+ <file>content/gfx/green-puzzle.png</file>
+ <file>content/gfx/green.png</file>
+ <file>content/gfx/icon-fail.png</file>
+ <file>content/gfx/icon-ok.png</file>
+ <file>content/gfx/icon-time.png</file>
+ <file>content/gfx/logo-a.png</file>
+ <file>content/gfx/logo-e.png</file>
+ <file>content/gfx/logo-g.png</file>
+ <file>content/gfx/logo-m.png</file>
+ <file>content/gfx/logo-s.png</file>
+ <file>content/gfx/logo.png</file>
+ <file>content/gfx/particle-brick.png</file>
+ <file>content/gfx/particle-paint.png</file>
+ <file>content/gfx/particle-smoke.png</file>
+ <file>content/gfx/red-puzzle.png</file>
+ <file>content/gfx/red.png</file>
+ <file>content/gfx/text-highscore-new.png</file>
+ <file>content/gfx/text-highscore.png</file>
+ <file>content/gfx/text-no-winner.png</file>
+ <file>content/gfx/text-p1-go.png</file>
+ <file>content/gfx/text-p1.png</file>
+ <file>content/gfx/text-p2-go.png</file>
+ <file>content/gfx/text-p2-won.png</file>
+ <file>content/gfx/text-p2.png</file>
+ <file>content/gfx/yellow-puzzle.png</file>
+ <file>content/gfx/yellow.png</file>
+ <file>content/levels/level0.qml</file>
+ <file>content/levels/level1.qml</file>
+ <file>content/levels/level2.qml</file>
+ <file>content/levels/level3.qml</file>
+ <file>content/levels/level4.qml</file>
+ <file>content/levels/level5.qml</file>
+ <file>content/levels/level6.qml</file>
+ <file>content/levels/level7.qml</file>
+ <file>content/levels/level8.qml</file>
+ <file>content/levels/level9.qml</file>
+ <file>content/levels/TemplateBase.qml</file>
+ <file>content/SamegameText.qml</file>
+ <file>content/SimpleBlock.qml</file>
+ <file>content/Block.qml</file>
+ <file>content/BlockEmitter.qml</file>
+ <file>content/Button.qml</file>
+ <file>content/GameArea.qml</file>
+ <file>content/LogoAnimation.qml</file>
+ <file>content/MenuEmitter.qml</file>
+ <file>content/PaintEmitter.qml</file>
+ <file>content/PrimaryPack.qml</file>
+ <file>content/PuzzleBlock.qml</file>
+ <file>content/samegame.js</file>
+ <file>content/SmokeText.qml</file>
+ </qresource>
+</RCC>
diff --git a/QtDemo/qml/QtDemo/demos/samegame/settings.js b/QtDemo/qml/QtDemo/demos/samegame/settings.js
new file mode 100644
index 0000000..e09dee9
--- /dev/null
+++ b/QtDemo/qml/QtDemo/demos/samegame/settings.js
@@ -0,0 +1,56 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Research In Motion
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+.pragma library
+
+//This should be switched over once a proper QML settings API exists
+
+var menuDelay = 500
+
+var headerHeight = 20 // 70 on BB10
+var footerHeight = 44 // 100 on BB10
+
+var fontPixelSize = 14 // 55 on BB10
+
+var blockSize = 32 // 64 on BB10
+
+var toolButtonHeight = 32 // 64 on BB10
+
+var menuButtonSpacing = 0 // 15 on BB10
diff --git a/QtDemo/qml/QtDemo/engine.js b/QtDemo/qml/QtDemo/engine.js
index c89209a..b944f75 100644
--- a/QtDemo/qml/QtDemo/engine.js
+++ b/QtDemo/qml/QtDemo/engine.js
@@ -1,20 +1,22 @@
-var positions = [{x:1300, y:-500, angle:-45, borderColor: "blue", scale: .7, url: "demos/calqlatr/Calqlatr.qml"},
- {x:-200, y:200, angle:0, borderColor: "grey", scale: .7, url: "demos/tweetsearch/tweetsearch.qml"},
- {x:-1600, y:-1300, angle:170, borderColor: "green", scale: .8, url: "demos/calqlatr/Calqlatr.qml"},
- {x:-1000, y:1500, angle:289, borderColor: "red", scale: .7, url: "demos/tweetsearch/tweetsearch.qml"},
- {x: 1700, y: 1100, angle:270, borderColor: "lime", scale: .8, url: "demos/calqlatr/Calqlatr.qml"},
- {x:50, y:-1500, angle:-45, borderColor: "black", scale: .7, url: "demos/tweetsearch/tweetsearch.qml"}
+var positions = [{x:1300, y:-500, angle: 0, borderColor: "blue", scale: .6, url: "demos/calqlatr/Calqlatr.qml", device: 0},
+ {x:-1200, y:200, angle:0, borderColor: "grey", scale: .6, url: "demos/tweetsearch/tweetsearch.qml", device: 0},
+ {x:-1600, y:-1300, angle: 0, borderColor: "green", scale: .6, url: "demos/samegame/samegame.qml", device: 0},
+ {x:-1300, y:1500, angle: 0, borderColor: "red", scale: 1.4, url: "demos/particledemo/particledemo.qml", device: 1},
+ {x: 1700, y: 1100, angle:0, borderColor: "lime", scale: .6, url: "demos/calqlatr/Calqlatr.qml", device: 0},
+ {x:50, y:-1500, angle: 0, borderColor: "black", scale: .6, url: "demos/tweetsearch/tweetsearch.qml", device: 0},
+ {x: 1200, y:-1600, angle: 0, borderColor: "orange", scale: .8, url: "demos/particledemo/particledemo.qml", device: 2},
+ {x: 500, y:1400, angle: 0, borderColor: "orange", scale: 2, url: "demos/particledemo/particledemo.qml", device: 3}
]
var objects = []
function initSlides(){
positions.forEach(function(pos){
- createNew(pos.x,pos.y,pos.angle, pos.borderColor, pos.scale, pos.url)
+ createNew(pos.x,pos.y,pos.angle, pos.borderColor, pos.scale, pos.url, pos.device)
})
}
-function createNew(x,y,angle,borderColor,scale,url){
+function createNew(x,y,angle,borderColor,scale,url,device){
var component = Qt.createComponent("Slide.qml")
if (component.status === Component.Ready)
var object=component.createObject(canvas)
@@ -26,6 +28,8 @@ function createNew(x,y,angle,borderColor,scale,url){
//in future objects will also
//get destroyed and re-created
object.borderColor = borderColor
+ object.device = device
+
if (url){
object.url = url;
@@ -53,7 +57,7 @@ function lookForSlides(x,y,angle){
return selectTarget(positions[idx].uid);
}
}
- return null; //no match
+ return selectTarget(null) //random
}
function selectTarget(uid){
diff --git a/QtDemo/qml/QtDemo/images/Laptop_mask.png b/QtDemo/qml/QtDemo/images/Laptop_mask.png
new file mode 100644
index 0000000..ffeafef
--- /dev/null
+++ b/QtDemo/qml/QtDemo/images/Laptop_mask.png
Binary files differ
diff --git a/QtDemo/qml/QtDemo/images/MedicalDevice_mask.png b/QtDemo/qml/QtDemo/images/MedicalDevice_mask.png
new file mode 100644
index 0000000..84a5edf
--- /dev/null
+++ b/QtDemo/qml/QtDemo/images/MedicalDevice_mask.png
Binary files differ
diff --git a/QtDemo/qml/QtDemo/images/Tablet_mask.png b/QtDemo/qml/QtDemo/images/Tablet_mask.png
new file mode 100644
index 0000000..fe0db54
--- /dev/null
+++ b/QtDemo/qml/QtDemo/images/Tablet_mask.png
Binary files differ
diff --git a/QtDemo/qml/QtDemo/images/iPhone_mask.png b/QtDemo/qml/QtDemo/images/iPhone_mask.png
new file mode 100644
index 0000000..79c4d31
--- /dev/null
+++ b/QtDemo/qml/QtDemo/images/iPhone_mask.png
Binary files differ
diff --git a/QtDemo/qml/QtDemo/main.qml b/QtDemo/qml/QtDemo/main.qml
index 48f01d8..5159d20 100644
--- a/QtDemo/qml/QtDemo/main.qml
+++ b/QtDemo/qml/QtDemo/main.qml
@@ -6,11 +6,15 @@ Item{
width: 1280
height: 800
clip: true
+
+ property bool showDebugRects: false
+
Rectangle{
anchors.centerIn: parent
width:1000
height:1
color: "black"
+ visible: app.showDebugRects
}
Rectangle{
@@ -18,6 +22,7 @@ Item{
width: 1
height:1000
color: "black"
+ visible: app.showDebugRects
}
MouseArea{
@@ -34,6 +39,21 @@ Item{
anchors.fill: parent
+ onDoubleClicked: {
+ //to initial state
+ canvas.xOffset = 0
+ canvas.yOffset = 0
+ canvas.rotationOriginX = 0
+ canvas.rotationOriginY = 0
+ canvas.angle = 0
+
+ //canvas.zoomOutTarget = .4
+ //canvas.scalingFactor = 5
+ canvas.zoomInTarget = 0.2 //1.0/canvas.scalingFactor
+
+ zoomOutAnimation.restart()
+ }
+
onClicked: {
var target = null;
var velocity = 0;
@@ -71,6 +91,7 @@ Item{
target = Engine.selectTarget(null)
}
}
+ panning = false;
canvas.xOffset = -target.x
canvas.yOffset = -target.y
@@ -165,9 +186,9 @@ Item{
//Qt logo image taken 28.3.2013 from: http://upload.wikimedia.org/wikipedia/de/0/08/Qt_(Bibliothek)_logo.svg
source: "QtLogo.svg"
anchors.centerIn: parent
- width: 5030
- height: 6000
- sourceSize: Qt.size(5030,6000)
+ width: 503*2
+ height: 600*2
+ sourceSize: Qt.size(503*2,600*2)
smooth: !zoomFlyByAnimation.running
}
@@ -192,11 +213,17 @@ Item{
SequentialAnimation{
id: zoomFlyByAnimation
- alwaysRunToEnd: true
- NumberAnimation { target: canvas; property: "scalingFactor"; duration: 700; to:canvas.zoomOutTarget; easing.type: Easing.OutCubic }
- NumberAnimation { target: canvas; property: "scalingFactor"; duration: 700; to:canvas.zoomInTarget; easing.type: Easing.OutBounce }
+ NumberAnimation { target: canvas; property: "scalingFactor"; duration: 500; to:canvas.zoomOutTarget; easing.type: Easing.OutCubic }
+ NumberAnimation { target: canvas; property: "scalingFactor"; duration: 500; to:canvas.zoomInTarget; easing.type: Easing.InCubic }
+ //NumberAnimation { target: canvas; property: "scalingFactor"; duration: 600; to:canvas.zoomInTarget; easing.type: Easing.OutBounce }
}
+ SequentialAnimation{
+ id: zoomOutAnimation
+ alwaysRunToEnd: true
+ NumberAnimation { target: canvas; property: "scalingFactor"; duration: 1500; to:canvas.zoomInTarget; easing.type: Easing.OutCubic }
+ onStarted: zoomFlyByAnimation.stop()
+ }
NavigationPanel{
anchors{top:parent.top; right:parent.right}