The Shoebox. A place for lil' apps to live in peace and harmony.

A hungry swarm indeed.

Change Log:
v0.1 – The initial swarm.

v0.2 – Replaced custom random method with (min..max).rand
- Mouse clicks add food. Careful not to add too much.

Magnus Adamsson v0.3 – Seems Shoes 0.r646 can no longer draw a zero radius circle

Wally Glutton v0.4 – No longer using a $app global to access Shoes methods within the Food and Boid classes.
- Moved class definitions above Shoes.app block as this was causing a problem for OSX builds.
- Decreased the Stay Visible Damper by 50.
- Fixed some spelling errors.
- Assigned explicit app title, height & width.

Wally Glutton v0.5 – In Shoes Raisins an oval :radius now acutally defines its radius, and not the diameter like in early versions of Shoes.
- Changed all references to RADIUS to DIAMETER and draw oval using :width.


Speak now or forever hold your peace:

kevinc
March 4, 2008

cute! works fine in os x. i would also like to see how an experienced rubyist would refactor this.

RyanTM
March 4, 2008

rmulliga@rtmlap:~/rb/shoes$ diff hungry_boids_v0.1.rb hungry_boids_v0.2.rb 28a29,31 > click do |_,x,y| > foodstuff.push Food.new(x,y) > end 58,59c61,62 < def initialize < spawn

> def initialize(x=(rand$app.width),y=(rand$app.height)) > spawn(x,y) 61c64 < def spawn

> def spawn(x=(rand$app.width),y=(rand$app.height)) 63c66 < @position = VectorK.new rand * $app.width, rand * $app.height

@position = VectorK.new x,y

kevinc
March 6, 2008

actually i see one bug in os x: the shapes sometimes flicker in and out, showing the white background instead. if i add more food, it gets worse. i can only really observe this on the food. the boids themselves move too fast for me to tell if this happens.

Wally Glutton
March 10, 2008

I noticed this food flashing under Ubuntu Linux too.

Ian M
March 16, 2008

I really like this. Used to play around with boids like agent sims for years in qbasic wayyyyy back. I’m thinking I might have to have a play with your code. Thanks :)

coffeejunk
April 11, 2008

it doesnt work any more with the new build of shoes :(

coffeejunk
April 11, 2008

oh and i’m using osx..

Magnus Adamsson
June 2, 2008

Seems Shoes 0.r646 can’t draw a zero radius circle. I took the liberty of fixing the code.

ashbb
March 7, 2009

Fantastic!

v0.5 works really cool on my Windows XP laptop with Shoes 2.

Great work, thanks.

nope
May 5, 2009

very good work!!!


How do I use this?