|
@@ -1,5 +1,6 @@
|
|
import QtQuick 2.5
|
|
import QtQuick 2.5
|
|
import QtQuick.Window 2.2
|
|
import QtQuick.Window 2.2
|
|
|
|
+import Qt.labs.settings 1.0
|
|
import Box2D 2.0
|
|
import Box2D 2.0
|
|
|
|
|
|
Window {
|
|
Window {
|
|
@@ -9,8 +10,14 @@ Window {
|
|
width: 1024
|
|
width: 1024
|
|
height: 768
|
|
height: 768
|
|
|
|
|
|
- property int columnCount: 4
|
|
|
|
- property int interval: 5
|
|
|
|
|
|
+ Settings {
|
|
|
|
+ id: settings
|
|
|
|
+ property int columnCount: 4
|
|
|
|
+ property int interval: 30
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ signal pause
|
|
|
|
+ signal next
|
|
|
|
|
|
Component {
|
|
Component {
|
|
id: pictureComponent
|
|
id: pictureComponent
|
|
@@ -28,6 +35,7 @@ Window {
|
|
bodyType: Body.Dynamic
|
|
bodyType: Body.Dynamic
|
|
source: "file://" + imageModel.randomPicture()
|
|
source: "file://" + imageModel.randomPicture()
|
|
//restitution: 0.0
|
|
//restitution: 0.0
|
|
|
|
+ onXChanged: x = 0
|
|
SequentialAnimation {
|
|
SequentialAnimation {
|
|
id: destroyAnimation
|
|
id: destroyAnimation
|
|
ScriptAction { script: { picture.destroy(); } }
|
|
ScriptAction { script: { picture.destroy(); } }
|
|
@@ -41,7 +49,7 @@ Window {
|
|
Item {
|
|
Item {
|
|
id: column
|
|
id: column
|
|
x: width * index
|
|
x: width * index
|
|
- width: parent.width/columnCount
|
|
|
|
|
|
+ width: parent.width/settings.columnCount
|
|
|
|
|
|
anchors { top: parent.top; bottom: parent.bottom }
|
|
anchors { top: parent.top; bottom: parent.bottom }
|
|
|
|
|
|
@@ -66,21 +74,27 @@ Window {
|
|
id: feedTimer
|
|
id: feedTimer
|
|
running: true
|
|
running: true
|
|
repeat: true
|
|
repeat: true
|
|
- interval: 1000*(root.interval > 60 ? 60*(root.interval-60) : root.interval)
|
|
|
|
|
|
+ interval: 1000*(settings.interval > 60 ? 60*(settings.interval-60) : settings.interval)*(Math.random()+1)
|
|
onTriggered: {
|
|
onTriggered: {
|
|
pictureArray.push(pictureComponent.createObject(column, { y: -2000 }))
|
|
pictureArray.push(pictureComponent.createObject(column, { y: -2000 }))
|
|
- if (pictureArray.length > root.columnCount) {
|
|
|
|
|
|
+ if (pictureArray.length > settings.columnCount) {
|
|
pictureArray.shift().detonate()
|
|
pictureArray.shift().detonate()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ Connections {
|
|
|
|
+ target: root
|
|
|
|
+ onPause: feedTimer.running = !feedTimer.running
|
|
|
|
+ onNext: feedTimer.triggered()
|
|
|
|
+ }
|
|
|
|
+
|
|
Timer {
|
|
Timer {
|
|
id: initialPopulation
|
|
id: initialPopulation
|
|
|
|
|
|
property int runCount: 0
|
|
property int runCount: 0
|
|
interval: 500
|
|
interval: 500
|
|
- running: runCount < root.columnCount
|
|
|
|
|
|
+ running: runCount < settings.columnCount
|
|
repeat: true
|
|
repeat: true
|
|
onTriggered: {
|
|
onTriggered: {
|
|
runCount = runCount + 1;
|
|
runCount = runCount + 1;
|
|
@@ -91,11 +105,17 @@ Window {
|
|
}
|
|
}
|
|
|
|
|
|
Rectangle {
|
|
Rectangle {
|
|
|
|
+ focus: true
|
|
color: "black"
|
|
color: "black"
|
|
anchors.fill: parent
|
|
anchors.fill: parent
|
|
Repeater {
|
|
Repeater {
|
|
- model: columnCount
|
|
|
|
|
|
+ model: settings.columnCount
|
|
delegate: columnComponent
|
|
delegate: columnComponent
|
|
}
|
|
}
|
|
|
|
+ Keys.onLeftPressed: settings.columnCount = Math.max(settings.columnCount-1,1)
|
|
|
|
+ Keys.onRightPressed: settings.columnCount++
|
|
|
|
+ Keys.onUpPressed: root.pause()
|
|
|
|
+ Keys.onDownPressed: root.next()
|
|
}
|
|
}
|
|
|
|
+
|
|
}
|
|
}
|