bjorn преди 9 години
родител
ревизия
fc4c8dacfa
променени са 10 файла, в които са добавени 49 реда и са изтрити 42 реда
  1. 1 1
      app/abilities/burst.lua
  2. 1 1
      app/abilities/fear.lua
  3. 12 10
      app/abilities/manager.lua
  4. 2 1
      app/enemies/spuju/config.lua
  5. 11 10
      app/hud/game.lua
  6. 1 1
      app/scenes/overgrowth.lua
  7. 1 1
      conf.lua
  8. 3 3
      lib/spuju.lua
  9. 1 1
      lib/view.lua
  10. 16 13
      main.lua

+ 1 - 1
app/abilities/burst.lua

@@ -3,7 +3,7 @@ local burst = lib.object.create():include(lib.ability)
 burst.cooldown = 3
 burst.cost = 1
 burst.range = 150
-burst.damage = 3
+burst.damage = 2
 
 function burst:canCast(owner)
   return util.isa(owner, app.minions.bruju.object) and not self:isOnCooldown() and self:canPayJuju()

+ 1 - 1
app/abilities/fear.lua

@@ -1,6 +1,6 @@
 local fear = lib.object.create():include(lib.ability)
 
-fear.cooldown = 10
+fear.cooldown = 12
 
 function fear:canCast()
   return not self:isOnCooldown()

+ 12 - 10
app/abilities/manager.lua

@@ -64,10 +64,9 @@ function abilities:bind()
         return love.touchreleased
           :filter(f.eq(id))
           :take(1)
-          :map(f.val(id))
       end)
-      :subscribe(function(id)
-        local mx, my = app.context.view:worldPoint(love.touch.getPosition(id))
+      :subscribe(function(id, x, y)
+        local mx, my = app.context.view:worldPoint(x, y)
         local cast = self.casts[id]
 
         if not cast then return end
@@ -90,8 +89,8 @@ function abilities:bind()
       end),
 
     love.touchreleased
-      :filter(function()
-        local casting = util.match(self.casts, function(cast) return cast.active end)
+      :filter(function(id)
+        local casting = util.match(self.casts, function(cast) return cast.active and cast.id == id end)
         return self.selected and not casting
       end)
       :subscribe(function()
@@ -122,10 +121,9 @@ function abilities:bind()
         return love.touchreleased
           :filter(f.eq(id))
           :take(1)
-          :map(f.val(id))
       end)
-      :subscribe(function(id)
-        local mx, my = app.context.view:worldPoint(love.touch.getPosition(id))
+      :subscribe(function(id, x, y)
+        local mx, my = app.context.view:worldPoint(x, y)
         local cast = self.casts[id]
 
         if not cast then return end
@@ -159,14 +157,18 @@ function abilities:draw()
       local ox, oy = cast.owner.position.x, cast.owner.position.y
       local points = {}
       local radius = 35
-      local tx, ty = app.context.view:worldPoint(love.touch.getPosition(cast.id))
+      local tx, ty
 
-      if not cast.active then
+      if cast.active and (util.find(love.touch.getTouches(), cast.id) or cast.id == 'm') then
+        tx, ty = app.context.view:worldPoint(love.touch.getPosition(cast.id))
+      else
         radius = radius + 20 * (1 - cast.factor)
         tx = cast.x
         ty = cast.y
       end
 
+      if not tx or not ty then return end
+
       local entity = lib.target.objectAtPosition(tx, ty)
       if entity and entity.isEnemy then
         tx = util.lerp(tx, entity.position.x, .5)

+ 2 - 1
app/enemies/spuju/config.lua

@@ -9,5 +9,6 @@ return {
   shape = 'ellipse',
   perspective = 2,
   damage = 1,
-  skullCount = 2
+  skullCount = 2,
+  attackCooldown = 5
 }

+ 11 - 10
app/hud/game.lua

@@ -39,7 +39,7 @@ function hud:bind()
             :take(1)
         )
         :max()
-        :filter(function(d) return d < 16 end)
+        :filter(function(d) return d < 64 end)
         :map(function()
           return ox, oy
         end)
@@ -264,7 +264,14 @@ function hud:drawAbilities()
   local x = u / 2 - (inc * (count - 1) / 2)
 
   for i = 1, count do
-    g.setColor(0, 0, 0, 100 + 80 * self.abilityFactor[i])
+    local ability = abilities.list[i]
+    local image = app.art.icons[ability.tag]
+    local w, h = image:getDimensions()
+
+    local cost = ability:getCost()
+    local canAfford = not cost or p.juju >= cost
+
+    g.setColor(0, 0, 0, (100 + 80 * self.abilityFactor[i]) * (canAfford and 1 or .5))
     g.rectangle('fill', x - size / 2, v - 8 - size, size, size)
 
     if app.context.abilities.selected == abilities.list[i] then
@@ -274,13 +281,9 @@ function hud:drawAbilities()
       g.setLineWidth(1)
     end
 
-    local ability = abilities.list[i]
-    local image = app.art.icons[ability.tag]
-    local w, h = image:getDimensions()
-
     local scale = (size * .75) / ((w > h) and w or h)
 
-    g.white(200 + 55 * self.abilityFactor[i])
+    g.white((200 + 55 * self.abilityFactor[i]) * (canAfford and 1 or .5))
     g.draw(image, x, v - 8 - size / 2, 0, scale, scale, w / 2, h / 2)
 
     if ability:isOnCooldown() then
@@ -289,15 +292,13 @@ function hud:drawAbilities()
       g.rectangle('fill', x - size / 2, v - 8 - size + size * (1 - cooldown), size, size * cooldown)
     end
 
-    local cost = ability:getCost()
-
     if cost then
       g.setFont(self.smallFont)
       local image = app.art.juju
       local scale = .02 * v / image:getWidth()
       local padding = .01 * v
       local totalWidth = image:getWidth() * scale + padding + g.getFont():getWidth(cost)
-      g.white(p.juju >= cost and 255 or 120)
+      g.white(canAfford and 255 or 120)
       g.draw(image, x - totalWidth / 2, v - 8 - size - .03 * v, 0, scale, scale)
       g.white()
       g.print(cost, x - totalWidth / 2 + image:getWidth() * scale + padding, v - 8 - size - .03 * v)

+ 1 - 1
app/scenes/overgrowth.lua

@@ -2,7 +2,7 @@ local overgrowth = {}
 
 overgrowth.name = 'The Overgrowth'
 overgrowth.width = 960
-overgrowth.height = 540
+overgrowth.height = 720
 
 local w, h = overgrowth.width, overgrowth.height
 

+ 1 - 1
conf.lua

@@ -1,6 +1,6 @@
 function love.conf(t)
   t.window.width = 960
-  t.window.height = 540
+  t.window.height = 720
   t.window.resizable = true
   t.window.msaa = 8
   t.window.highdpi = true

+ 3 - 3
lib/spuju.lua

@@ -21,20 +21,20 @@ function spuju:move()
       self.abilities.fear:cast(self, x, y)
       self.animation:set('fear')
       self.state = 'fear'
-    elseif not self.lastAttack or (lib.tick.index - self.lastAttack) * lib.tick.rate >= 5 then
+    elseif not self.lastAttack or (lib.tick.index - self.lastAttack) * lib.tick.rate >= self.config.attackCooldown then
       self.animation:set('attack')
       self.state = 'attack'
     end
   elseif not isInRange then
     self.animation:set('walk')
     self.targetDirection = directionToTarget
-    self.direction = util.anglerp(self.direction, self.targetDirection, lib.tick.getLerpFactor(.1))
+    self.direction = util.anglerp(self.direction, self.targetDirection, lib.tick.getLerpFactor(.05))
 
     self:moveInDirection(self.direction, self.config.speed)
   else
     local flip = (math.floor(lib.tick.index * lib.tick.rate / 2) % 2) == 0
     self.targetDirection = flip and (directionToTarget + math.pi * .5) or (directionToTarget - math.pi * .5)
-    self.direction = util.anglerp(self.direction, self.targetDirection, lib.tick.getLerpFactor(.1))
+    self.direction = util.anglerp(self.direction, self.targetDirection, lib.tick.getLerpFactor(.05))
     self:moveInDirection(self.direction, self.config.speed / 2)
   end
 

+ 1 - 1
lib/view.lua

@@ -4,7 +4,7 @@ function view:init()
   self.x = 0
   self.y = 0
   self.width = 960
-  self.height = 540
+  self.height = 720
   self.xmin = -math.huge
   self.ymin = -math.huge
   self.xmax = math.huge--self.width

+ 16 - 13
main.lua

@@ -45,20 +45,23 @@ love.keypressed
     app.context.load('overgrowth')
   end)
 
-love.mousepressed:subscribe(function(x, y)
-  love.touchpressed('m', x, y)
-end)
+local os = love.system.getOS()
+if os ~= 'Android' and os ~= 'iOS' then
+  love.mousepressed:subscribe(function(x, y)
+    love.touchpressed('m', x, y)
+  end)
 
-love.mousemoved:subscribe(function(x, y)
-  love.touchmoved('m', x, y)
-end)
+  love.mousemoved:subscribe(function(x, y)
+    love.touchmoved('m', x, y)
+  end)
 
-love.mousereleased:subscribe(function(x, y)
-  love.touchreleased('m', x, y)
-end)
+  love.mousereleased:subscribe(function(x, y)
+    love.touchreleased('m', x, y)
+  end)
 
-local getTouchPosition = love.touch.getPosition
-love.touch.getPosition = function(id)
-  if id == 'm' then return love.mouse.getPosition() end
-  return love.touch.getPosition(id)
+  local getTouchPosition = love.touch.getPosition
+  love.touch.getPosition = function(id)
+    if id == 'm' then return love.mouse.getPosition() end
+    return love.touch.getPosition(id)
+  end
 end