aboutsummaryrefslogtreecommitdiffstats
path: root/demos/declarative/samegame
diff options
context:
space:
mode:
Diffstat (limited to 'demos/declarative/samegame')
-rw-r--r--demos/declarative/samegame/SamegameCore/BoomBlock.qml36
-rw-r--r--demos/declarative/samegame/SamegameCore/Button.qml2
-rw-r--r--demos/declarative/samegame/SamegameCore/Dialog.qml7
-rw-r--r--demos/declarative/samegame/SamegameCore/pics/blueStar.pngbin278 -> 0 bytes
-rw-r--r--demos/declarative/samegame/SamegameCore/pics/greenStar.pngbin273 -> 0 bytes
-rw-r--r--demos/declarative/samegame/SamegameCore/pics/particle.pngbin0 -> 861 bytes
-rw-r--r--demos/declarative/samegame/SamegameCore/pics/redStar.pngbin274 -> 0 bytes
-rw-r--r--demos/declarative/samegame/SamegameCore/pics/star.pngbin262 -> 0 bytes
-rwxr-xr-xdemos/declarative/samegame/SamegameCore/samegame.js43
-rw-r--r--demos/declarative/samegame/samegame.qml35
10 files changed, 95 insertions, 28 deletions
diff --git a/demos/declarative/samegame/SamegameCore/BoomBlock.qml b/demos/declarative/samegame/SamegameCore/BoomBlock.qml
index d3904e705d..67e67b893a 100644
--- a/demos/declarative/samegame/SamegameCore/BoomBlock.qml
+++ b/demos/declarative/samegame/SamegameCore/BoomBlock.qml
@@ -39,8 +39,8 @@
**
****************************************************************************/
-import QtQuick 1.1
-import Qt.labs.particles 1.0
+import QtQuick 2.0
+import Qt.labs.particles 2.0
Item {
id: block
@@ -71,26 +71,28 @@ Item {
Behavior on opacity { NumberAnimation { duration: 200 } }
anchors.fill: parent
}
-
- Particles {
+ TrailEmitter {
id: particles
-
- width: 1; height: 1
- anchors.centerIn: parent
-
- emissionRate: 0
- lifeSpan: 700; lifeSpanDeviation: 600
- angle: 0; angleDeviation: 360;
- velocity: 100; velocityDeviation: 30
- source: {
+ system: particleSystem
+ particle: {
if(type == 0){
- "pics/redStar.png";
+ "red";
} else if (type == 1) {
- "pics/blueStar.png";
+ "blue";
} else {
- "pics/greenStar.png";
+ "green";
}
}
+ anchors.fill: parent
+
+ speed: DirectedVector{targetX: block.width/2; targetY: block.height/2; magnitude: -60; magnitudeVariation: 60}
+ shape: Ellipse{fill:true}
+ emitting: false;
+ particleDuration: 700; particleDurationVariation: 100
+ particlesPerSecond: 1000
+ maxParticles: 100 //only fires 0.1s bursts (still 2x old number, ColoredParticle wants less than 16000 max though)
+ particleSize: 28
+ particleEndSize: 14
}
states: [
@@ -101,7 +103,7 @@ Item {
State {
name: "DeathState"; when: dying == true
- StateChangeScript { script: particles.burst(50); }
+ StateChangeScript { script: particles.pulse(0.1); }
PropertyChanges { target: img; opacity: 0 }
StateChangeScript { script: block.destroy(1000); }
}
diff --git a/demos/declarative/samegame/SamegameCore/Button.qml b/demos/declarative/samegame/SamegameCore/Button.qml
index 933bdfe2de..be9ad62dfd 100644
--- a/demos/declarative/samegame/SamegameCore/Button.qml
+++ b/demos/declarative/samegame/SamegameCore/Button.qml
@@ -39,7 +39,7 @@
**
****************************************************************************/
-import QtQuick 1.1
+import QtQuick 2.0
Rectangle {
id: container
diff --git a/demos/declarative/samegame/SamegameCore/Dialog.qml b/demos/declarative/samegame/SamegameCore/Dialog.qml
index 3c0b92df97..aea6ac7dda 100644
--- a/demos/declarative/samegame/SamegameCore/Dialog.qml
+++ b/demos/declarative/samegame/SamegameCore/Dialog.qml
@@ -39,23 +39,26 @@
**
****************************************************************************/
-import QtQuick 1.1
+import QtQuick 2.0
Rectangle {
id: page
property Item text: dialogText
+ property bool open: false
signal closed
signal opened
function forceClose() {
- if(page.opacity == 0)
+ if(!open)
return; //already closed
+ page.open = false;
page.closed();
page.opacity = 0;
}
function show(txt) {
+ page.open = true;
page.opened();
dialogText.text = txt;
page.opacity = 1;
diff --git a/demos/declarative/samegame/SamegameCore/pics/blueStar.png b/demos/declarative/samegame/SamegameCore/pics/blueStar.png
deleted file mode 100644
index ff9588f80a..0000000000
--- a/demos/declarative/samegame/SamegameCore/pics/blueStar.png
+++ /dev/null
Binary files differ
diff --git a/demos/declarative/samegame/SamegameCore/pics/greenStar.png b/demos/declarative/samegame/SamegameCore/pics/greenStar.png
deleted file mode 100644
index cd06854719..0000000000
--- a/demos/declarative/samegame/SamegameCore/pics/greenStar.png
+++ /dev/null
Binary files differ
diff --git a/demos/declarative/samegame/SamegameCore/pics/particle.png b/demos/declarative/samegame/SamegameCore/pics/particle.png
new file mode 100644
index 0000000000..5c83896d22
--- /dev/null
+++ b/demos/declarative/samegame/SamegameCore/pics/particle.png
Binary files differ
diff --git a/demos/declarative/samegame/SamegameCore/pics/redStar.png b/demos/declarative/samegame/SamegameCore/pics/redStar.png
deleted file mode 100644
index 0a4dffe583..0000000000
--- a/demos/declarative/samegame/SamegameCore/pics/redStar.png
+++ /dev/null
Binary files differ
diff --git a/demos/declarative/samegame/SamegameCore/pics/star.png b/demos/declarative/samegame/SamegameCore/pics/star.png
deleted file mode 100644
index defbde53ca..0000000000
--- a/demos/declarative/samegame/SamegameCore/pics/star.png
+++ /dev/null
Binary files differ
diff --git a/demos/declarative/samegame/SamegameCore/samegame.js b/demos/declarative/samegame/SamegameCore/samegame.js
index bb587bc6f3..4c5cbe5bb3 100755
--- a/demos/declarative/samegame/SamegameCore/samegame.js
+++ b/demos/declarative/samegame/SamegameCore/samegame.js
@@ -4,10 +4,11 @@ var maxColumn = 10;
var maxRow = 15;
var maxIndex = maxColumn*maxRow;
var board = new Array(maxIndex);
-var blockSrc = "SamegameCore/BoomBlock.qml";
+var blockSrc = "BoomBlock.qml";
var scoresURL = "";
var gameDuration;
var component = Qt.createComponent(blockSrc);
+var highScoreBar = 0;
// Index function used instead of a 2D array
function index(column, row)
@@ -152,11 +153,15 @@ function victoryCheck()
// Checks for game over
if (deservesBonus || !(floodMoveCheck(0, maxRow - 1, -1))) {
gameDuration = new Date() - gameDuration;
- nameInputDialog.show("You won! Please enter your name: ");
- nameInputDialog.initialWidth = nameInputDialog.text.width + 20;
- if (nameInputDialog.name == "")
- nameInputDialog.width = nameInputDialog.initialWidth;
- nameInputDialog.text.opacity = 0; // Just a spacer
+ if(gameCanvas.score > highScoreBar){
+ nameInputDialog.show("You won! Please enter your name: ");
+ nameInputDialog.initialWidth = nameInputDialog.text.width + 20;
+ if (nameInputDialog.name == "")
+ nameInputDialog.width = nameInputDialog.initialWidth;
+ nameInputDialog.text.opacity = 0; // Just a spacer
+ }else{
+ dialog.show("You won!");
+ }
}
}
@@ -203,6 +208,30 @@ function createBlock(column,row)
return true;
}
+function initHighScoreBar()
+{
+ if(scoresURL != "")
+ return true;//don't query remote scores
+ var db = openDatabaseSync(
+ "SameGameScores",
+ "1.0",
+ "Local SameGame High Scores",
+ 100
+ );
+ db.transaction(
+ function(tx) {
+ tx.executeSql('CREATE TABLE IF NOT EXISTS Scores(name 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 + '" ORDER BY score desc LIMIT 10');
+ if(rs.rows.length < 10)
+ highScoreBar = 0;
+ else
+ highScoreBar = rs.rows.item(rs.rows.length - 1).score;
+ }
+ );
+}
+
function saveHighScore(name)
{
if (scoresURL != "")
@@ -235,6 +264,8 @@ function saveHighScore(name)
+ rs.rows.item(i).score + ' points in '
+ rs.rows.item(i).time + ' seconds.\n';
}
+ if(rs.rows.length == 10)
+ highScoreBar = rs.rows.item(9).score;
dialog.show(r);
}
);
diff --git a/demos/declarative/samegame/samegame.qml b/demos/declarative/samegame/samegame.qml
index 7917d9ac8c..202eb40401 100644
--- a/demos/declarative/samegame/samegame.qml
+++ b/demos/declarative/samegame/samegame.qml
@@ -39,13 +39,14 @@
**
****************************************************************************/
-import QtQuick 1.1
+import QtQuick 2.0
+import Qt.labs.particles 2.0
import "SamegameCore"
import "SamegameCore/samegame.js" as Logic
Rectangle {
id: screen
- width: 490; height: 720
+ width: 360; height: 640
property bool inAnotherDemo: false //Samegame often is just plonked straight into other demos
SystemPalette { id: activePalette }
@@ -74,6 +75,36 @@ Rectangle {
anchors.fill: parent; onClicked: Logic.handleClick(mouse.x,mouse.y);
}
}
+ Item{
+ ParticleSystem{ id: particleSystem; }
+ ColoredParticle {
+ system: particleSystem
+ particles: ["red"]
+ color: Qt.darker("red");//Actually want desaturated...
+ image: "SamegameCore/pics/particle.png"
+ colorVariation: 0.4
+ alpha: 0.1
+ }
+ ColoredParticle {
+ system: particleSystem
+ particles: ["green"]
+ color: Qt.darker("green");//Actually want desaturated...
+ image: "SamegameCore/pics/particle.png"
+ colorVariation: 0.4
+ alpha: 0.1
+ }
+ ColoredParticle {
+ system: particleSystem
+ particles: ["blue"]
+ color: Qt.darker("blue");//Actually want desaturated...
+ image: "SamegameCore/pics/particle.png"
+ colorVariation: 0.4
+ alpha: 0.1
+ }
+ id: aboveGameCanvas
+ anchors.fill: gameCanvas
+ z: gameCanvas.z + 1
+ }
}
Dialog { id: dialog; anchors.centerIn: parent; z: 21 }