UG_RRobots 2.0 → 2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (176) hide show
  1. data/Rakefile +20 -4
  2. data/bin/rrobots +48 -17
  3. data/config/locales/en.yml +4 -2
  4. data/config/locales/fr.yml +3 -1
  5. data/doc/install.rdoc +20 -20
  6. data/doc/install_fr.rdoc +20 -20
  7. data/lib/GUI/gosu.rb +237 -0
  8. data/lib/GUI/tk.rb +215 -0
  9. data/lib/battlefield.rb +2 -0
  10. data/lib/mines.rb +36 -0
  11. data/lib/misc.rb +7 -4
  12. data/lib/robotrunner.rb +4 -0
  13. data/medias/gosu/images/blue_body000.bmp +0 -0
  14. data/medias/gosu/images/blue_radar000.bmp +0 -0
  15. data/medias/gosu/images/blue_turret000.bmp +0 -0
  16. data/medias/gosu/images/bullet.png +0 -0
  17. data/medias/gosu/images/explosion00.bmp +0 -0
  18. data/medias/gosu/images/explosion01.bmp +0 -0
  19. data/medias/gosu/images/explosion02.bmp +0 -0
  20. data/medias/gosu/images/explosion03.bmp +0 -0
  21. data/medias/gosu/images/explosion04.bmp +0 -0
  22. data/medias/gosu/images/explosion05.bmp +0 -0
  23. data/medias/gosu/images/explosion06.bmp +0 -0
  24. data/medias/gosu/images/explosion07.bmp +0 -0
  25. data/medias/gosu/images/explosion08.bmp +0 -0
  26. data/medias/gosu/images/explosion09.bmp +0 -0
  27. data/medias/gosu/images/explosion10.bmp +0 -0
  28. data/medias/gosu/images/explosion11.bmp +0 -0
  29. data/medias/gosu/images/explosion12.bmp +0 -0
  30. data/medias/gosu/images/explosion13.bmp +0 -0
  31. data/medias/gosu/images/explosion14.bmp +0 -0
  32. data/medias/gosu/images/lime_body000.bmp +0 -0
  33. data/medias/gosu/images/lime_radar000.bmp +0 -0
  34. data/medias/gosu/images/lime_turret000.bmp +0 -0
  35. data/medias/gosu/images/mine.png +0 -0
  36. data/medias/gosu/images/red_body000.bmp +0 -0
  37. data/medias/gosu/images/red_radar000.bmp +0 -0
  38. data/medias/gosu/images/red_turret000.bmp +0 -0
  39. data/medias/gosu/images/space.png +0 -0
  40. data/medias/gosu/images/toolbox.png +0 -0
  41. data/medias/gosu/images/white_body000.bmp +0 -0
  42. data/medias/gosu/images/white_radar000.bmp +0 -0
  43. data/medias/gosu/images/white_turret000.bmp +0 -0
  44. data/medias/gosu/images/yellow_body000.bmp +0 -0
  45. data/medias/gosu/images/yellow_radar000.bmp +0 -0
  46. data/medias/gosu/images/yellow_turret000.bmp +0 -0
  47. data/medias/gosu/music/song.mod +0 -0
  48. data/medias/gosu/sounds/shotborn.wav +0 -0
  49. data/medias/gosu/sounds/sunexp.wav +0 -0
  50. data/{images → medias/tk/images}/explosion00.gif +0 -0
  51. data/{images → medias/tk/images}/explosion01.gif +0 -0
  52. data/{images → medias/tk/images}/explosion02.gif +0 -0
  53. data/{images → medias/tk/images}/explosion03.gif +0 -0
  54. data/{images → medias/tk/images}/explosion04.gif +0 -0
  55. data/{images → medias/tk/images}/explosion05.gif +0 -0
  56. data/{images → medias/tk/images}/explosion06.gif +0 -0
  57. data/{images → medias/tk/images}/explosion07.gif +0 -0
  58. data/{images → medias/tk/images}/explosion08.gif +0 -0
  59. data/{images → medias/tk/images}/explosion09.gif +0 -0
  60. data/{images → medias/tk/images}/explosion10.gif +0 -0
  61. data/{images → medias/tk/images}/explosion11.gif +0 -0
  62. data/{images → medias/tk/images}/explosion12.gif +0 -0
  63. data/{images → medias/tk/images}/explosion13.gif +0 -0
  64. data/{images → medias/tk/images}/explosion14.gif +0 -0
  65. data/medias/tk/images/mine.gif +0 -0
  66. data/{images → medias/tk/images}/red_body000.gif +0 -0
  67. data/{images → medias/tk/images}/red_body010.gif +0 -0
  68. data/{images → medias/tk/images}/red_body020.gif +0 -0
  69. data/{images → medias/tk/images}/red_body030.gif +0 -0
  70. data/{images → medias/tk/images}/red_body040.gif +0 -0
  71. data/{images → medias/tk/images}/red_body050.gif +0 -0
  72. data/{images → medias/tk/images}/red_body060.gif +0 -0
  73. data/{images → medias/tk/images}/red_body070.gif +0 -0
  74. data/{images → medias/tk/images}/red_body080.gif +0 -0
  75. data/{images → medias/tk/images}/red_body090.gif +0 -0
  76. data/{images → medias/tk/images}/red_body100.gif +0 -0
  77. data/{images → medias/tk/images}/red_body110.gif +0 -0
  78. data/{images → medias/tk/images}/red_body120.gif +0 -0
  79. data/{images → medias/tk/images}/red_body130.gif +0 -0
  80. data/{images → medias/tk/images}/red_body140.gif +0 -0
  81. data/{images → medias/tk/images}/red_body150.gif +0 -0
  82. data/{images → medias/tk/images}/red_body160.gif +0 -0
  83. data/{images → medias/tk/images}/red_body170.gif +0 -0
  84. data/{images → medias/tk/images}/red_body180.gif +0 -0
  85. data/{images → medias/tk/images}/red_body190.gif +0 -0
  86. data/{images → medias/tk/images}/red_body200.gif +0 -0
  87. data/{images → medias/tk/images}/red_body210.gif +0 -0
  88. data/{images → medias/tk/images}/red_body220.gif +0 -0
  89. data/{images → medias/tk/images}/red_body230.gif +0 -0
  90. data/{images → medias/tk/images}/red_body240.gif +0 -0
  91. data/{images → medias/tk/images}/red_body250.gif +0 -0
  92. data/{images → medias/tk/images}/red_body260.gif +0 -0
  93. data/{images → medias/tk/images}/red_body270.gif +0 -0
  94. data/{images → medias/tk/images}/red_body280.gif +0 -0
  95. data/{images → medias/tk/images}/red_body290.gif +0 -0
  96. data/{images → medias/tk/images}/red_body300.gif +0 -0
  97. data/{images → medias/tk/images}/red_body310.gif +0 -0
  98. data/{images → medias/tk/images}/red_body320.gif +0 -0
  99. data/{images → medias/tk/images}/red_body330.gif +0 -0
  100. data/{images → medias/tk/images}/red_body340.gif +0 -0
  101. data/{images → medias/tk/images}/red_body350.gif +0 -0
  102. data/{images → medias/tk/images}/red_radar000.gif +0 -0
  103. data/{images → medias/tk/images}/red_radar010.gif +0 -0
  104. data/{images → medias/tk/images}/red_radar020.gif +0 -0
  105. data/{images → medias/tk/images}/red_radar030.gif +0 -0
  106. data/{images → medias/tk/images}/red_radar040.gif +0 -0
  107. data/{images → medias/tk/images}/red_radar050.gif +0 -0
  108. data/{images → medias/tk/images}/red_radar060.gif +0 -0
  109. data/{images → medias/tk/images}/red_radar070.gif +0 -0
  110. data/{images → medias/tk/images}/red_radar080.gif +0 -0
  111. data/{images → medias/tk/images}/red_radar090.gif +0 -0
  112. data/{images → medias/tk/images}/red_radar100.gif +0 -0
  113. data/{images → medias/tk/images}/red_radar110.gif +0 -0
  114. data/{images → medias/tk/images}/red_radar120.gif +0 -0
  115. data/{images → medias/tk/images}/red_radar130.gif +0 -0
  116. data/{images → medias/tk/images}/red_radar140.gif +0 -0
  117. data/{images → medias/tk/images}/red_radar150.gif +0 -0
  118. data/{images → medias/tk/images}/red_radar160.gif +0 -0
  119. data/{images → medias/tk/images}/red_radar170.gif +0 -0
  120. data/{images → medias/tk/images}/red_radar180.gif +0 -0
  121. data/{images → medias/tk/images}/red_radar190.gif +0 -0
  122. data/{images → medias/tk/images}/red_radar200.gif +0 -0
  123. data/{images → medias/tk/images}/red_radar210.gif +0 -0
  124. data/{images → medias/tk/images}/red_radar220.gif +0 -0
  125. data/{images → medias/tk/images}/red_radar230.gif +0 -0
  126. data/{images → medias/tk/images}/red_radar240.gif +0 -0
  127. data/{images → medias/tk/images}/red_radar250.gif +0 -0
  128. data/{images → medias/tk/images}/red_radar260.gif +0 -0
  129. data/{images → medias/tk/images}/red_radar270.gif +0 -0
  130. data/{images → medias/tk/images}/red_radar280.gif +0 -0
  131. data/{images → medias/tk/images}/red_radar290.gif +0 -0
  132. data/{images → medias/tk/images}/red_radar300.gif +0 -0
  133. data/{images → medias/tk/images}/red_radar310.gif +0 -0
  134. data/{images → medias/tk/images}/red_radar320.gif +0 -0
  135. data/{images → medias/tk/images}/red_radar330.gif +0 -0
  136. data/{images → medias/tk/images}/red_radar340.gif +0 -0
  137. data/{images → medias/tk/images}/red_radar350.gif +0 -0
  138. data/{images → medias/tk/images}/red_turret000.gif +0 -0
  139. data/{images → medias/tk/images}/red_turret010.gif +0 -0
  140. data/{images → medias/tk/images}/red_turret020.gif +0 -0
  141. data/{images → medias/tk/images}/red_turret030.gif +0 -0
  142. data/{images → medias/tk/images}/red_turret040.gif +0 -0
  143. data/{images → medias/tk/images}/red_turret050.gif +0 -0
  144. data/{images → medias/tk/images}/red_turret060.gif +0 -0
  145. data/{images → medias/tk/images}/red_turret070.gif +0 -0
  146. data/{images → medias/tk/images}/red_turret080.gif +0 -0
  147. data/{images → medias/tk/images}/red_turret090.gif +0 -0
  148. data/{images → medias/tk/images}/red_turret100.gif +0 -0
  149. data/{images → medias/tk/images}/red_turret110.gif +0 -0
  150. data/{images → medias/tk/images}/red_turret120.gif +0 -0
  151. data/{images → medias/tk/images}/red_turret130.gif +0 -0
  152. data/{images → medias/tk/images}/red_turret140.gif +0 -0
  153. data/{images → medias/tk/images}/red_turret150.gif +0 -0
  154. data/{images → medias/tk/images}/red_turret160.gif +0 -0
  155. data/{images → medias/tk/images}/red_turret170.gif +0 -0
  156. data/{images → medias/tk/images}/red_turret180.gif +0 -0
  157. data/{images → medias/tk/images}/red_turret190.gif +0 -0
  158. data/{images → medias/tk/images}/red_turret200.gif +0 -0
  159. data/{images → medias/tk/images}/red_turret210.gif +0 -0
  160. data/{images → medias/tk/images}/red_turret220.gif +0 -0
  161. data/{images → medias/tk/images}/red_turret230.gif +0 -0
  162. data/{images → medias/tk/images}/red_turret240.gif +0 -0
  163. data/{images → medias/tk/images}/red_turret250.gif +0 -0
  164. data/{images → medias/tk/images}/red_turret260.gif +0 -0
  165. data/{images → medias/tk/images}/red_turret270.gif +0 -0
  166. data/{images → medias/tk/images}/red_turret280.gif +0 -0
  167. data/{images → medias/tk/images}/red_turret290.gif +0 -0
  168. data/{images → medias/tk/images}/red_turret300.gif +0 -0
  169. data/{images → medias/tk/images}/red_turret310.gif +0 -0
  170. data/{images → medias/tk/images}/red_turret320.gif +0 -0
  171. data/{images → medias/tk/images}/red_turret330.gif +0 -0
  172. data/{images → medias/tk/images}/red_turret340.gif +0 -0
  173. data/{images → medias/tk/images}/red_turret350.gif +0 -0
  174. data/{images → medias/tk/images}/toolbox.gif +0 -0
  175. metadata +168 -128
  176. data/lib/tkarena.rb +0 -194
data/lib/GUI/tk.rb ADDED
@@ -0,0 +1,215 @@
1
+ require 'tk'
2
+ require 'base64'
3
+
4
+ def load_gui(battlefield, xres, yres, speed_multiplier)
5
+ arena = GUI::TkArena.new(battlefield, xres, yres, speed_multiplier)
6
+ game_over_counter = battlefield.teams.all?{|k,t| t.size < 2} ? 250 : 500
7
+ outcome_printed = false
8
+ arena.on_game_over{|battlefield|
9
+ unless outcome_printed
10
+ print_outcome(battlefield)
11
+ outcome_printed = true
12
+ end
13
+ exit 0 if game_over_counter < 0
14
+ game_over_counter -= 1
15
+ }
16
+ arena.run
17
+ end
18
+
19
+ module GUI
20
+
21
+
22
+
23
+ TkRobot = Struct.new(:body, :gun, :radar, :speech, :info, :status)
24
+
25
+ class TkArena
26
+
27
+
28
+ attr_reader :engine
29
+ attr_reader :battlefield, :xres, :yres
30
+ attr_accessor :speed_multiplier, :on_game_over_handlers
31
+ attr_accessor :canvas, :boom, :robots, :bullets, :explosions, :colors, :toolboxes, :toolbox_img, :mines, :mine_img
32
+ attr_accessor :default_skin_prefix, :path_prefix
33
+
34
+ def initialize battlefield, xres, yres, speed_multiplier
35
+ @engine = 'tk'
36
+ @battlefield = battlefield
37
+ @xres, @yres = xres, yres
38
+ @speed_multiplier = speed_multiplier
39
+ @text_colors = ['#ff0000', '#00ff00', '#0000ff', '#ffff00', '#00ffff', '#ff00ff', '#ffffff', '#777777']
40
+ @path_prefix = "#{gem_path}/medias/#{@engine}"
41
+ @default_skin_prefix = "images/red_"
42
+ @on_game_over_handlers = []
43
+ init_canvas
44
+ init_simulation
45
+ end
46
+
47
+ def on_game_over(&block)
48
+ @on_game_over_handlers << block
49
+ end
50
+
51
+ def read_gif name, c1, c2, c3
52
+ data = nil
53
+ open(name, 'rb') do |f|
54
+ data = f.read()
55
+ ncolors = 2**(1 + data[10][0] + data[10][1] * 2 + data[10][2] * 4)
56
+ ncolors.times do |j|
57
+ data[13 + j * 3 + 0], data[13 + j * 3 + 1], data[13 + j * 3 + 2] =
58
+ data[13 + j * 3 + c1], data[13 + j * 3 + c2], data[13 + j * 3 + c3]
59
+ end
60
+ end
61
+ TkPhotoImage.new(:data => Base64.encode64(data))
62
+ end
63
+
64
+ def init_canvas
65
+ @canvas = TkCanvas.new(:height=>yres, :width=>xres, :scrollregion=>[0, 0, xres, yres], :background => '#000000').pack
66
+ @colors = []
67
+ [[0,1,1],[1,0,1],[1,1,0],[0,0,1],[1,0,0],[0,1,0],[0,0,0],[1,1,1]][0...@battlefield.robots.length].zip(@battlefield.robots) do |color, robot|
68
+ bodies, guns, radars = [], [], []
69
+ image_path = robot.skin_prefix || @default_skin_prefix
70
+ image_path = "#{@path_prefix}/#{image_path}"
71
+ reader = robot.skin_prefix ? lambda{|fn| TkPhotoImage.new(:file => fn) } : lambda{|fn| read_gif(fn, *color)}
72
+ 36.times do |i|
73
+ bodies << reader["#{image_path}body#{(i*10).to_s.rjust(3, '0')}.gif"]
74
+ guns << reader["#{image_path}turret#{(i*10).to_s.rjust(3, '0')}.gif"]
75
+ radars << reader["#{image_path}radar#{(i*10).to_s.rjust(3, '0')}.gif"]
76
+ end
77
+ @colors << GUI::TkRobot.new(bodies << bodies[0], guns << guns[0], radars << radars[0])
78
+ end
79
+
80
+ @boom = (0..14).map do |i|
81
+ TkPhotoImage.new(:file => "#{path_prefix}/images/explosion#{i.to_s.rjust(2, '0')}.gif")
82
+ end
83
+ @toolbox_img = TkPhotoImage.new(:file => "#{path_prefix}/images/toolbox.gif")
84
+ @mine_img = TkPhotoImage.new(:file => "#{path_prefix}/images/mine.gif")
85
+ end
86
+
87
+ def init_simulation
88
+ @robots, @bullets, @explosions, @toolboxes, @mines = {}, {}, {}, {}, {}
89
+ TkTimer.new(20, -1, Proc.new{
90
+ begin
91
+ draw_frame
92
+ rescue => err
93
+ puts err.class, err, err.backtrace
94
+ raise
95
+ end
96
+ }).start
97
+ end
98
+
99
+ def draw_frame
100
+ simulate(@speed_multiplier)
101
+ draw_battlefield
102
+ end
103
+
104
+ def simulate(ticks=1)
105
+ @explosions.reject!{|e,tko| @canvas.delete(tko) if e.dead; e.dead }
106
+ @bullets.reject!{|b,tko| @canvas.delete(tko) if b.dead; b.dead }
107
+ @toolboxes.reject!{|t,tko| @canvas.delete(tko) if t.dead; t.dead }
108
+ @mines.reject!{|m,tko| @canvas.delete(tko) if m.dead; m.dead }
109
+ @robots.reject! do |ai,tko|
110
+ if ai.dead
111
+ tko.status.configure(:text => I18n.t('gui.ai_name_dead', :ai_name => ai.name.ljust(20)))
112
+ tko.each{|part| @canvas.delete(part) if part != tko.status}
113
+ true
114
+ end
115
+ end
116
+ ticks.times do
117
+ if @battlefield.game_over
118
+ @on_game_over_handlers.each{|h| h.call(@battlefield) }
119
+ unless @game_over
120
+ winner = @robots.keys.first
121
+ whohaswon = if winner.nil?
122
+ I18n.t('gui.draw')
123
+ elsif @battlefield.teams.all?{|k,t|t.size<2}
124
+ I18n.t('gui.no_team_won', :winner_name => winner.name)
125
+ else
126
+ I18n.t('gui.team_won', :winner_team => winner.team)
127
+ end
128
+ text_color = winner ? winner.team : 7
129
+ @game_over = TkcText.new(canvas,
130
+ :fill => @text_colors[text_color],
131
+ :anchor => 'c', :coords => [400,400], :font=>'courier 36', :justify => 'center',
132
+ :text => I18n.t('gui.game_over').concat("\n#{whohaswon}"))
133
+ end
134
+ end
135
+ @battlefield.tick
136
+ end
137
+ end
138
+
139
+ def draw_battlefield
140
+ draw_toolboxes
141
+ draw_mines
142
+ draw_robots
143
+ draw_bullets
144
+ draw_explosions
145
+ end
146
+
147
+ def draw_robots
148
+ @battlefield.robots.each_with_index do |ai, i|
149
+ next if ai.dead
150
+ @robots[ai] ||= GUI::TkRobot.new(
151
+ TkcImage.new(@canvas, 0, 0),
152
+ TkcImage.new(@canvas, 0, 0),
153
+ TkcImage.new(@canvas, 0, 0),
154
+ TkcText.new(@canvas,
155
+ :fill => @text_colors[ai.team],
156
+ :anchor => 's', :justify => 'center', :coords => [ai.x / 2, ai.y / 2 - ai.size / 2]),
157
+ TkcText.new(@canvas,
158
+ :fill => @text_colors[ai.team],
159
+ :anchor => 'n', :justify => 'center', :coords => [ai.x / 2, ai.y / 2 + ai.size / 2]),
160
+ TkcText.new(@canvas,
161
+ :fill => @text_colors[ai.team],
162
+ :anchor => 'nw', :coords => [10, 15 * i + 10], :font => TkFont.new("courier 9")))
163
+ @robots[ai].body.configure( :image => @colors[ai.team].body[(ai.heading+5) / 10],
164
+ :coords => [ai.x / 2, ai.y / 2])
165
+ @robots[ai].gun.configure( :image => @colors[ai.team].gun[(ai.gun_heading+5) / 10],
166
+ :coords => [ai.x / 2, ai.y / 2])
167
+ @robots[ai].radar.configure(:image => @colors[ai.team].radar[(ai.radar_heading+5) / 10],
168
+ :coords => [ai.x / 2, ai.y / 2])
169
+ @robots[ai].speech.configure(:text => "#{ai.speech}",
170
+ :coords => [ai.x / 2, ai.y / 2 - ai.size / 2])
171
+ @robots[ai].info.configure(:text => "#{ai.name}\n#{'|' * (ai.energy / 5)}",
172
+ :coords => [ai.x / 2, ai.y / 2 + ai.size / 2])
173
+ @robots[ai].status.configure(:text => "#{ai.name.ljust(20)} #{'%.1f' % ai.energy}")
174
+ end
175
+ end
176
+
177
+ def draw_bullets
178
+ @battlefield.bullets.each do |bullet|
179
+ @bullets[bullet] ||= TkcOval.new(
180
+ @canvas, [-2, -2], [3, 3],
181
+ :fill=>'#'+("%02x" % (128+bullet.energy*14).to_i)*3)
182
+ @bullets[bullet].coords(
183
+ bullet.x / 2 - 2, bullet.y / 2 - 2,
184
+ bullet.x / 2 + 3, bullet.y / 2 + 3)
185
+ end
186
+ end
187
+
188
+ def draw_mines
189
+ @battlefield.mines.each do |mine|
190
+ @mines[mine] ||= TkcImage.new(@canvas, mine.x / 2, mine.y / 2)
191
+ @mines[mine].image(mine_img)
192
+ end
193
+ end
194
+
195
+ def draw_explosions
196
+ @battlefield.explosions.each do |explosion|
197
+ @explosions[explosion] ||= TkcImage.new(@canvas, explosion.x / 2, explosion.y / 2)
198
+ @explosions[explosion].image(boom[explosion.t])
199
+ end
200
+ end
201
+
202
+ def draw_toolboxes
203
+ @battlefield.toolboxes.each do |toolbox|
204
+ @toolboxes[toolbox] ||= TkcImage.new(@canvas, toolbox.x / 2, toolbox.y / 2)
205
+ @toolboxes[toolbox].image(toolbox_img)
206
+ end
207
+ end
208
+
209
+ def run
210
+ Tk.mainloop
211
+ end
212
+
213
+ end
214
+
215
+ end
data/lib/battlefield.rb CHANGED
@@ -4,6 +4,8 @@ require 'bullets'
4
4
  require 'mines'
5
5
 
6
6
  class Battlefield
7
+
8
+
7
9
  attr_reader :width
8
10
  attr_reader :height
9
11
  attr_reader :robots
data/lib/mines.rb ADDED
@@ -0,0 +1,36 @@
1
+ class Mine
2
+ attr_accessor :x
3
+ attr_accessor :y
4
+ attr_accessor :t
5
+ attr_accessor :dead
6
+ attr_accessor :energy
7
+ attr_accessor :origin
8
+
9
+ def initialize bf, x, y, energy, origin
10
+ @x, @y, @origin = x, y, origin
11
+ @battlefield, @energy, @dead = bf, energy, false
12
+ end
13
+
14
+ def state
15
+ {:x=>x, :y=>y, :energy=>energy}
16
+ end
17
+
18
+ def tick
19
+ @battlefield.robots.each do |robot|
20
+ if (robot != origin) && (Math.hypot(@y - robot.y, robot.x - @x) < 40) && (!robot.dead)
21
+ explosion = Explosion.new(@battlefield, robot.x, robot.y)
22
+ @battlefield << explosion
23
+ damage = robot.hit(self)
24
+ origin.damage_given += damage
25
+ origin.kills += 1 if robot.dead
26
+ robot.trigged_mines += 1
27
+ @dead = true
28
+ end
29
+ end
30
+ end
31
+
32
+ def destroy
33
+ @dead = true
34
+ end
35
+
36
+ end
data/lib/misc.rb CHANGED
@@ -2,12 +2,15 @@
2
2
  def gem_path(path='')
3
3
  # TODO : Perhaps a better way to do it ...
4
4
  # regarder Rubygems pour avoir le path direct ..
5
+ res = Array::new
6
+
5
7
  table_map = Gem.location_of_caller.first.split('/')
6
- 2.times do
7
- table_map.pop
8
+ table_map.each do |item|
9
+ res.push item
10
+ break if item =~ /UG_RRobots/
8
11
  end
9
- table_map.push path unless path.empty?
10
- path_prefix = table_map.join('/')
12
+ res.push path unless path.empty?
13
+ path_prefix = res.join('/')
11
14
  return false unless File::exist?(path_prefix)
12
15
  return path_prefix
13
16
  end
data/lib/robotrunner.rb CHANGED
@@ -317,6 +317,10 @@ class RobotRunner
317
317
  end
318
318
  end
319
319
 
320
+ def pressed_button(id)
321
+ @events['button_pressed'] += id
322
+ end
323
+
320
324
  def to_s
321
325
  @robot.class.name
322
326
  end
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
Binary file
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes