bjorn 9 years ago
parent
commit
09532cc524
5 changed files with 27 additions and 20 deletions
  1. 11 10
      app/block.lua
  2. 2 1
      app/mobile.lua
  3. 9 4
      app/shape.lua
  4. 2 1
      app/shapematch.lua
  5. 3 4
      app/sleep.lua

+ 11 - 10
app/block.lua

@@ -5,49 +5,50 @@ local textures = {
 }
 
 local cubeFace = lovr.graphics.newBuffer({
-  { -.5, .5, 0, 0,0,0, 0, 0 },
-  { .5, .5, 0, 0,0,0, 1, 0 },
-  { -.5, -.5, 0, 0,0,0, 0, 1 },
-  { .5, -.5, 0, 0,0,0, 1, 1 }
+  { -.25, .25, 0, 0,0,0, 0, 0 },
+  { .25, .25, 0, 0,0,0, 1, 0 },
+  { -.25, -.25, 0, 0,0,0, 0, 1 },
+  { .25, -.25, 0, 0,0,0, 1, 1 }
 }, 'strip')
 
 -- DAMMIT
 return function(letter)
+  g.setColor(255, 255, 255)
   cubeFace:setTexture(textures[letter])
 
   g.push()
   g.rotate(0, 0, 1, 0)
-  g.translate(0, 0, .5)
+  g.translate(0, 0, .25)
   cubeFace:draw()
   g.pop()
 
   g.push()
   g.rotate(math.pi / 2, 0, 1, 0)
-  g.translate(0, 0, .5)
+  g.translate(0, 0, .25)
   cubeFace:draw()
   g.pop()
 
   g.push()
   g.rotate(math.pi, 0, 1, 0)
-  g.translate(0, 0, .5)
+  g.translate(0, 0, .25)
   cubeFace:draw()
   g.pop()
 
   g.push()
   g.rotate(3 * math.pi / 2, 0, 1, 0)
-  g.translate(0, 0, .5)
+  g.translate(0, 0, .25)
   cubeFace:draw()
   g.pop()
 
   g.push()
   g.rotate(math.pi / 2, 1, 0, 0)
-  g.translate(0, 0, .5)
+  g.translate(0, 0, .25)
   cubeFace:draw()
   g.pop()
 
   g.push()
   g.rotate(-math.pi / 2, 1, 0, 0)
-  g.translate(0, 0, .5)
+  g.translate(0, 0, .25)
   cubeFace:draw()
   g.pop()
 end

+ 2 - 1
app/mobile.lua

@@ -1,6 +1,7 @@
 local controllers = require 'app/controllers'
 local cry = require 'app/cry'
 local sleep = require 'app/sleep'
+local play = require 'app/play'
 local vec3 = require('lib/cpml').vec3
 local mat4 = require('lib/cpml').mat4
 
@@ -45,7 +46,7 @@ function mobile:init()
       angle = 0,
       model = lovr.graphics.newModel('art/mobile_balloon.obj'),
       color = { 0, 200, 200 },
-      target = sleep
+      target = play
     }
   }
 

+ 9 - 4
app/shape.lua

@@ -4,6 +4,12 @@ shape.__index = shape
 local vec3 = require('lib/cpml').vec3
 local quat = require('lib/cpml').quat
 
+local squareModel = lovr.graphics.newModel('art/duck.dae')
+squareModel:setTexture(lovr.graphics.newTexture('art/duck.tga'))
+
+local circleModel = lovr.graphics.newModel('art/mobile_plane.obj')
+circleModel:setTexture(lovr.graphics.newTexture('art/mobile_DIFF.png'))
+
 function shape.grow(position, type)
   local self = {}
 
@@ -11,12 +17,11 @@ function shape.grow(position, type)
   self.position = position
 
   if self.type == 'square' then
-    self.model = lovr.graphics.newModel('art/duck.dae')
-    self.model:setTexture(lovr.graphics.newTexture('art/duck.tga'))
+    self.model = squareModel
   else
-    self.model = lovr.graphics.newModel('art/mobile_plane.obj')
-    self.model:setTexture(lovr.graphics.newTexture('art/mobile_DIFF.png'))
+    self.model = circleModel
   end
+
   self.direction = vec3(0, 0, 0) - position -- player position - my postiion
   self.speed = _.random(.15, .2)
   local quat = quat.from_direction(self.direction, vec3(0, 1, 0))

+ 2 - 1
app/shapematch.lua

@@ -38,6 +38,7 @@ end
 function play:update(dt)
   rattle:update(dt)
   self.currentShape = self.shapes[1]
+  self.correctHole = self.currentShape and self.holes[self.currentShape.type]
 
   _.each(self.shapes, 'update', dt)
 
@@ -126,7 +127,7 @@ function play:setHoles()
       maxX = 1,
       minZ = -1,
       maxZ = 1,
-      color = { 0, 0, 245 }
+      color = { 255, 0, 245 }
     }
   }
 end

+ 3 - 4
app/sleep.lua

@@ -21,7 +21,7 @@ function sleep:init()
   self.block = {}
   self.block.maxY = 6
   self.block.position = vec3(0, self.block.maxY, 0)
-  self.block.size = .4
+  self.block.size = .5
 
   self.transitionFactor = 0
 
@@ -34,9 +34,8 @@ function sleep:update(dt)
   -- Logic
   if rattle.isShaking then
     local x, y, z = lovr.headset.getPosition()
-    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)
+    local factor = (1 - _.clamp(y / 2.2, 0, 1)) ^ 2
+    self.block.position.y = math.max(self.block.position.y - dt * factor * 2, .5)
   else
     self.block.position.y = math.min(self.block.position.y + dt * .5, self.block.maxY)
   end