aboutsummaryrefslogtreecommitdiffstats
path: root/examples/demos/samegame/content
diff options
context:
space:
mode:
Diffstat (limited to 'examples/demos/samegame/content')
-rw-r--r--examples/demos/samegame/content/BlockEmitter.qml6
-rw-r--r--examples/demos/samegame/content/Button.qml9
-rw-r--r--examples/demos/samegame/content/GameArea.qml4
-rw-r--r--examples/demos/samegame/content/PaintEmitter.qml5
-rw-r--r--examples/demos/samegame/content/SamegameText.qml49
-rwxr-xr-xexamples/demos/samegame/content/samegame.js27
6 files changed, 77 insertions, 23 deletions
diff --git a/examples/demos/samegame/content/BlockEmitter.qml b/examples/demos/samegame/content/BlockEmitter.qml
index e39616ee52..7dad509dfd 100644
--- a/examples/demos/samegame/content/BlockEmitter.qml
+++ b/examples/demos/samegame/content/BlockEmitter.qml
@@ -41,6 +41,8 @@
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}
@@ -50,6 +52,6 @@ Emitter {
lifeSpan: 700; lifeSpanVariation: 100
emitRate: 1000
maximumEmitted: 100 //only fires 0.1s bursts (still 2x old number)
- size: 28
- endSize: 14
+ size: Settings.blockSize * 0.85
+ endSize: Settings.blockSize * 0.85 /2
}
diff --git a/examples/demos/samegame/content/Button.qml b/examples/demos/samegame/content/Button.qml
index b17c831e41..aab21ec8c6 100644
--- a/examples/demos/samegame/content/Button.qml
+++ b/examples/demos/samegame/content/Button.qml
@@ -47,12 +47,15 @@ Item {
property alias group: emitter.group
signal clicked
property bool rotatedButton: false
- //Defaults, feel free to override
+
width: image.width
- height: image.height
+ height: image.sourceSize.height
Image {
id: image
- anchors.centerIn: parent
+ 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
diff --git a/examples/demos/samegame/content/GameArea.qml b/examples/demos/samegame/content/GameArea.qml
index 0185ab50dc..f3ca98d80e 100644
--- a/examples/demos/samegame/content/GameArea.qml
+++ b/examples/demos/samegame/content/GameArea.qml
@@ -48,7 +48,6 @@ Item {
property int score: 0
property int highScore: 0
property int moves: 0
- property int blockSize: 32
property string mode: ""
property ParticleSystem ps: particleSystem
//For easy theming
@@ -85,12 +84,11 @@ Item {
Image {
id: bg
z: -1
+ anchors.fill: parent
source: background;
fillMode: Image.PreserveAspectCrop
}
- width: 320
- height: 480
MouseArea {
anchors.fill: parent; onClicked: {
if (puzzleTextBubble.opacity == 1) {
diff --git a/examples/demos/samegame/content/PaintEmitter.qml b/examples/demos/samegame/content/PaintEmitter.qml
index 5f2ea1f9a9..4a67c4a2d2 100644
--- a/examples/demos/samegame/content/PaintEmitter.qml
+++ b/examples/demos/samegame/content/PaintEmitter.qml
@@ -40,6 +40,7 @@
import QtQuick 2.0
import QtQuick.Particles 2.0
+import "../settings.js" as Settings
Emitter {
property Item block: parent
@@ -56,8 +57,8 @@ Emitter {
"yellowspots";
}
}
- size: 64
- endSize: 16
+ size: Settings.blockSize * 2
+ endSize: Settings.blockSize/2
lifeSpan: 30000
enabled: false
emitRate: 60
diff --git a/examples/demos/samegame/content/SamegameText.qml b/examples/demos/samegame/content/SamegameText.qml
new file mode 100644
index 0000000000..28c85f9486
--- /dev/null
+++ b/examples/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/examples/demos/samegame/content/samegame.js b/examples/demos/samegame/content/samegame.js
index 320203583f..7b226cb42f 100755
--- a/examples/demos/samegame/content/samegame.js
+++ b/examples/demos/samegame/content/samegame.js
@@ -41,6 +41,7 @@
/* 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;
@@ -110,8 +111,8 @@ function startNewGame(gc, mode, map)
gc.gameOver = false;
gc.mode = gameMode;
// Calculate board size
- maxColumn = Math.floor(gameCanvas.width/gameCanvas.blockSize);
- maxRow = Math.floor(gameCanvas.height/gameCanvas.blockSize);
+ 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();
@@ -142,8 +143,8 @@ function handleClick(x,y)
{
if (betweenTurns || gameOver || gameCanvas == undefined)
return;
- var column = Math.floor(x/gameCanvas.blockSize);
- var row = Math.floor(y/gameCanvas.blockSize);
+ 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)
@@ -211,7 +212,7 @@ function shuffleDown()
} else {
if (fallDist > 0) {
var obj = board[index(column, row)];
- obj.y = (row + fallDist) * gameCanvas.blockSize;
+ obj.y = (row + fallDist) * Settings.blockSize;
board[index(column, row + fallDist)] = obj;
board[index(column, row)] = null;
}
@@ -229,7 +230,7 @@ function shuffleDown()
obj = board[index(column, row)];
if (obj == null)
continue;
- obj.x = (column - fallDist) * gameCanvas.blockSize;
+ obj.x = (column - fallDist) * Settings.blockSize;
board[index(column - fallDist,row)] = obj;
board[index(column, row)] = null;
}
@@ -250,7 +251,7 @@ function shuffleUp()
} else {
if (fallDist > 0) {
var obj = board[index(column, row)];
- obj.y = (row - fallDist) * gameCanvas.blockSize;
+ obj.y = (row - fallDist) * Settings.blockSize;
board[index(column, row - fallDist)] = obj;
board[index(column, row)] = null;
}
@@ -268,7 +269,7 @@ function shuffleUp()
obj = board[index(column, row)];
if (obj == null)
continue;
- obj.x = (column - fallDist) * gameCanvas.blockSize;
+ obj.x = (column - fallDist) * Settings.blockSize;
board[index(column - fallDist,row)] = obj;
board[index(column, row)] = null;
}
@@ -371,17 +372,17 @@ function createBlock(column,row,type)
}
var dynamicObject = component.createObject(gameCanvas,
{"type": type,
- "x": column*gameCanvas.blockSize,
- "y": -1*gameCanvas.blockSize,
- "width": gameCanvas.blockSize,
- "height": gameCanvas.blockSize,
+ "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*gameCanvas.blockSize;
+ dynamicObject.y = row*Settings.blockSize;
dynamicObject.spawned = true;
board[index(column,row)] = dynamicObject;