Created
June 9, 2010 21:19
-
-
Save abachman/432188 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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