Quellcode durchsuchen

Introduce travel factor

Items are still more prone to falling through each other now

Change-Id: I57c7ecbf44c30de4cd3789ad209e5b04ce769e07
Donald Carr vor 9 Jahren
Ursprung
Commit
0f38284404
2 geänderte Dateien mit 6 neuen und 5 gelöschten Zeilen
  1. 4 4
      qml/Gravity.qml
  2. 2 1
      qml/main.qml

+ 4 - 4
qml/Gravity.qml

@@ -16,6 +16,7 @@ Item {
         id: d
         property double pace: settings.pace/60.0
         property int itemCount: 0
+        property int itemTravel: settings.itemTravel
         property int primedColumns: 0
         property int columnCount: settings.columnCount
         property bool running: primedColumns >= columnCount
@@ -35,7 +36,6 @@ Item {
     }
 
     World {
-        // Global world at odds with relative positions!
         id: commonWorld
         timeStep: d.pace
         running: d.running
@@ -60,8 +60,8 @@ Item {
             function addImage() {
                 if (columnHeight < (1.1+1/d.columnCount)*root.height) {
                     var item = pictureDelegate.createObject(column)
-                    columnHeight += item.height
-                    item.y = (floor.y - 1) - columnHeight
+                    columnHeight += (item.height + d.itemTravel)
+                    item.y = floor.y - columnHeight
                     d.itemCount++
                     pictureArray.push(item)
                 }
@@ -116,7 +116,7 @@ Item {
                         image.world = bullshitWorld
                         image.freefall = true
                         d.itemCount--
-                        columnHeight -= image.height
+                        columnHeight -= (image.height + d.itemTravel)
                     }
                 }
             }

+ 2 - 1
qml/main.qml

@@ -12,6 +12,7 @@ Window {
 
     Settings {
         id: settings
+        property int itemTravel: 2
         property int columnCount: 30
         property int interval: 2
         property bool fitByHeight: false
@@ -39,7 +40,7 @@ Window {
     }
 
     Rectangle {
-        visible: imageModel.rowCount() == 0
+        visible: imageModel.rowCount() === 0
         color: "red"
         width: childrenRect.width
         height: childrenRect.height