Skip to content

Instantly share code, notes, and snippets.

View 2bt's full-sized avatar

Daniel Langner 2bt

  • Berlin, Germany
View GitHub Profile
@2bt
2bt / README.md
Created March 3, 2019 18:27
SCRIPT-8
@2bt
2bt / main.lua
Last active February 17, 2016 01:47
love2d polygon substraction
local G = love.graphics
function splitPoly(poly, mx, my, dx, dy)
local poly_a = {}
local poly_b = {}
local ax = poly[#poly-1]
local ay = poly[#poly ]
for i = 1, #poly, 2 do
local bx = poly[i ]
@2bt
2bt / main.lua
Last active February 1, 2016 14:57
Dancing with friends and enemies
local G = love.graphics
math.randomseed(os.time())
parts = {}
function find_partner(p)
while true do
local q = parts[math.random(#parts)]
if q ~= p and q ~= p.friend and q ~= p.enemy then
#include <SDL/SDL.h>
#include <stdio.h>
#include <time.h>
enum {
CELL_SIZE = 20,
GRID_WIDTH = 10,
GRID_HEIGHT = 20,
};
@2bt
2bt / blob.py
Created October 20, 2012 20:05
ASCII metaball silhouette
import sys, time, math, random
def get_foo(x, y):
d = 0
for a, b, c in points:
d += c / (1 + (x - a)**2 + (y - b)**2)
return d
def march(a, b, c, d):
@2bt
2bt / main.lua
Created October 11, 2012 02:10
minimal love2d pong
local isDown = love.keyboard.isDown
local bool = { [true] = 1, [false] = 0 }
local speed = 3
local ball = { x = 0, y = 0, vx = -speed, vy = speed }
local pad1_y = 0
local pad2_y = 0
local score1 = 0
local score2 = 0
function love.update()
pad1_y = pad1_y + (bool[isDown"a"] - bool[isDown"q"]) * 7
@2bt
2bt / main.lua
Created September 4, 2012 22:22
love2d gaussian blur test
local graphics = love.graphics
function love.load()
local program = ([[
const float kernel[5] = float[](0.2270270270, 0.1945945946, 0.1216216216, 0.0540540541, 0.0162162162);
vec4 effect(vec4 color, sampler2D tex, vec2 tex_coords, vec2 pos) {
color = texture2D(tex, tex_coords) * kernel[0];
for(int i = 1; i < 5; i++) {
color += texture2D(tex, vec2(tex_coords.x + i * %f, tex_coords.y)) * kernel[i];