From: Terje Tjervaag Date: 2005-11-25T18:51:48+09:00 Subject: Re: RRobots - ducks, armed and dangerous ------=_Part_19401_9617396.1132912301478 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On 11/24/05, Simon Kr=F6ger wrote: > v0.1.1 is ready for download. Hi, I added a little status display in the canvas so each robot's health is shown - easier to have it all in one window rather than having the health in the terminal window. Diff attached, against 0.1.1 -- Terje ------=_Part_19401_9617396.1132912301478 Content-Type: application/octet-stream; name=robot.diff Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="robot.diff" --- ../robots3/rrobots.rb 2005-11-24 14:59:06.000000000 +0100 +++ rrobots.rb 2005-11-25 10:40:10.052577500 +0100 @@ -107,7 +107,7 @@ $stdout.sync = true -TkRobot = Struct.new(:body, :gun, :radar) +TkRobot = Struct.new(:body, :gun, :radar, :status) usage if ARGV.size != 2 @@ -161,10 +161,16 @@ battlefield.tick battlefield.robots.each_with_index do |ai, i| - robots[ai] ||= TkRobot.new(TkcImage.new(canvas, 0, 0), TkcImage.new(canvas, 0, 0), TkcImage.new(canvas, 0, 0)) + robots[ai] ||= TkRobot.new(TkcImage.new(canvas, 0, 0), TkcImage.new(canvas, 0, 0), TkcImage.new(canvas, 0, 0), + TkcText.new(canvas, + :fill => %w{red green}[i], + :anchor => 'nw', + :coords => [10, 15 * i + 10], + :font => TkFont.new("courier 10"))) robots[ai].body.configure(:image => colors[i].body[(ai.heading+5) / 10], :coords => [ai.x / 2, ai.y / 2]) robots[ai].gun.configure(:image => colors[i].gun[(ai.gun_heading+5) / 10], :coords => [ai.x / 2, ai.y / 2]) robots[ai].radar.configure(:image => colors[i].radar[(ai.radar_heading+5) / 10], :coords => [ai.x / 2, ai.y / 2]) + robots[ai].status.configure(:text => "#{ai.class.name.ljust(20)} #{ai.energy}") end battlefield.bullets.each do |bullet| bullets[bullet] ||= TkcOval.new(canvas, [-2, -2], [3, 3], :fill=>'gray80') @@ -177,4 +183,4 @@ end }).start -Tk.mainloop \ No newline at end of file +Tk.mainloop ------=_Part_19401_9617396.1132912301478--