Browse Source

balancing sleep;

sophia 9 years ago
parent
commit
c994b2f5ea
1 changed files with 4 additions and 3 deletions
  1. 4 3
      app/sleep.lua

+ 4 - 3
app/sleep.lua

@@ -19,7 +19,7 @@ function sleep:init()
   self.floor = g.newBuffer(lovr.headset.getBoundsGeometry())
 
   self.block = {}
-  self.block.maxY = 10
+  self.block.maxY = 6
   self.block.position = vec3(0, self.block.maxY, 0)
   self.block.size = .4
 
@@ -34,8 +34,9 @@ function sleep:update(dt)
   -- Logic
   if rattle.isShaking then
     local x, y, z = lovr.headset.getPosition()
-    local factor = (1 - _.clamp(y / 2, 0, 1)) ^ 2
-    self.block.position.y = math.max(self.block.position.y - dt * factor * 2, 1)
+    local factor = (_.clamp(y / 2, 0, 1)) ^ 2
+    local lowestPoint = .5 + self.block.maxY * .75 * factor
+    self.block.position.y = math.max(self.block.position.y - dt * factor * 2, lowestPoint)
   else
     self.block.position.y = math.min(self.block.position.y + dt * .5, self.block.maxY)
   end