bjorn 9 lat temu
rodzic
commit
7ca3426fd8
3 zmienionych plików z 39 dodań i 1 usunięć
  1. 19 0
      app/hud/game.lua
  2. 19 0
      app/shaders/godray.glsl
  3. 1 1
      main.lua

+ 19 - 0
app/hud/game.lua

@@ -65,6 +65,7 @@ function hud:bind()
         end)
 
         self:drawAbilities()
+        self:drawGodTest()
 
         return -1000
       end),
@@ -280,4 +281,22 @@ function hud:drawAbilities()
   end
 end
 
+function hud:drawGodTest()
+  local u, v = self.u, self.v
+
+  self.godCanvas = self.godCanvas or g.newCanvas(u, v)
+  g.setCanvas(self.godCanvas)
+  g.clear(0, 0, 0, 0)
+
+  g.white()
+  g.rectangle('fill', u * .5 - 100, v * .5 - 100, 200, 200)
+
+  g.setCanvas()
+
+  app.shaders.godray:send('time', lib.tick.index)
+  g.setShader(app.shaders.godray)
+  g.draw(self.godCanvas)
+  g.setShader()
+end
+
 return hud

+ 19 - 0
app/shaders/godray.glsl

@@ -0,0 +1,19 @@
+extern vec4 color;
+extern float time;
+
+#define pi 3.141592653589793238462
+
+vec4 effect(vec4 color, Image texture, vec2 texture_coords, vec2 screen_coords) {
+  vec4 result = Texel(texture, texture_coords);
+
+  float direction = atan((texture_coords.y - .5) / (texture_coords.x - .5));
+  float distance = length(texture_coords - vec2(.5, .5)) * 7;
+
+  vec2 rayCoords = vec2(((texture_coords.x - .5) / 2) + .5, ((texture_coords.y - .5) / 2) + .5);
+  rayCoords.x += cos(time / 11 + texture_coords.y / 2) * .04;
+  rayCoords.y += sin(time / 9 + texture_coords.x / 2) * .04;
+  vec4 rayColor = Texel(texture, rayCoords);
+  rayColor.a = .5;
+
+  return result + rayColor;
+}

+ 1 - 1
main.lua

@@ -30,7 +30,7 @@ f = lib.funk
 g = love.graphics
 util = setmetatable(lib.util, { __index = lib.lume })
 
-app.context.load('world')
+app.context.load('overgrowth')
 
 love.update:subscribe(lib.flux.update)