1. benbeltran
  2. Cows

Commits

benbeltran  committed 55aef93

Working status @ broken macbook (recovery)

  • Participants
  • Parent commits d0607a8
  • Branches master

Comments (0)

Files changed (30)

File actors/actor.lua

View file
 end
 
 function Actor:physics(dt)
+  --move in y
+  self:fall(dt)
+  self.y = math.floor(self.y + self.y_vel)
+  self:unstick("y")
+  self:fall(dt)
+
   --move in x
   self:accelerate(dt)
   self:deccelerate(dt)
+  self:unstick("x")
 
   -- My own movements
   if self.dir == "right" then
   self:accelerate(dt)
   self:deccelerate(dt)
   self:unstick("x")
-
-  --move in y
-  self:fall(dt)
-  self.y = math.floor(self.y + self.y_vel)
-  self:fall(dt)
-  self:unstick("y")
 end
 
 function Actor:get_friction()
 function Actor:unstick(context)
   if context == "y" then
     -- Half speed on bump
-    if not self:can_pass("up", self.x, self.y+1, true) and self.y_vel > 0 then
+    if not self:can_pass("up", self.x, self.y, true) and self.y_vel > 0 then
       self.y_vel = self.y_vel/2
     end
 
-    while not self:can_pass("down", self.x, self.y-1, true) do
+    while not self:can_pass("down", self.x, self.y, true) do
       self.y = self.y-1
+      self.fall_time = 0
     end
-    while not self:can_pass("up", self.x, self.y+1, true) do
-      self.y = self.y+1
-    end
+--    while not self:can_pass("up", self.x, self.y, true) do
+--      self.y = self.y+1
+--    end
   end
 
   if context == "x" then
-    while not self:can_pass("right", self.x+1, self.y, true) do
+    while not self:can_pass("right", self.x, self.y, true) do
       if self.x_vel > 0 then
         self.x_vel = 0
       end
       self.x = self.x-1
     end
 
-    while not self:can_pass("left", self.x-1, self.y, true) do
+    while not self:can_pass("left", self.x, self.y, true) do
       if self.x_vel < 0 then
         self.x_vel = 0
       end
   end
 end
 
-function Actor:get_tile(side, val)
+function Actor:get_tile(context, val)
   local mapsys = game.map_manager
 
-  if side == "x1" then
-    return math.floor( (val - self:box_side("left")) / mapsys.map.tileWidth)
-  end
-
-  if side == "x2" then
-    return math.floor( (val + self:box_side("right")) / mapsys.map.tileWidth)
-  end
-
-  if side == "y1" then
-    return math.floor( (val - self:box_side("top")) / mapsys.map.tileHeight)
-  end
-
-  if side == "y2" then
-    return math.floor( (val + self:box_side("bottom")) / mapsys.map.tileHeight)
-  end
-
-  if side == "x" then
+  if context == "x" then
     return math.floor(val / mapsys.map.tileWidth)
   end
 
-  if side == "y" then
+  if context == "y" then
     return math.floor(val / mapsys.map.tileHeight)
   end
 end
 
-function Actor:can_pass(direction, x, y, skip_objects)
-
-  local mapsys = game.map_manager
+function Actor:can_pass(direction, skip_objects)
 
-  x = x or self.x
-  y = y or self.y
+  local mapsys = game.map_manager,
+        tiles
 
-  --the padding to check
-  padding = 2
+  local left = self.x - self:box_side("left")
+  local right = self.x + self:box_side("right")
+  local top = self.y - self:box_side("top")
+  local bottom = self.y + self:box_side("bottom")
 
-  local tiles = mapsys.map("Collision")
+  tiles = mapsys.map("Collision")
 
   if direction == "up" then
 
     end
 
     --get the tiles for this direction
-    local tile_x1 = self:get_tile("x1", x+padding)
-    local tile_x2 = self:get_tile("x2", x-padding)
-    local tile_y1 = self:get_tile("y1", y)
+    local from_tile = self:get_tile("x", left)
+    local to_tile = self:get_tile("x", right)
+    local roof_tile = self:get_tile("y", top-1)
+    local current_tile = nil
 
     --loop from x1 to x2, and check with y1
-    for i=tile_x1,tile_x2,1 do
-      if tiles:get(i, tile_y1) then
-        if tiles:get(i, tile_y1).properties.passable == 0 then
+    for i=from_tile,to_tile,1 do
+      current_tile = tiles:get(i, roof_tile)
+      if current_tile and current_tile.properties.passable == 0 then
+        if not current_tile.properties.slope then
           return false
         end
       end
     end
 
     --test edge of roof
-    if y <= 0 then
+    if bottom <= 0 then
       return false
     end
   end
     end
 
     --get the tiles for this direction
-    local tile_x1 = self:get_tile("x1", x+padding)
-    local tile_x2 = self:get_tile("x2", x-padding)
-    local tile_y2 = self:get_tile("y2", y)
-    local tile = nil
-    local slope = nil
-    local difference = nil
+    local from_tile = self:get_tile("x", left)
+    local to_tile = self:get_tile("x", right)
+    local floor_tile = self:get_tile("y", bottom+1)
+    local current_tile = nil
 
     --loop from x1 to x2, and check with y2
-    for i=tile_x1,tile_x2,1 do
-      if tiles:get(i, tile_y2) then
-        tile = tiles:get(i, tile_y2)
-        slope = tile.properties.slope
-        if tile.properties.passable == 0 then
-
-          if slope == "down" then
-            difference   = (x + 1 - self:box_side("left") - (tile_x1*16))
-            if y + self:box_side("bottom") >= (tile_y2*16) + difference -1 then
-              return false
-            else
-              return true
-            end
-          end
-
-          if slope == "up" then
-            new_diff = (x + self:box_side("right")) % 16
-            difference   =  16 - (x - 1 + self:box_side("right") - ((tile_x2)*16))
-            beetle.update("Guy", "diff: "..difference.."; newdiff: "..new_diff.."; base_y: "..(tile_y2*16).."; current_y: "..(y+self:box_side("bottom")))
-            if y + self:box_side("bottom") >= (tile_y2*16) + difference then
-              return false
-            else
-              return true
-            end
+    for i=from_tile,to_tile,1 do
+      current_tile = tiles:get(i, floor_tile)
+      if current_tile and current_tile.properties.passable == 0 then
+        if current_tile.properties.slope then
+          if not self:_can_pass_slope(current_tile, i, floor_tile) then
+            return false
           end
-
-          return false
-        end
-        if tile.properties.passable == 2 and
-          self.y_vel >= 0 and
-          self.y + self.box.bottom <= tile_y2 * mapsys.map.tileHeight + 12 + self.y_vel then
+        else
           return false
         end
       end
+
+      if current_tile and current_tile.properties.passable == 2 and
+        self.y_vel >= 0 and
+        bottom <= floor_tile * mapsys.map.tileHeight + 12 + self.y_vel then
+        return false
+      end
     end
 
     --test edge of floor
-    if y >= mapsys.map.height * mapsys.map.tileHeight then
+    if top >= mapsys.map.height * mapsys.map.tileHeight then
       return false
     end
   end
     end
 
     --get the tiles for this direction
-    local tile_x1 = self:get_tile("x1", x)
-    local tile_y1 = self:get_tile("y1", y+padding)
-    local tile_y2 = self:get_tile("y2", y-padding)
-    local slope = nil
+    local from_tile = self:get_tile("y", top)
+    local to_tile = self:get_tile("y", bottom)
+    local wall_tile = self:get_tile("x", left)
+    local current_tile = nil
 
     --loop from y1 to y2, and check with x1
-    for i=tile_y1,tile_y2,1 do
-      if tiles:get(tile_x1, i) then
-        if tiles:get(tile_x1, i).properties.passable == 0 then
-          slope = tiles:get(tile_x1, i).properties.slope
-          if slope == "down" or slope == "up" then
-            return true
-          else
-            return false
-          end
+    for i=from_tile,to_tile,1 do
+      current_tile = tiles:get(wall_tile, i)
+      if current_tile and current_tile.properties.passable == 0 then
+        if not current_tile.properties.slope then
+          return false
         end
       end
     end
 
     --test left wall
-    if x <= 0 then
+    if left <= 0 then
       return false
     end
   end
     end
 
     --get the tiles for this direction
-    local tile_x2 = self:get_tile("x2", x)
-    local tile_y1 = self:get_tile("y1", y+padding)
-    local tile_y2 = self:get_tile("y2", y-padding)
-    local slope = nil
+    local from_tile = self:get_tile("y", top)
+    local to_tile = self:get_tile("y", bottom)
+    local wall_tile = self:get_tile("x", right)
+    local current_tile = nil
 
     --loop from y1 to y2, and check with x2
-    for i=tile_y1,tile_y2,1 do
-      if tiles:get(tile_x2, i) then
-        if tiles:get(tile_x2, i).properties.passable == 0 then
-          slope = tiles:get(tile_x2, i).properties.slope
-          if slope == "down" or slope == "up" then
-            return true
-          else
-            return false
-          end
+    for i=to_tile,from_tile,-1 do
+      current_tile = tiles:get(wall_tile, i)
+      if current_tile and current_tile.properties.passable == 0 then
+        if not current_tile.properties.slope then
+          return false
         end
       end
     end
 
     --test edge of roof
-    if x >= mapsys.map.width * mapsys.map.tileWidth then
+    if right >= mapsys.map.width * mapsys.map.tileWidth then
       return false
     end
   end
   end
 end
 
+function Actor:_can_pass_slope(tile, x, y)
+  local left = self.x - self:box_side("left")
+  local right = self.x + self:box_side("right")
+  local bottom = self.y + self:box_side("bottom")
+
+  local tile_left = x*tile.width
+  local tile_right = tile_left + tile.width
+  local tile_top = y*tile.height
+  local tile_bottom = tile_top + tile.height
+
+  local difference = 0
+
+  if tile.properties.slope == "down" then
+    if left < tile_left or left > tile_right then
+      return true
+    end
+    difference = tile_right - left
+    if bottom < tile_bottom - difference then
+      return true
+    end
+  end
+
+  if tile.properties.slope == "up" then
+    if right < tile_left or right >= tile_right then
+      return true
+    end
+    difference = (right - tile_left) + 1
+    if bottom < tile_bottom - difference then
+      return true
+    end
+  end
+
+  return false
+end
+
 return Actor

File actors/player.lua

View file
   survives_map  = true,
   stomach       = {"", "", ""},
   box           = {
-    top   = -12,
-    left  = 12,
-    right = 12,
+    bottom = 30,
+    top    = -12,
+    left   = 12,
+    right  = 12,
   },
   key_times     = {
     up    = 0,
   --regular keyboard / joypad control
   --TODO: Move these "right, left, etc." to a config file. Much laters though.
   --NOTE: Joystick buttons mapped to xbox controller
+  beetle.update("Guy", "x: "..self.x.."; y: "..self.y..";diff: "..(difference or 0))
 
   self:_update_keys()
 
 end
 
 function Player:jump(dt)
-  -- vel calculation
-  if not self.jumplock and self.jump_time < self.max_jump_time and self.fall_time < 0.3 then
-    if not self:can_pass('down') then
-      self.y = self.y-1
-    end
-
-    if not self:can_pass('up') then
-      self:unjump()
-      return
-    end
-
     self.y_vel = -self.jump_strength
-  end
-
     self.jump_time = self.jump_time + dt
 end
 

File animation_controller.lua

View file
+local AnimationController = class('AnimationController')
+
+return AnimationController

File assets/audio/bgm/title.mp3

Binary file modified.

File assets/fonts/PT_Sans-Web-Bold.ttf

Binary file modified.

File assets/fonts/PT_Sans-Web-Regular.ttf

Binary file modified.

File assets/fonts/QuattrocentoSans-Regular.ttf

Binary file modified.

File assets/maps/vf1-altargrounds.tmx

View file
  </layer>
  <layer name="MG" width="200" height="100">
   <data encoding="base64" compression="zlib">
-   eJztnFuP40QQhUuwb2xAQpAECUEnSAgmyyOP/Druu8tN/GFcmhz5dE/idXZmp83k+6RS7KR9iVOnqtrdTgQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACc4oPB3p9hz3qdIEBHvhxsPdh2sJUtb47ru+Py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/wfC//N9vvO/vYy6/lKvd932WN+jxG8/Z90Va1SH0QS8R3cVwDY/fWclu/jluu1/B5yMPEfnx/fq1KfYvPNXz90yv7jB9zsvD72df2P9bGeHs=
   </data>
  </layer>
  <layer name="FG" width="200" height="100">
   <data encoding="base64" compression="zlib">
-   eJzt2DEOABEQBVAnt9xctqMhq8DKe4lyZn5hIhECAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEDr2XRSJ1OcqBnVfukBp6jv7ip54Sz4o3dHvC/cJu0OAABwod7/FAAAAAAAAAAAAACcrACJmiDG
+   eJzt2MEKgCAMAFC/3LQvjw4dAjHq0Ia8B16EuR10A0sBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAALjbglab1FQ/xDzFvjkDMuiDvT0oL2R03tWrt//xNkZ5zRdW0aILAABY0Ox/CgAAAAAAAAAAAAAyOwArUiJN
   </data>
  </layer>
- <layer name="Collision" width="200" height="100">
+ <layer name="Collision" width="200" height="100" visible="0">
   <data encoding="base64" compression="zlib">
    eJzt00EKwkAQRFHPHfTurtzI9CSBxpqY9+AvRRuntgcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMLKdCO7GPqBmH1CzD6jZB9TsA2r2ATX7gJp9QI8zW+ruOfg9r53PdNwz+l4YSe7j+63ubaNrHzbCUel9nO0X98BH+r13v1/7oFP6rV9hH/Z0X+m3vuI+On8Px6TflOxjZen/UPaxsvR/qP/dR/p+aVZa+n5pVlr6fmlWWvp+aVZa+n5JkiRJkiRJmd58ETAO
   </data>

File lib/shaders/bloom.lua

View file
+local math, love = math, love
+
+local function FindSmallestPO2(num)
+   return 2 ^ math.ceil(math.log(num)/math.log(2))
+end
+
+local function ScaleToPO2(xsize, ysize)
+   if love.graphics.isSupported("npot") then return xsize, ysize end
+   return FindSmallestPO2(xsize), FindSmallestPO2(ysize)
+end
+
+-- i've found xsize and ysize of 1/2 - 1/4 the screen resolution to be nice
+-- smaller values make the bloom more apparent and give much better performance, but can make it look bad if too small
+function CreateBloomEffect(xsize, ysize) 
+   if not love.graphics.newPixelEffect
+   or not love.graphics.isSupported
+   or not love.graphics.isSupported("pixeleffect")
+   or not love.graphics.isSupported("canvas") then
+      return
+   end
+   
+   local function newPixelEffect(code)
+      local success, result = pcall(love.graphics.newPixelEffect, code)
+      if success then
+         return result
+      else
+         print("Error compiling shader!\n"..result)
+      end
+   end
+   
+   local bloom = {}
+   
+   local shaders = {
+      blur_vert = [[
+         extern number canvas_h = 256.0;
+         
+         const number offset_1 = 1.3846153846;
+         const number offset_2 = 3.2307692308;
+         
+         const number weight_0 = 0.2270270270;
+         const number weight_1 = 0.3162162162;
+         const number weight_2 = 0.0702702703;
+         
+         vec4 effect(vec4 color, Image texture, vec2 texture_coords, vec2 pixel_coords)
+         {
+            vec4 texcolor = Texel(texture, texture_coords);
+            vec3 tc = texcolor.rgb * weight_0;
+            
+            tc += Texel(texture, texture_coords + vec2(0.0, offset_1)/canvas_h).rgb * weight_1;
+            tc += Texel(texture, texture_coords - vec2(0.0, offset_1)/canvas_h).rgb * weight_1;
+            
+            tc += Texel(texture, texture_coords + vec2(0.0, offset_2)/canvas_h).rgb * weight_2;
+            tc += Texel(texture, texture_coords - vec2(0.0, offset_2)/canvas_h).rgb * weight_2;
+            
+            return color * vec4(tc, 1.0);
+         }
+      ]],
+      blur_horiz = [[
+         extern number canvas_w = 256.0;
+
+         const number offset_1 = 1.3846153846;
+         const number offset_2 = 3.2307692308;
+         
+         const number weight_0 = 0.2270270270;
+         const number weight_1 = 0.3162162162;
+         const number weight_2 = 0.0702702703;
+
+         vec4 effect(vec4 color, Image texture, vec2 texture_coords, vec2 pixel_coords)
+         {
+            vec4 texcolor = Texel(texture, texture_coords);
+            vec3 tc = texcolor.rgb * weight_0;
+            
+            tc += Texel(texture, texture_coords + vec2(offset_1, 0.0)/canvas_w).rgb * weight_1;
+            tc += Texel(texture, texture_coords - vec2(offset_1, 0.0)/canvas_w).rgb * weight_1;
+            
+            tc += Texel(texture, texture_coords + vec2(offset_2, 0.0)/canvas_w).rgb * weight_2;
+            tc += Texel(texture, texture_coords - vec2(offset_2, 0.0)/canvas_w).rgb * weight_2;
+            
+            return color * vec4(tc, 1.0);
+         }
+      ]],
+      bloom = [[
+         extern number threshold = 1.0;
+         
+         float luminance(vec3 color)
+         {
+            // numbers make 'true grey' on most monitors, apparently
+            return (0.212671 * color.r) + (0.715160 * color.g) + (0.072169 * color.b);
+         }
+         
+         vec4 effect(vec4 color, Image texture, vec2 texture_coords, vec2 pixel_coords)
+         {
+            vec4 texcolor = Texel(texture, texture_coords);
+            
+            vec3 extract = smoothstep(threshold * 0.7, threshold, luminance(texcolor.rgb)) * texcolor.rgb;
+            return vec4(extract, 1.0);
+         }
+      ]],
+      
+      combine = [[
+         extern Image bloomtex;
+         
+         extern number basesaturation = 1.0;
+         extern number bloomsaturation = 1.0;
+         
+         extern number baseintensity = 1.0;
+         extern number bloomintensity = 1.0;
+         
+         vec3 AdjustSaturation(vec3 color, number saturation)
+         {
+             vec3 grey = vec3(dot(color, vec3(0.212671, 0.715160, 0.072169)));
+             return mix(grey, color, saturation);
+         }
+      
+         vec4 effect(vec4 color, Image texture, vec2 texture_coords, vec2 pixel_coords)
+         {
+            vec4 basecolor = Texel(texture, texture_coords);
+            vec4 bloomcolor = Texel(bloomtex, texture_coords);
+            
+            bloomcolor.rgb = AdjustSaturation(bloomcolor.rgb, bloomsaturation) * bloomintensity;
+            basecolor.rgb = AdjustSaturation(basecolor.rgb, basesaturation) * baseintensity;
+            
+            basecolor.rgb *= (1.0 - clamp(bloomcolor.rgb, 0.0, 1.0));
+            
+            bloomcolor.a = 0.0;
+            
+            return clamp(basecolor + bloomcolor, 0.0, 1.0);
+         }
+      ]]
+   }
+   
+   for k,v in pairs(shaders) do
+      local shader = newPixelEffect(v)
+      if shader then
+         shaders[k] = shader
+      else
+         return
+      end
+   end
+   
+   if not shaders.blur_vert or not shaders.blur_horiz or not shaders.bloom or not shaders.combine then
+      return
+   end
+
+   
+   local intensity_base, intensity_bloom = 1, 1
+   local saturation_base, saturation_bloom = 1, 1
+   local threshold_bloom = 0.5
+   
+   local debugdraw = false
+   
+   function bloom:refresh(xs, ys)
+      xs, ys = math.floor(xs+0.5), math.floor(ys+0.5)
+      
+      local renderingtoscene = false
+
+      self.xsize, self.ysize = xs, ys
+      
+      self.po2xsize, self.po2ysize = ScaleToPO2(self.xsize, self.ysize) -- scales x and y to next power of 2 if npot is false
+      
+      self.xres, self.yres = love.graphics.getWidth(), love.graphics.getHeight()
+      self.po2xres, self.po2yres = ScaleToPO2(self.xres, self.yres)
+
+   
+      self.quad = love.graphics.newQuad(0, 0, self.xsize, self.ysize, self.po2xsize, self.po2ysize)
+      self.scenequad = love.graphics.newQuad(0, 0, self.xres, self.yres, self.po2xres, self.po2yres)
+   
+      self.canvas = {
+         bloom = love.graphics.newCanvas(self.po2xsize, self.po2ysize),
+         blur_horiz = love.graphics.newCanvas(self.po2xsize, self.po2ysize),
+         blur_vert = love.graphics.newCanvas(self.po2xsize, self.po2ysize),
+         scene = love.graphics.newCanvas(self.po2xres, self.po2yres),
+         bloomscene = love.graphics.newCanvas(self.po2xres, self.po2yres),
+      }
+            
+      for k,v in pairs(self.canvas) do
+         v:clear()
+      end
+      
+      shaders.blur_horiz:send("canvas_w", self.po2xsize)
+      shaders.blur_vert:send("canvas_h", self.po2ysize)
+      self:setThreshold(self:getThreshold())
+      self:setIntensity(self:getIntensity())
+      self:setSaturation(self:getSaturation())
+      
+      if renderingtoscene then
+         love.graphics.setCanvas(self.canvas.scene)
+      end
+      
+      collectgarbage("collect")
+   end
+   
+   function bloom:debugDraw(shoulddebugdraw)
+      debugdraw = not not shoulddebugdraw
+   end
+   
+   function bloom:setIntensity(ibase, ibloom)
+      intensity_base = ibase
+      intensity_bloom = ibloom
+      
+      shaders.combine:send("baseintensity", ibase)
+      shaders.combine:send("bloomintensity", ibloom)
+   end
+   function bloom:getIntensity()
+      return intensity_base, intensity_bloom
+   end
+   
+   function bloom:setSaturation(sbase, sbloom)
+      saturation_base = sbase
+      saturation_bloom = sbloom
+      
+      shaders.combine:send("basesaturation", sbase)
+      shaders.combine:send("bloomsaturation", sbloom)
+   end
+   function bloom:getSaturation()
+      return saturation_base, saturation_bloom
+   end
+   
+   function bloom:setThreshold(threshold)
+      threshold_bloom = threshold
+      
+      shaders.bloom:send("threshold", threshold)
+   end
+   function bloom:getThreshold()
+      return threshold_bloom
+   end
+   
+   
+   -- call right before drawing the stuff you want bloomed
+   function bloom:predraw()
+      for k,v in pairs(self.canvas) do
+         v:clear()
+      end
+      love.graphics.setCanvas(self.canvas.scene)
+      
+      self.drawing = true
+   end
+   
+   function bloom:enabledrawtobloom()
+      love.graphics.setCanvas(self.canvas.bloomscene)
+   end
+   
+   -- call after drawing the stuff you want bloomed
+   function bloom:postdraw()         
+      love.graphics.setColor(255, 255, 255)
+      local blendmode = love.graphics.getBlendMode()
+      love.graphics.setBlendMode("premultiplied")
+      
+      love.graphics.push()
+      love.graphics.scale(self.po2xsize/self.po2xres, self.po2ysize/self.po2yres)
+      
+      -- apply bloom extract shader
+      love.graphics.setCanvas(self.canvas.bloom)
+      love.graphics.setPixelEffect(shaders.bloom)
+      love.graphics.drawq(self.canvas.bloomscene, self.scenequad, 0, 0)
+      
+      love.graphics.pop()
+               
+      -- apply horizontal blur shader to extracted bloom
+      love.graphics.setCanvas(self.canvas.blur_horiz)
+      love.graphics.setPixelEffect(shaders.blur_horiz)
+      love.graphics.drawq(self.canvas.bloom, self.quad, 0, 0)
+      
+      -- apply vertical blur shader to blurred bloom
+      love.graphics.setCanvas(self.canvas.blur_vert)
+      love.graphics.setPixelEffect(shaders.blur_vert)
+      love.graphics.drawq(self.canvas.blur_horiz, self.quad, 0, 0)
+      
+      -- render final scene combined with bloom canvas
+      love.graphics.setCanvas()
+      shaders.combine:send("bloomtex", self.canvas.blur_vert)
+      love.graphics.setPixelEffect(shaders.combine)
+      love.graphics.drawq(self.canvas.scene, self.scenequad, 0, 0)
+      
+      love.graphics.setPixelEffect()
+      
+      if debugdraw then
+         -- love.graphics.setColor(255, 255, 255, 128)
+         love.graphics.draw(self.canvas.bloom, 0, 0)
+         love.graphics.draw(self.canvas.blur_horiz, self.po2xsize+4, 0)
+         love.graphics.draw(self.canvas.blur_vert, self.po2xsize*2+8, 0)
+         -- love.graphics.draw(self.canvas.blur_vert, 0, 0, 0, self.po2xres/self.po2xsize, self.po2yres/self.po2ysize)
+      end
+      
+      love.graphics.setBlendMode(blendmode)
+      
+      self.drawing = false
+   end
+   
+   function bloom:isDrawing()
+      return not not self.drawing
+   end
+   
+   bloom:refresh(xsize, ysize)
+   
+   bloom:setIntensity(1, 1)
+   bloom:setSaturation(1, 1)
+   bloom:setThreshold(0.35)
+   
+   return bloom
+end

File lib/shaders/bloom_simple.lua

View file
+local bloom = love.graphics.newPixelEffect [[
+vec2 image_size;
+
+vec4 effect(vec4 color, Image tex, vec2 tc, vec2 pc)
+{
+    vec2 offset = vec2(1.0)/image_size;
+    color = Texel(tex, tc); // maybe add a weight here?
+
+    color += Texel(tex, tc + vec2(-offset.x, offset.y));
+    color += Texel(tex, tc + vec2(0, offset.y));
+    color += Texel(tex, tc + vec2(offset.x, offset.y));
+
+    color += Texel(tex, tc + vec2(-offset.x, 0));
+    color += Texel(tex, tc + vec2(0, 0));
+    color += Texel(tex, tc + vec2(offset.x, 0));
+
+    color += Texel(tex, tc + vec2(-offset.x, -offset.y));
+    color += Texel(tex, tc + vec2(0, -offset.y));
+    color += Texel(tex, tc + vec2(offset.x, -offset.y));
+
+    return color / 10.0; // use 10.0 for regular blurring.
+}
+]]
+
+return bloom
+
+

File lib/vendor/AdvancedTiledLoader/Base64.lua

File contents unchanged.

File lib/vendor/AdvancedTiledLoader/Grid.lua

File contents unchanged.

File lib/vendor/AdvancedTiledLoader/Loader.lua

File contents unchanged.

File lib/vendor/AdvancedTiledLoader/Map.lua

File contents unchanged.

File lib/vendor/AdvancedTiledLoader/Object.lua

File contents unchanged.

File lib/vendor/AdvancedTiledLoader/ObjectLayer.lua

File contents unchanged.

File lib/vendor/AdvancedTiledLoader/README.md

File contents unchanged.

File lib/vendor/AdvancedTiledLoader/Tile.lua

File contents unchanged.

File lib/vendor/AdvancedTiledLoader/TileLayer.lua

File contents unchanged.

File lib/vendor/AdvancedTiledLoader/TileSet.lua

File contents unchanged.

File lib/vendor/AdvancedTiledLoader/VERSION.txt

File contents unchanged.

File lib/vendor/AdvancedTiledLoader/external/crc32lua.lua

File contents unchanged.

File lib/vendor/AdvancedTiledLoader/external/deflatelua.lua

File contents unchanged.

File lib/vendor/AdvancedTiledLoader/external/gunziplua.lua

File contents unchanged.

File lib/vendor/AdvancedTiledLoader/external/numberlua.lua

File contents unchanged.

File lib/vendor/AdvancedTiledLoader/external/optparse.lua

File contents unchanged.

File lib/vendor/AdvancedTiledLoader/external/xml.lua

File contents unchanged.

File lib/vendor/AdvancedTiledLoader/init.lua

File contents unchanged.

File lib/vendor/Beetle.lua

File contents unchanged.

File lib/vendor/neon.lua

View file
+local Neon = {}
+
+Neon.Interface = function(name_or_namespace, name)
+  local namespace, interface_name, factory
+
+  -- define our namespace
+  if name_or_namespace and name then
+    namespace = name_or_namespace
+  else
+    namespace = _G
+  end
+
+  -- define our interface name
+  if name_or_namespace and name then
+    interface_name = name
+  elseif name_or_namespace then
+    interface_name = name_or_namespace
+  else
+    interface_name = 'interface' .. math.random()
+  end
+
+  -- factory method, creates our interface
+  factory = function(definition)
+    definition.is_interface = true;
+    definition.name = interface_name;
+    namespace[interface_name] = definition;
+    return namespace[interface_name];
+  end
+
+  return factory
+end
+
+Neon.Module = function(name_or_namespace, name)
+  local namespace, module_name, factory, new_module
+
+  -- define our namespace
+  if name_or_namespace and name then
+    namespace = name_or_namespace
+  else
+    namespace = _G
+  end
+
+  -- define our module name
+  if name_or_namespace and name then
+    module_name = name
+  elseif name_or_namespace then
+    module_name = name_or_namespace
+  else
+    module_name = 'module' .. math.random()
+  end
+
+end
+
+
+return Neon