Эх сурвалжийг харах

Reintroduce column based worlds for a purer experience

Cumulative wiggle is a mofo

Change-Id: I24c5fd359bd2faaa15514396904e14229f0be145
Donald Carr 9 жил өмнө
parent
commit
e2b5ebbe4f
3 өөрчлөгдсөн 37 нэмэгдсэн , 14 устгасан
  1. 3 4
      qml/ArtDelegate.qml
  2. 33 10
      qml/Gravity.qml
  3. 1 0
      qml/main.qml

+ 3 - 4
qml/ArtDelegate.qml

@@ -8,15 +8,14 @@ ImageBoxBody {
     signal beyondThePale(var item)
 
     onYChanged:
-        if (y > floor.y)
+        if (y > globalFloor.y)
             beyondThePale(this)
 
-    density: 10
+    density: 1.0
     friction: 0
-    restitution: 0.2
+    restitution: 0.1
 
     fixedRotation: parent.fixedRotation
-    world: parent.physicsWorld
     bodyType: Body.Dynamic
 
     source: imageModel.randomPicture()

+ 33 - 10
qml/Gravity.qml

@@ -20,6 +20,7 @@ Item {
         property int primedColumns: 0
         property int columnCount: settings.columnCount
         property bool running: primedColumns >= columnCount
+        property bool globalWorld: settings.globalWorld
 
         function reset() {
             itemCount = 0
@@ -32,13 +33,13 @@ Item {
     World {
         id: bullshitWorld
         timeStep: d.pace
-        running: d.running
+        running: d.globalWorld && d.running
     }
 
     World {
         id: commonWorld
         timeStep: d.pace
-        running: d.running
+        running: d.globalWorld && d.running
     }
 
     Component {
@@ -49,6 +50,7 @@ Item {
 
             property int stackHeight: 0
             property bool full: false
+            property int xOffset: width * index
 
             onStackHeightChanged: {
                 if (!column.full && (stackHeight > root.height)) {
@@ -57,11 +59,18 @@ Item {
                 }
             }
 
+            function considerImage() {
+                if (stackHeight < (1.3 + 1/d.columnCount)*root.height) {
+                    addImage()
+                }
+            }
+
             function addImage() {
                 var item = pictureDelegate.createObject(column, { x: -1000, y: -1000 })
                 item.beyondThePale.connect(removeImage)
                 stackHeight += (item.height + d.itemTravel)
-                item.x = width * index
+                item.world = d.globalWorld ? commonWorld : columnWorld
+                item.x = xOffset
                 item.y = floor.y - stackHeight
                 d.itemCount++
                 pictureArray.push(item)
@@ -78,17 +87,32 @@ Item {
             anchors { top: parent.top; bottom: parent.bottom }
 
             property var pictureArray: []
-            property var physicsWorld: commonWorld
             property bool fixedRotation: true
 
+            World {
+                id: columnWorld
+                timeStep: d.pace
+                running: !d.globalWorld && d.running
+            }
+
+            RectangleBoxBody {
+                id: floor
+                world: columnWorld
+                height: 0
+                width: parent.width
+                x: xOffset
+                anchors {
+                    top: parent.bottom
+                }
+                friction: 1
+            }
+
             Timer {
                 id: pumpTimer
                 interval: Math.random()*500 + 500
                 repeat: true
-                running: !full
-                onTriggered: {
-                    addImage()
-                }
+                running: true
+                onTriggered: considerImage()
             }
 
             Timer {
@@ -123,7 +147,7 @@ Item {
 
     // floor
     RectangleBoxBody {
-        id: floor
+        id: globalFloor
         world: commonWorld
         height: 0
         anchors {
@@ -132,7 +156,6 @@ Item {
             top: parent.bottom
         }
         friction: 1
-        density: 1
     }
 
     DebugDraw {

+ 1 - 0
qml/main.qml

@@ -17,6 +17,7 @@ Window {
         property int interval: 2
         property double pace: 1.0
         property bool viewItemCount: false
+        property bool globalWorld: false
     }
 
     Rectangle {