Skip to content

Instantly share code, notes, and snippets.

@bryanwoods
Created September 9, 2008 16:17
Show Gist options
  • Save bryanwoods/9701 to your computer and use it in GitHub Desktop.
Save bryanwoods/9701 to your computer and use it in GitHub Desktop.
#ALL HAILZ THE TRV DVRK EMPORER
#THEBIRDCAGETHEATER
require 'ruby-processing'
require 'boids'
class HailHail < Processing::App
attr_reader :blackout
# And what shall He look like?
def setup
@num = 1000
@blackout = false
@kaons = []
render_mode P3D
# Let the flames of hatred overtake the darkness
@num.times do |i|
emitx = (900*Math.sin(Math::PI*2*i/@num))
emity = (4500*Math.sin(Math::PI*4*i/@num))
r = Math::PI * i / @num
@kaons[i] = DarkLord.new(self, emitx, emity, r)
end
end
def draw
push_matrix
translate width/3, height/2
@kaons.each {|kaon| kaon.move }
@blackout = !@blackout if rand < 0.05
pop_matrix
end
#The fingers of such mere mortals pressed
def mouse_pressed
@blackout = !@blackout
end
end
def mouse_dragged
@blackout = !@blackout
end
class DarkLord
def initialize(app, dx, dy, r)
@app = app
@width, @height = @app.width, @app.height
@x, @y = -dx, -dy
@xx, @yy = 0, 0
@vx, @vy = 2*Math.cos(r), 8*Math.sin(r)
@app.blackout ? @i = 0 : @i = 200
@age = rand(20)
end
def move
@xx, @yy = @x, @y
@x += @vx
@y += @vy
@vx += rand - 0.5
@vy += rand - 0.5
@app.stroke @i, 24
@app.line(@xx, @yy, @x, @y)
@app.line(- @xx, @yy, - @x, @y)
@age += 1
if @age > 200 || @x.abs > @width || @y.abs > @height
t = rand * Math::PI*2
@x, @y = 60*Math.sin(t), 90*Math.cos(t)
@xx, @yy, @vx, @vy, @age = 0, 0, 0, 0, 0
@app.blackout ? @i = 0 : @i = 255
end
end
end
HailHail.new :width => 1000, :height => 500, :title => "THERE WILL BE NO MERCY", :full_screen => true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment