Skip to content

Instantly share code, notes, and snippets.

@abachman
Created June 9, 2010 21:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abachman/432188 to your computer and use it in GitHub Desktop.
Save abachman/432188 to your computer and use it in GitHub Desktop.
# Bohconf
class Bohconf < Processing::App
def setup
background 0
frame_rate 30
no_stroke
@xy = []
400.times {
@xy << [random(width),random(height),1,1]
}
@yx = []
40.times {
@yx << [random(width),random(height),1,1]
}
@a = 0
@b = 0
@da = 10
@db = 29
@r = 0
end
def draw
@yx = zombies @yx, true
push_matrix
translate width/2, height/2
rotate @r
@xy = zombies @xy, false
pop_matrix
@a = (@a + @da) % width
@b = (@b + @db) % height
@r += 0.1
end
def zombies arr, flip
if flip
fill(map(@a, 0, width, 0, 255),
map(@b, 0, height, 0, 255), 0)
else
fill(map(@b, 0, height, 0, 255),
map(@a, 0, width, 0, 255), 0)
end
arr.map { |pack|
if flip
x, y, dx, dy = pack
else
y, x, dx, dy = pack
end
if flip
x += dx * map(@a, 0, width, 0, 20)
y += dy * map(@b, 0, width, 0, 20)
else
x -= dx * map(@a, 0, width, 0, 20)
y -= dy * map(@b, 0, width, 0, 20)
end
ellipse x, y, 10, 10
rect y, x, 10, 10
if x > width || x < 0
dx = -dx
end
if y > height || y < 0
dy = -dy
end
if flip
[x, y, dx, dy]
else
[y, x, dy, dx]
end
}
end
def mouse_pressed
background 255
end
end
Bohconf.new :title => "Bohconf",
:width => 675,
:height => 768
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment