Ruby Tweets!
ruby -e "i=0;loop{puts ' '*(29*(Math.sin(i)/2+1))+'|'*(29*(Math.cos(i)/2+1)); i+=0.1}" #ruby
about 23 hours ago via web
ruby -rtk -e "w=TkCanvas.new(TkRoot.new{title:paint});w.pack.bind('B1-Motion',proc{|x,y|TkcOval.new(w,x,y,x+4,y+4)},'%x %y').mainloop" #ruby
about 3 hours ago via web
Almost got this one short enough to tweet:
ruby -rtk -e"v,w=0,0;a=[1]*9;c=TkCanvas.new;c.pack.bind('Motion',proc{|x,y|a<<TkcLine.new(c,v,w,v=x,w=y,:arrow=>'last');a.shift.delete rescue 1},'%x %y').mainloop"
Read more...
Killing the Pegasus...
Going salaried at my current employer, and have to fill out a job application as a formality. So I was digging around for past employer info in my archives, and came across this e-mail, sent on the occasion of departing Pegasus Solutions…
Date: Sat, 22 Oct 2005 From: Me User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) To: John Subject: Re: New job! John McGavren wrote: > What level are you now, and what did you put your stat points into? > Oh! I'm curious about the loot you got from killing the pegasus too. > Any tomes of knowledge? Or swords? Um, no. But I am gonna take my stapler with me. -JayRead more...
Jemini Tutorial (Part 2 of 2)
In Part 2 of our tutorial, we’ll create some enemies for our player to fight. We’ll set up collision detection, use timers to make a pretty fading effect, and set up a custom manager to coordinate enemy movements and shooting.
Be sure to visit jemini.org for help on starting your own game!
You can view part 1 here.
Read more...Jemini Tutorial (Part 1 of 2)
Jemini is a Ruby-based framework for game development. In this screencast, we’ll create a shooter game from scratch.
Part 1 shows creating a project, setting up a game state, loading animations, music and sound effects, and setting up keyboard input and event handlers. (Not bad for 22 minutes, right?)
You can view part 2 here.
Read more...Puerto Penasco/Rocky Point was fun, if not exactly my cup of tea… This was my first time to Mexico, so we weren’t exactly seasoned travelers, but we got by and actually had a good time.
Read more...SVG On Acid...
Everything so far has relied on some tricky-to-install GUI gem… Working in SVG lets Ruby On Acid make pretty graphics (viewable in any modern browser) by outputting plain text.
Here’s a few samples. I’m sure I could produce more consistently pretty results with more SVG expertise, but that’s something I’ll have to play with another time.
Read more...A computer can mimic the style of a classical composer by analyzing sheet music. I bet GUIs could be (partially) generated for command-line tools. You just analyze how people mapped a CLI tool’s functions to a GUI wrapper (say, Git vs. GitX), then apply the rules you learn to other CLI tools.
Read more...RubyConf in 22 Minutes video just posted by @greggpollack, featuring my handsome mug! I give the elevator pitch version of our Jemini talk.
http://blog.envylabs.com/2009/12/rubyconf-videos/
Read more...Processing on Acid...
Got Ruby-Processing working with external libraries, so I can finally try it out with Ruby On Acid! My problem was that I couldn’t (or didn’t know how to) set the ruby load path with ruby-processing’s included “rp5” tool. But on Marc Chung’s advice, I tried loading it into vanilla JRuby (had to do a small hack, but it worked). From there I was able to set $RUBYLIB, include it from a gem, whatever.
It’s fast, too, at least compared to wxRuby on MRI 1.8.7. My dual-core MacBook can draw 3000 shapes a second without breaking a sweat.
OK, so here’s how to try it out yourself:
Save to acid_sketch.rb:
require 'rubygems'
require 'ruby-processing'
require 'rubyonacid/factories/meta'
require 'rubyonacid/factories/combination'
require 'rubyonacid/factories/constant'
require 'rubyonacid/factories/flash'
require 'rubyonacid/factories/loop'
require 'rubyonacid/factories/random'
require 'rubyonacid/factories/repeat'
require 'rubyonacid/factories/sine'
require 'rubyonacid/factories/skip'
class Sketch < Processing::App
def setup
@f = create_factory
@resetter = RubyOnAcid::SkipFactory.new(0.9999)
background 0
smooth
ellipse_mode CENTER
rect_mode CENTER
end
def draw
10.times do
fill(
@f.get(:red, :max => 255),
@f.get(:green, :max => 255),
@f.get(:blue, :max => 255),
@f.get(:alpha, :max => 255)
)
no_stroke
ellipse(
@f.get(:x, :max => width),
@f.get(:y, :max => height),
@f.get(:width, :max => 100),
@f.get(:height, :max => 100)
)
@f.reset_assignments if @resetter.boolean(:reset)
end
end
def create_factory
random_factory = RubyOnAcid::RandomFactory.new
source_factories = []
#Loop factories loop from 0.0 to 1.0 (or 1.0 to 0.0 if the increment value is negative).
source_factories << RubyOnAcid::LoopFactory.new(0.01)
source_factories << RubyOnAcid::LoopFactory.new(-0.01)
source_factories << RubyOnAcid::LoopFactory.new(0.001)
source_factories << RubyOnAcid::LoopFactory.new(-0.001)
#Constant factories always return the same value,
source_factories << RubyOnAcid::ConstantFactory.new(rand)
source_factories << RubyOnAcid::ConstantFactory.new(rand)
source_factories << RubyOnAcid::FlashFactory.new(rand(100))
#Sine factories produce a "wave" pattern.
source_factories << RubyOnAcid::SineFactory.new(0.1)
source_factories << RubyOnAcid::SineFactory.new(-0.1)
source_factories << RubyOnAcid::SineFactory.new(0.01)
source_factories << RubyOnAcid::SineFactory.new(-0.01)
#A RepeatFactory wraps another factory, queries it, and repeats the same value a certain number of times.
source_factories << RubyOnAcid::RepeatFactory.new(
RubyOnAcid::LoopFactory.new(random_factory.within(:increment, -0.1, 0.1)),
random_factory.get(:interval, :min => 2, :max => 100)
)
source_factories << RubyOnAcid::RepeatFactory.new(
RubyOnAcid::SineFactory.new(random_factory.within(:increment, -0.1, 0.1)),
random_factory.get(:interval, :min => 2, :max => 100)
)
#A CombinationFactory combines the values of two or more other factories.
combination_factory = RubyOnAcid::CombinationFactory.new
2.times do
combination_factory.source_factories << source_factories[rand(source_factories.length)]
end
source_factories << combination_factory
#The MetaFactory pulls requested value types from the other factories.
meta_factory = RubyOnAcid::MetaFactory.new
meta_factory.factory_pool = source_factories
meta_factory
end
end
Processing::SKETCH_PATH = ""
Sketch.new :title => "Ruby On Acid", :width => 800, :height => 600, :full_screen => falsejay@dandelion:~/Projects/ruby-processing $ sudo jruby -S gem install ruby-processing jay@dandelion:~/Projects/ruby-processing $ sudo jruby -S gem install rubyonacid jay@dandelion:~/Projects/ruby-processing $ jruby acid_sketch.rbRead more...
RubyConf wrapup...
RubyConf was awesome, and I’d like to think we made our contribution. The Jemini talk generated a lot of interested questions, and I’m pretty happy with the approach of using a screencast instead of slides (though we’ll see how it turns out in the Confreaks video). Last night Logan and I set up in the lobby with Life-Tank and our collection of XBox controllers, which attracted quite a few players and comments of “I gotta try this library when I get home”.
Enjoyed the Bay Area Computer Music Technology meetup at Pier 38, too. Got to promote Ruby On Acid, too. I showed off the usual graphical stuff, then the 8-bit PCM/WAV (“drunk Atari 2600”) sound and MIDI demos that I hacked together for the meetup. The audio demos need some experimentation before they’re ready for prime time, but I’d say the same of most things shown that evening. The other presenters clearly had more music composition education and/or experience, but I got a surprisingly warm reception anyway.
Had a lot of fun in SF. Great conference, great city, great people. If the right company is hiring I will definitely consider moving here.
Read more...