Skip to content

Instantly share code, notes, and snippets.

@cybojanek
Created May 31, 2014 20:15
Show Gist options
  • Save cybojanek/e01de06a7211eea49108 to your computer and use it in GitHub Desktop.
Save cybojanek/e01de06a7211eea49108 to your computer and use it in GitHub Desktop.
-- lick = require "lick"
-- lick.reset = true
function love.load()
love.graphics.setBackgroundColor(139, 137, 137)
love.graphics.setColor(205, 201, 201)
circle = {}
circle.x = 1
circle.y = 0
square = {}
square.x = 0
square.y = 1
highlight = love.graphics.newShader([[
extern vec2 source;
extern vec2 source2;
extern float radius;
vec4 effect(vec4 color, Image texture, vec2 tc, vec2 screen) {
float d = distance(screen, source);
float d2 = distance(screen, source2);
if (d >= radius && d2 >= radius) {
return vec4(0, 0, 0, 1.0);
} else if (d < radius && d2 < radius) {
return vec4(color[0], color[1], color[2],
min(d/radius, d2/radius));
} else if (d < radius) {
return vec4(color[0], color[1], color[2], d/radius);
} else if (d2 < radius) {
return vec4(color[0], color[1], color[2], d2/radius);
}
}
]])
highlight:send("radius", 150)
rainbow = love.graphics.newShader([[
vec4 effect(vec4 color, Image texture, vec2 texture_coords, vec2 screen) {
return vec4(screen.x / 512, screen.y / 512, 0.0, 1.0);
}
]])
end
function love.update(dt)
circle.x = circle.x + dt*2
circle.y = circle.y + dt*2
square.x = love.mouse.getX() - 10
square.y = love.mouse.getY() - 10
-- square.x = square.x + dt*2
-- square.y = square.y + dt*2
end
function love.draw(dt)
x = 400+200*math.sin(circle.x)
y = 300+200*math.sin(circle.y)
x2 = square.x
y2 = square.y
love.graphics.setColor(255, 255, 200)
love.graphics.rectangle("fill", 100, 100, 50, 50)
love.graphics.setColor(255, 100, 0)
love.graphics.rectangle("fill", 200, 200, 50, 50)
love.graphics.rectangle("fill", 400, 200, 50, 50)
love.graphics.setColor(100, 255, 90)
love.graphics.rectangle("fill", 400, 400, 50, 50)
highlight:send("source", {x, love.window.getHeight() - y})
highlight:send("source2", {x2 + 10, love.window.getHeight() - (y2 + 10)})
love.graphics.setShader(highlight)
love.graphics.setColor(0, 0, 0);
love.graphics.rectangle("fill", 0, 0, love.window.getWidth(), love.window.getHeight())
love.graphics.setShader(rainbow)
love.graphics.setColor(255, 255, 255)
love.graphics.circle("fill", x, y, 16,16)
love.graphics.rectangle("fill", x2, y2, 20, 20)
love.graphics.setShader()
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment