Sha256: 8d892697ea34f2ee63f91b8e950e09da50e6e4787bfb154f78db798fed63232b
Contents?: true
Size: 894 Bytes
Versions: 5
Compression:
Stored size: 894 Bytes
Contents
#!/usr/local/bin/ruby -w # -*- coding: utf-8 -*- require "graphics" ## # Virtual Ants -- inspired by a model in NetLogo. class Vant < Graphics::Body COUNT = 100 M = 1 attr_accessor :white, :black, :red, :s def initialize w super self.a = random_angle self.s = w.renderer self.white = w.color[:white] self.black = w.color[:black] end def update move_by a, M end def draw if s[x, y] == white then s[x, y] = black turn 270 else s[x, y] = white turn 90 end end end class Vants < Graphics::Drawing attr_accessor :vs CLEAR_COLOR = :white def initialize super 850, 850 self.vs = populate Vant register_bodies vs end def draw n draw_on texture do _bodies.each do |a| a.each do |v| v.draw end end end end end Vants.new.run if $0 == __FILE__
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
graphics-1.1.2 | examples/vants.rb |
graphics-1.1.1 | examples/vants.rb |
graphics-1.1.0 | examples/vants.rb |
graphics-1.0.1 | examples/vants.rb |
graphics-1.0.0 | examples/vants.rb |