summaryrefslogtreecommitdiffstats
path: root/animals
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@nokia.com>2010-08-12 16:08:03 +0200
committerFrederik Gladhorn <frederik.gladhorn@nokia.com>2010-08-12 16:09:43 +0200
commit9e7a4827a1335dbac94d523279966f49dc856f54 (patch)
tree9815d7eb5969f5f2f99cf0fa0757d55aaffe47da /animals
parentb1200bcf83536abcaf665b9ee722733e1c4a0361 (diff)
Use nicer pictures, clean up creation logic and use pictures twice.
Diffstat (limited to 'animals')
-rwxr-xr-xanimals/Animal.qml94
-rw-r--r--animals/images/.directory3
-rw-r--r--animals/images/Gerald_G_Crawfish.pngbin0 -> 154310 bytes
-rw-r--r--animals/images/Gerald_G_Rubber_Duck.pngbin0 -> 48453 bytes
-rw-r--r--animals/images/Machovka_lady_bug.pngbin0 -> 103580 bytes
-rw-r--r--animals/images/bugmenot_Happy_Pig.pngbin0 -> 100826 bytes
-rw-r--r--animals/images/carlitos_Green_Worm.pngbin0 -> 148551 bytes
-rw-r--r--animals/images/danko_Friendly_rabbit.pngbin0 -> 83830 bytes
-rw-r--r--animals/images/molumen_Green_sitting_frog.pngbin0 -> 196897 bytes
-rw-r--r--animals/memory.js50
-rw-r--r--animals/memory.qml2
11 files changed, 52 insertions, 97 deletions
diff --git a/animals/Animal.qml b/animals/Animal.qml
index b315f19..2cdc70a 100755
--- a/animals/Animal.qml
+++ b/animals/Animal.qml
@@ -7,16 +7,16 @@ Rectangle {
id: animalRectangle;
property string image;
+ color: "transparent"
width: 100; height: 100;
- property int imageSize: width - 10
+ property int imageSize: width - 10;
+
+ transformOriginPoint.x: width/2;
+ transformOriginPoint.y: height/2;
// to identify pairs of animals
property int type;
- color: "transparent"
-
- signal rotated
-
Flipable {
id: flipable
anchors.fill: parent
@@ -60,6 +60,24 @@ Rectangle {
}
}
+ states: [
+ State {
+ name: ""
+ PropertyChanges {
+ target: animalRectangle
+ rotation: 0
+
+ }
+ },
+ State {
+ name: "rotated"
+ PropertyChanges {
+ target: animalRectangle
+
+ }
+ }
+ ]
+
function hide() {
hideTimer.start();
console.log("hiding: " + image);
@@ -71,97 +89,51 @@ Rectangle {
onTriggered: flipable.flipped = false;
}
-
function showFront() {
flipable.flipped = true;
parent.animalFlipped(animalRectangle);
}
- Behavior on scale {
- NumberAnimation {
- easing.type: Easing.OutBounce
- easing.amplitude: 100
- duration: 400
- }
- }
- Behavior on opacity {
- NumberAnimation {
- easing.type: Easing.OutBounce
- easing.amplitude: 100
- duration: 400
- }
- }
-
GestureArea {
anchors.fill: parent
Tap {
onStarted: { console.log("tap started");
- //animalRectangle.color = "red";
- //animalRectangle.toggleSide();
-// animalRectangle.scale = 1.1;
+ animalRectangle.z = 1;
}
onCanceled: { console.log("tap canceled");
- //animalRectangle.color = "white";
-// animalRectangle.scale = 1.0;
}
onFinished: { console.log("tap finished");
- //animalRectangle.color = "white";
-// animalRectangle.scale = 1.0;
animalRectangle.showFront();
}
}
TapAndHold {
onStarted: { console.log("tap-and-hold started"); }
-
- onFinished: {
- console.log("tap-and-hold finished");
-// animalRectangle.scale = 1.0;
-// animalRectangle.rotation = 0.0;
+ onFinished: { console.log("tap-and-hold finished");
+ animalRectangle.state = "";
}
}
Pan {
- onStarted: { console.log("pan started");
- }
onUpdated: {
- //console.log("pan update dx:" + gesture.delta.x + " dy: " + gesture.delta.y
- // + " ox: " + gesture.offset.x);
-// animalRectangle.scale = 0.8;
- //animalRectangle.x += gesture.offset.x;
-// animalRectangle.opacity = 0.7;
animalRectangle.x += gesture.delta.x;
animalRectangle.y += gesture.delta.y;
}
- onFinished: { console.log("pan finished");
-// animalRectangle.scale = 1.0;
- animalRectangle.opacity = 1.0;
-
- console.log( "velocity: " + gesture.horizontalVelocity + ", " + gesture.verticalVelocity );
- }
}
Pinch {
- onStarted:
- {
- console.log("pinch started");
- animalRectangle.tmpScale = eval(animalRectangle.scale);
-
+ onStarted: {
+ animalRectangle.state = "rotated";
}
+
onUpdated: {
- console.log("scale total:" + gesture.totalScaleFactor
- +"scaleFactor:" + gesture.scaleFactor );
- //animalRectangle.scale = gesture.scaleFactor;
-// animalRectangle.scale *= 1.0 + gesture.totalScaleFactor;
- console.log("rotation total:" + gesture.totalRotationAngle
- +"rotationAngle:" + gesture.rotationAngle );
-
- //animalRectangle.rotation = gesture.totalRotationAngle;
animalRectangle.rotation += gesture.rotationAngle - gesture.lastRotationAngle
+ animalRectangle.scale = animalRectangle.scale * gesture.scaleFactor;
+ animalRectangle.x += gesture.centerPoint.x - gesture.lastCenterPoint.x
+ animalRectangle.y += gesture.centerPoint.y - gesture.lastCenterPoint.y
- console.log("tmpScale: " + animalRectangle.tmpScale);
- animalRectangle.scale += gesture.scaleFactor - gesture.lastScaleFactor;
+ console.log("center: " + gesture.centerPoint.x + " last center: " + gesture.lastCenterPoint.x);
}
}
diff --git a/animals/images/.directory b/animals/images/.directory
new file mode 100644
index 0000000..db52e72
--- /dev/null
+++ b/animals/images/.directory
@@ -0,0 +1,3 @@
+[Dolphin]
+ShowPreview=true
+Timestamp=2010,8,12,11,43,32
diff --git a/animals/images/Gerald_G_Crawfish.png b/animals/images/Gerald_G_Crawfish.png
new file mode 100644
index 0000000..74cb597
--- /dev/null
+++ b/animals/images/Gerald_G_Crawfish.png
Binary files differ
diff --git a/animals/images/Gerald_G_Rubber_Duck.png b/animals/images/Gerald_G_Rubber_Duck.png
new file mode 100644
index 0000000..8d0dcfc
--- /dev/null
+++ b/animals/images/Gerald_G_Rubber_Duck.png
Binary files differ
diff --git a/animals/images/Machovka_lady_bug.png b/animals/images/Machovka_lady_bug.png
new file mode 100644
index 0000000..507dfbc
--- /dev/null
+++ b/animals/images/Machovka_lady_bug.png
Binary files differ
diff --git a/animals/images/bugmenot_Happy_Pig.png b/animals/images/bugmenot_Happy_Pig.png
new file mode 100644
index 0000000..214c256
--- /dev/null
+++ b/animals/images/bugmenot_Happy_Pig.png
Binary files differ
diff --git a/animals/images/carlitos_Green_Worm.png b/animals/images/carlitos_Green_Worm.png
new file mode 100644
index 0000000..975e026
--- /dev/null
+++ b/animals/images/carlitos_Green_Worm.png
Binary files differ
diff --git a/animals/images/danko_Friendly_rabbit.png b/animals/images/danko_Friendly_rabbit.png
new file mode 100644
index 0000000..f075932
--- /dev/null
+++ b/animals/images/danko_Friendly_rabbit.png
Binary files differ
diff --git a/animals/images/molumen_Green_sitting_frog.png b/animals/images/molumen_Green_sitting_frog.png
new file mode 100644
index 0000000..bdea2e8
--- /dev/null
+++ b/animals/images/molumen_Green_sitting_frog.png
Binary files differ
diff --git a/animals/memory.js b/animals/memory.js
index 0943190..a01083a 100644
--- a/animals/memory.js
+++ b/animals/memory.js
@@ -1,28 +1,15 @@
-
-
var component;
-var maxColumn = 4;
var maxRow = 3;
+var maxColumn = 6;
var maxIndex = maxColumn * maxRow;
var finished = new Array();
-var order = new Array(maxIndex);
+var positions = new Array();
-var animals = [ [1, "Andy_ant.png"],
- [1, "rejon_Ant_Icon.png"],
- [2, "ArtFavor_Cartoon_Sheep.png"],
- [2, "ArtFavor_Sheep_(Ewe).png"],
- [3, "johnny_automatic_cow.png"],
- [3, "lemmling_Cartoon_cow.png"],
- [4, "obi_Dragon_s_head.png"],
- [4, "liftarn_Ddraig.png"],
- [5, "PeterM_Housefly.png"],
- [5, "PeterM_Bee.png"],
- [6, "PeterM_Sad_cat.png"],
- [6, "PeterM_Angry_black_panther.png"] ];
-
-function index(column, row) {
- return column + (row * maxColumn);
-}
+var animals = [ "ArtFavor_Cartoon_Sheep.png", "danko_Friendly_rabbit.png",
+ "lemmling_Cartoon_cow.png", "PeterM_Sad_cat.png",
+ "bugmenot_Happy_Pig.png", "Gerald_G_Crawfish.png",
+ "Machovka_lady_bug.png", "carlitos_Green_Worm.png",
+ "Gerald_G_Rubber_Duck.png", "molumen_Green_sitting_frog.png"]
function createBoard() {
var currentTime = new Date();
@@ -30,20 +17,16 @@ function createBoard() {
Math.random(seed);
for (var i = 0; i < maxIndex; i++) {
- order[i] = i;
+ positions[i] = i;
+ var position = Math.floor(Math.random()*positions.length);
+ var tmp = positions[i];
+ positions[i] = positions[position];
+ positions[position] = tmp;
}
- for (var i = 0; i < maxIndex; i++) {
- var position = Math.floor(Math.random()*order.length);
- var tmp = order[i];
- order[i] = order[position];
- order[position] = tmp;
- }
- for (var i = 0; i < maxIndex; i++) {
-
- //console.log(" create:" + i + ": " + order[i], animals[i][1]);
-
- var animal = createAnimal(animals[order[i]][1], animals[order[i]][0], i%maxColumn, i%maxRow);
+ for (var i = 0; i < maxIndex/2; i++) {
+ createAnimal(animals[i], i, positions[i*2]%maxColumn, Math.floor(positions[i*2]/maxColumn));
+ createAnimal(animals[i], i, positions[i*2+1]%maxColumn, Math.floor(positions[i*2+1]/maxColumn));
}
}
@@ -56,7 +39,6 @@ function createAnimal(image, animalId, column, row) {
if (dynamicObject == null) {
console.log("error creating block");
console.log(component.errorString());
- return false;
}
dynamicObject.type = animalId;
dynamicObject.image = "images/" + image;
@@ -67,9 +49,7 @@ function createAnimal(image, animalId, column, row) {
} else {
console.log("error loading block component");
console.log(component.errorString());
- return false;
}
- return true;
}
function finishedTiles(a1, a2) {
diff --git a/animals/memory.qml b/animals/memory.qml
index e70c762..583be7f 100644
--- a/animals/memory.qml
+++ b/animals/memory.qml
@@ -6,7 +6,7 @@ import "memory.js" as MemoryLogic
Rectangle {
Component.onCompleted: MemoryLogic.createBoard();
- width: 600
+ width: 1200
height: 500
id: gameBoard