UG_RRobots 2.0 → 2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +20 -4
- data/bin/rrobots +48 -17
- data/config/locales/en.yml +4 -2
- data/config/locales/fr.yml +3 -1
- data/doc/install.rdoc +20 -20
- data/doc/install_fr.rdoc +20 -20
- data/lib/GUI/gosu.rb +237 -0
- data/lib/GUI/tk.rb +215 -0
- data/lib/battlefield.rb +2 -0
- data/lib/mines.rb +36 -0
- data/lib/misc.rb +7 -4
- data/lib/robotrunner.rb +4 -0
- data/medias/gosu/images/blue_body000.bmp +0 -0
- data/medias/gosu/images/blue_radar000.bmp +0 -0
- data/medias/gosu/images/blue_turret000.bmp +0 -0
- data/medias/gosu/images/bullet.png +0 -0
- data/medias/gosu/images/explosion00.bmp +0 -0
- data/medias/gosu/images/explosion01.bmp +0 -0
- data/medias/gosu/images/explosion02.bmp +0 -0
- data/medias/gosu/images/explosion03.bmp +0 -0
- data/medias/gosu/images/explosion04.bmp +0 -0
- data/medias/gosu/images/explosion05.bmp +0 -0
- data/medias/gosu/images/explosion06.bmp +0 -0
- data/medias/gosu/images/explosion07.bmp +0 -0
- data/medias/gosu/images/explosion08.bmp +0 -0
- data/medias/gosu/images/explosion09.bmp +0 -0
- data/medias/gosu/images/explosion10.bmp +0 -0
- data/medias/gosu/images/explosion11.bmp +0 -0
- data/medias/gosu/images/explosion12.bmp +0 -0
- data/medias/gosu/images/explosion13.bmp +0 -0
- data/medias/gosu/images/explosion14.bmp +0 -0
- data/medias/gosu/images/lime_body000.bmp +0 -0
- data/medias/gosu/images/lime_radar000.bmp +0 -0
- data/medias/gosu/images/lime_turret000.bmp +0 -0
- data/medias/gosu/images/mine.png +0 -0
- data/medias/gosu/images/red_body000.bmp +0 -0
- data/medias/gosu/images/red_radar000.bmp +0 -0
- data/medias/gosu/images/red_turret000.bmp +0 -0
- data/medias/gosu/images/space.png +0 -0
- data/medias/gosu/images/toolbox.png +0 -0
- data/medias/gosu/images/white_body000.bmp +0 -0
- data/medias/gosu/images/white_radar000.bmp +0 -0
- data/medias/gosu/images/white_turret000.bmp +0 -0
- data/medias/gosu/images/yellow_body000.bmp +0 -0
- data/medias/gosu/images/yellow_radar000.bmp +0 -0
- data/medias/gosu/images/yellow_turret000.bmp +0 -0
- data/medias/gosu/music/song.mod +0 -0
- data/medias/gosu/sounds/shotborn.wav +0 -0
- data/medias/gosu/sounds/sunexp.wav +0 -0
- data/{images → medias/tk/images}/explosion00.gif +0 -0
- data/{images → medias/tk/images}/explosion01.gif +0 -0
- data/{images → medias/tk/images}/explosion02.gif +0 -0
- data/{images → medias/tk/images}/explosion03.gif +0 -0
- data/{images → medias/tk/images}/explosion04.gif +0 -0
- data/{images → medias/tk/images}/explosion05.gif +0 -0
- data/{images → medias/tk/images}/explosion06.gif +0 -0
- data/{images → medias/tk/images}/explosion07.gif +0 -0
- data/{images → medias/tk/images}/explosion08.gif +0 -0
- data/{images → medias/tk/images}/explosion09.gif +0 -0
- data/{images → medias/tk/images}/explosion10.gif +0 -0
- data/{images → medias/tk/images}/explosion11.gif +0 -0
- data/{images → medias/tk/images}/explosion12.gif +0 -0
- data/{images → medias/tk/images}/explosion13.gif +0 -0
- data/{images → medias/tk/images}/explosion14.gif +0 -0
- data/medias/tk/images/mine.gif +0 -0
- data/{images → medias/tk/images}/red_body000.gif +0 -0
- data/{images → medias/tk/images}/red_body010.gif +0 -0
- data/{images → medias/tk/images}/red_body020.gif +0 -0
- data/{images → medias/tk/images}/red_body030.gif +0 -0
- data/{images → medias/tk/images}/red_body040.gif +0 -0
- data/{images → medias/tk/images}/red_body050.gif +0 -0
- data/{images → medias/tk/images}/red_body060.gif +0 -0
- data/{images → medias/tk/images}/red_body070.gif +0 -0
- data/{images → medias/tk/images}/red_body080.gif +0 -0
- data/{images → medias/tk/images}/red_body090.gif +0 -0
- data/{images → medias/tk/images}/red_body100.gif +0 -0
- data/{images → medias/tk/images}/red_body110.gif +0 -0
- data/{images → medias/tk/images}/red_body120.gif +0 -0
- data/{images → medias/tk/images}/red_body130.gif +0 -0
- data/{images → medias/tk/images}/red_body140.gif +0 -0
- data/{images → medias/tk/images}/red_body150.gif +0 -0
- data/{images → medias/tk/images}/red_body160.gif +0 -0
- data/{images → medias/tk/images}/red_body170.gif +0 -0
- data/{images → medias/tk/images}/red_body180.gif +0 -0
- data/{images → medias/tk/images}/red_body190.gif +0 -0
- data/{images → medias/tk/images}/red_body200.gif +0 -0
- data/{images → medias/tk/images}/red_body210.gif +0 -0
- data/{images → medias/tk/images}/red_body220.gif +0 -0
- data/{images → medias/tk/images}/red_body230.gif +0 -0
- data/{images → medias/tk/images}/red_body240.gif +0 -0
- data/{images → medias/tk/images}/red_body250.gif +0 -0
- data/{images → medias/tk/images}/red_body260.gif +0 -0
- data/{images → medias/tk/images}/red_body270.gif +0 -0
- data/{images → medias/tk/images}/red_body280.gif +0 -0
- data/{images → medias/tk/images}/red_body290.gif +0 -0
- data/{images → medias/tk/images}/red_body300.gif +0 -0
- data/{images → medias/tk/images}/red_body310.gif +0 -0
- data/{images → medias/tk/images}/red_body320.gif +0 -0
- data/{images → medias/tk/images}/red_body330.gif +0 -0
- data/{images → medias/tk/images}/red_body340.gif +0 -0
- data/{images → medias/tk/images}/red_body350.gif +0 -0
- data/{images → medias/tk/images}/red_radar000.gif +0 -0
- data/{images → medias/tk/images}/red_radar010.gif +0 -0
- data/{images → medias/tk/images}/red_radar020.gif +0 -0
- data/{images → medias/tk/images}/red_radar030.gif +0 -0
- data/{images → medias/tk/images}/red_radar040.gif +0 -0
- data/{images → medias/tk/images}/red_radar050.gif +0 -0
- data/{images → medias/tk/images}/red_radar060.gif +0 -0
- data/{images → medias/tk/images}/red_radar070.gif +0 -0
- data/{images → medias/tk/images}/red_radar080.gif +0 -0
- data/{images → medias/tk/images}/red_radar090.gif +0 -0
- data/{images → medias/tk/images}/red_radar100.gif +0 -0
- data/{images → medias/tk/images}/red_radar110.gif +0 -0
- data/{images → medias/tk/images}/red_radar120.gif +0 -0
- data/{images → medias/tk/images}/red_radar130.gif +0 -0
- data/{images → medias/tk/images}/red_radar140.gif +0 -0
- data/{images → medias/tk/images}/red_radar150.gif +0 -0
- data/{images → medias/tk/images}/red_radar160.gif +0 -0
- data/{images → medias/tk/images}/red_radar170.gif +0 -0
- data/{images → medias/tk/images}/red_radar180.gif +0 -0
- data/{images → medias/tk/images}/red_radar190.gif +0 -0
- data/{images → medias/tk/images}/red_radar200.gif +0 -0
- data/{images → medias/tk/images}/red_radar210.gif +0 -0
- data/{images → medias/tk/images}/red_radar220.gif +0 -0
- data/{images → medias/tk/images}/red_radar230.gif +0 -0
- data/{images → medias/tk/images}/red_radar240.gif +0 -0
- data/{images → medias/tk/images}/red_radar250.gif +0 -0
- data/{images → medias/tk/images}/red_radar260.gif +0 -0
- data/{images → medias/tk/images}/red_radar270.gif +0 -0
- data/{images → medias/tk/images}/red_radar280.gif +0 -0
- data/{images → medias/tk/images}/red_radar290.gif +0 -0
- data/{images → medias/tk/images}/red_radar300.gif +0 -0
- data/{images → medias/tk/images}/red_radar310.gif +0 -0
- data/{images → medias/tk/images}/red_radar320.gif +0 -0
- data/{images → medias/tk/images}/red_radar330.gif +0 -0
- data/{images → medias/tk/images}/red_radar340.gif +0 -0
- data/{images → medias/tk/images}/red_radar350.gif +0 -0
- data/{images → medias/tk/images}/red_turret000.gif +0 -0
- data/{images → medias/tk/images}/red_turret010.gif +0 -0
- data/{images → medias/tk/images}/red_turret020.gif +0 -0
- data/{images → medias/tk/images}/red_turret030.gif +0 -0
- data/{images → medias/tk/images}/red_turret040.gif +0 -0
- data/{images → medias/tk/images}/red_turret050.gif +0 -0
- data/{images → medias/tk/images}/red_turret060.gif +0 -0
- data/{images → medias/tk/images}/red_turret070.gif +0 -0
- data/{images → medias/tk/images}/red_turret080.gif +0 -0
- data/{images → medias/tk/images}/red_turret090.gif +0 -0
- data/{images → medias/tk/images}/red_turret100.gif +0 -0
- data/{images → medias/tk/images}/red_turret110.gif +0 -0
- data/{images → medias/tk/images}/red_turret120.gif +0 -0
- data/{images → medias/tk/images}/red_turret130.gif +0 -0
- data/{images → medias/tk/images}/red_turret140.gif +0 -0
- data/{images → medias/tk/images}/red_turret150.gif +0 -0
- data/{images → medias/tk/images}/red_turret160.gif +0 -0
- data/{images → medias/tk/images}/red_turret170.gif +0 -0
- data/{images → medias/tk/images}/red_turret180.gif +0 -0
- data/{images → medias/tk/images}/red_turret190.gif +0 -0
- data/{images → medias/tk/images}/red_turret200.gif +0 -0
- data/{images → medias/tk/images}/red_turret210.gif +0 -0
- data/{images → medias/tk/images}/red_turret220.gif +0 -0
- data/{images → medias/tk/images}/red_turret230.gif +0 -0
- data/{images → medias/tk/images}/red_turret240.gif +0 -0
- data/{images → medias/tk/images}/red_turret250.gif +0 -0
- data/{images → medias/tk/images}/red_turret260.gif +0 -0
- data/{images → medias/tk/images}/red_turret270.gif +0 -0
- data/{images → medias/tk/images}/red_turret280.gif +0 -0
- data/{images → medias/tk/images}/red_turret290.gif +0 -0
- data/{images → medias/tk/images}/red_turret300.gif +0 -0
- data/{images → medias/tk/images}/red_turret310.gif +0 -0
- data/{images → medias/tk/images}/red_turret320.gif +0 -0
- data/{images → medias/tk/images}/red_turret330.gif +0 -0
- data/{images → medias/tk/images}/red_turret340.gif +0 -0
- data/{images → medias/tk/images}/red_turret350.gif +0 -0
- data/{images → medias/tk/images}/toolbox.gif +0 -0
- metadata +168 -128
- data/lib/tkarena.rb +0 -194
data/Rakefile
CHANGED
@@ -1,17 +1,20 @@
|
|
1
1
|
require 'rubygems'
|
2
|
+
|
2
3
|
require 'rake'
|
3
4
|
require "rake/clean"
|
4
5
|
require "rake/gempackagetask"
|
6
|
+
require "rake/rdoctask"
|
7
|
+
|
5
8
|
|
6
9
|
spec = Gem::Specification.new do |s|
|
7
10
|
s.name = "UG_RRobots"
|
8
|
-
s.version = "2.
|
11
|
+
s.version = "2.1"
|
9
12
|
s.author = "Simon Kröger, Romain GEORGES"
|
10
13
|
s.email = "dev@ultragreen.net"
|
11
14
|
s.homepage = "http://www.ultragreen.net/projects/rrobots"
|
12
15
|
s.platform = Gem::Platform::RUBY
|
13
16
|
s.summary = "Ultragreen RRobots Fork with new features like toolboxes, config file, gemified"
|
14
|
-
s.files = FileList["{bin,lib,
|
17
|
+
s.files = FileList["{bin,lib,medias,config,doc,contribs,robots}/**/*"].to_a.concat(['COPYRIGHT.txt','Rakefile'])
|
15
18
|
s.require_path = "lib"
|
16
19
|
# s.autorequire = "name"
|
17
20
|
# s.test_files = FileList["{test}/**/*test.rb"].to_a
|
@@ -21,9 +24,22 @@ spec = Gem::Specification.new do |s|
|
|
21
24
|
s.bindir = 'bin'
|
22
25
|
s.executables = ['rrobots','tournament']
|
23
26
|
s.description = "Ultragreen RRobots Fork"
|
24
|
-
s.rdoc_options << '--title' << 'UG RRobots a RRobots project Fork ' << '--main' << 'doc/manual.rdoc' << '--line-numbers' << '--exclude' << 'robots
|
27
|
+
s.rdoc_options << '--title' << 'UG RRobots a RRobots project Fork ' << '--main' << 'doc/manual.rdoc' << '--line-numbers' << '--exclude' << 'contribs robots medias' << '--diagram'
|
25
28
|
end
|
29
|
+
|
26
30
|
|
27
31
|
Rake::GemPackageTask.new(spec) do |pkg|
|
28
32
|
pkg.need_tar = true
|
29
|
-
end
|
33
|
+
end
|
34
|
+
|
35
|
+
Rake::RDocTask.new('rdoc') do |d|
|
36
|
+
d.rdoc_files.include('doc/**/*','lib/**/*.rb','bin/*')
|
37
|
+
d.main = 'doc/manual.rdoc'
|
38
|
+
d.title = 'UG RRobots a RRobots project Fork '
|
39
|
+
d.options << '--line-numbers' << '--exclude' << 'contribs robots medias' << '--diagram' << '-SHN'
|
40
|
+
end
|
41
|
+
|
42
|
+
task :default => [:gem]
|
43
|
+
|
44
|
+
|
45
|
+
|
data/bin/rrobots
CHANGED
@@ -40,6 +40,7 @@ require 'battlefield'
|
|
40
40
|
|
41
41
|
|
42
42
|
init_I18n get_locale_from_env
|
43
|
+
@locales = I18n.backend.available_locales
|
43
44
|
|
44
45
|
##############################################
|
45
46
|
# arena
|
@@ -66,21 +67,12 @@ def run_out_of_gui(battlefield)
|
|
66
67
|
end
|
67
68
|
|
68
69
|
def run_in_gui(battlefield, xres, yres, speed_multiplier)
|
69
|
-
require
|
70
|
-
|
71
|
-
game_over_counter = battlefield.teams.all?{|k,t| t.size < 2} ? 250 : 500
|
72
|
-
outcome_printed = false
|
73
|
-
arena.on_game_over{|battlefield|
|
74
|
-
unless outcome_printed
|
75
|
-
print_outcome(battlefield)
|
76
|
-
outcome_printed = true
|
77
|
-
end
|
78
|
-
exit 0 if game_over_counter < 0
|
79
|
-
game_over_counter -= 1
|
80
|
-
}
|
81
|
-
arena.run
|
70
|
+
require "GUI/#{@engine}"
|
71
|
+
load_gui(battlefield, xres, yres, speed_multiplier)
|
82
72
|
end
|
83
73
|
|
74
|
+
|
75
|
+
|
84
76
|
def print_outcome(battlefield)
|
85
77
|
winners = battlefield.robots.find_all{|robot| !robot.dead}
|
86
78
|
puts
|
@@ -121,7 +113,15 @@ def print_outcome(battlefield)
|
|
121
113
|
end
|
122
114
|
|
123
115
|
|
124
|
-
|
116
|
+
def array_gui_engines
|
117
|
+
my_res = Array::new
|
118
|
+
engines_path = gem_path('lib')
|
119
|
+
Dir["#{engines_path}/GUI/*.rb"].each {|file|
|
120
|
+
engine = File.basename(file, ".rb")
|
121
|
+
my_res.push engine
|
122
|
+
}
|
123
|
+
return my_res
|
124
|
+
end
|
125
125
|
|
126
126
|
def hash_internals
|
127
127
|
my_res = Hash::new
|
@@ -142,21 +142,45 @@ def list_internals
|
|
142
142
|
end
|
143
143
|
end
|
144
144
|
|
145
|
+
def list_gui_engines
|
146
|
+
title = I18n.t('rrobots.list_gui_engines_title')
|
147
|
+
puts title
|
148
|
+
puts "-"*title.size
|
149
|
+
array_gui_engines.each do |value|
|
150
|
+
puts " - #{value}"
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
145
154
|
def list_locales
|
146
155
|
title = I18n.t('rrobots.list_locales_title')
|
147
156
|
puts title
|
148
157
|
puts "-"*title.size
|
149
|
-
|
158
|
+
@locales.each do |value|
|
150
159
|
puts " - #{value}"
|
151
160
|
end
|
152
161
|
end
|
153
162
|
|
154
163
|
$stdout.sync = true
|
155
164
|
|
165
|
+
@engine = 'tk'
|
166
|
+
ARGV.grep( /^-set-gui-engine=(\w+)/ ) do |item|
|
167
|
+
x = $1.to_s
|
168
|
+
if array_gui_engines.include?(x) then
|
169
|
+
@engine=x
|
170
|
+
else
|
171
|
+
puts I18n.t('rrobots.gui_engine_not_found')
|
172
|
+
end
|
173
|
+
ARGV.delete(item)
|
174
|
+
end
|
175
|
+
|
156
176
|
|
157
|
-
ARGV.grep( /^-set-locale=(\w{2})/ )do |item|
|
177
|
+
ARGV.grep( /^-set-locale=(\w{2})/ ) do |item|
|
158
178
|
x = $1.to_s
|
159
|
-
|
179
|
+
if @locales.include?(x) then
|
180
|
+
I18n.locale=x
|
181
|
+
else
|
182
|
+
I18n.locale='en'
|
183
|
+
end
|
160
184
|
ARGV.delete(item)
|
161
185
|
end
|
162
186
|
|
@@ -166,6 +190,13 @@ ARGV.grep(/^(-list-internals)/) do |item|
|
|
166
190
|
exit 0
|
167
191
|
end
|
168
192
|
|
193
|
+
# look for query for robots internal list
|
194
|
+
ARGV.grep(/^(-list-gui-engines)/) do |item|
|
195
|
+
list_gui_engines
|
196
|
+
exit 0
|
197
|
+
end
|
198
|
+
|
199
|
+
|
169
200
|
# look for query for robots internal list
|
170
201
|
ARGV.grep(/^(-manual)/) do |item|
|
171
202
|
manual_file = "manual.rdoc"
|
data/config/locales/en.yml
CHANGED
@@ -2,11 +2,13 @@
|
|
2
2
|
en:
|
3
3
|
rrobots:
|
4
4
|
list_internals_title: List of avaibles internals robots
|
5
|
-
list_locales_title: List of
|
5
|
+
list_locales_title: List of avaibles locales
|
6
|
+
list_gui_engines_title: List of avaibles GUI Engines
|
6
7
|
match_limit_warning: match ends if only 1 bot/team left or dots get here-->|
|
8
|
+
gui_engine_not_found: The GUI Engine you have requested not exist
|
7
9
|
battlefield:
|
8
10
|
robot_made_an_exception: '{{robot}} made an exception'
|
9
|
-
|
11
|
+
gui:
|
10
12
|
ai_name_dead: '{{ai_name}} dead'
|
11
13
|
draw: "Draw!"
|
12
14
|
no_team_wonn: ' won!'
|
data/config/locales/fr.yml
CHANGED
@@ -3,10 +3,12 @@ fr:
|
|
3
3
|
rrobots:
|
4
4
|
list_internals_title: Liste des robots disponibles en interne
|
5
5
|
list_locales_title: Liste des locales disponibles
|
6
|
+
list_gui_engines_title: Listes des moteur GUI disponibles
|
6
7
|
match_limit_warning: fin si 1 robot/equipe survi(e) ou ligne jusqu'ici -->|
|
8
|
+
gui_engine_not_found: The GUI Engine you have requested not exist
|
7
9
|
battlefield:
|
8
10
|
robot_made_an_exception: '{{robot}} a lev� une exception'
|
9
|
-
|
11
|
+
gui:
|
10
12
|
ai_name_dead: '{{ai_name}} d�truit'
|
11
13
|
draw: Match nul !
|
12
14
|
no_team_won: '{{winner_name}} a gagn� !'
|
data/doc/install.rdoc
CHANGED
@@ -13,11 +13,11 @@ Files are sort by release
|
|
13
13
|
|
14
14
|
*Info* : this step is mandatory only if you choose to download TGZ sources
|
15
15
|
|
16
|
-
Exemple version 2.
|
16
|
+
Exemple version 2.1 :
|
17
17
|
|
18
|
-
$ wget http://www.ultragreen.net/attachments/download/51/UG_RRobots-2.
|
19
|
-
$ tar xvzf G_RRobots-2.
|
20
|
-
$ cd UG_RRobots-2.
|
18
|
+
$ wget http://www.ultragreen.net/attachments/download/51/UG_RRobots-2.1.tgz
|
19
|
+
$ tar xvzf G_RRobots-2.1.tgz
|
20
|
+
$ cd UG_RRobots-2.1/
|
21
21
|
$ rake clean
|
22
22
|
$ rake clobber
|
23
23
|
$ rake gem
|
@@ -31,14 +31,14 @@ If you create your gem, please do :
|
|
31
31
|
|
32
32
|
otherwise
|
33
33
|
|
34
|
-
$ wget http://www.ultragreen.net/attachments/download/52/UG_RRobots-2.
|
34
|
+
$ wget http://www.ultragreen.net/attachments/download/52/UG_RRobots-2.1.gem
|
35
35
|
|
36
36
|
== Gem Installation
|
37
37
|
|
38
38
|
You should be root
|
39
39
|
|
40
40
|
$ sudo bash
|
41
|
-
# gem install UG_RRobots-2.
|
41
|
+
# gem install UG_RRobots-2.1.gem
|
42
42
|
|
43
43
|
deinstallation :
|
44
44
|
|
@@ -52,26 +52,26 @@ deinstallation :
|
|
52
52
|
YAML file : rrobots.yaml
|
53
53
|
|
54
54
|
battlefield:
|
55
|
-
|
56
|
-
|
55
|
+
width: 800
|
56
|
+
height: 800
|
57
57
|
bullets:
|
58
|
-
|
58
|
+
speed: 30
|
59
59
|
filename: rrobots.yml
|
60
60
|
game:
|
61
|
-
|
61
|
+
timeout: 50000
|
62
62
|
mines:
|
63
|
-
|
64
|
-
|
65
|
-
|
63
|
+
with_mines: false
|
64
|
+
bullet_energy_resistance: 2
|
65
|
+
energy_hit_points: 20
|
66
66
|
robots:
|
67
|
-
|
68
|
-
|
69
|
-
|
67
|
+
nb_mines: 3
|
68
|
+
radar_mine_scanning_performance: 500
|
69
|
+
energy_max: 100
|
70
70
|
toolboxes:
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
71
|
+
energy_heal_points: 20
|
72
|
+
life_time: 200
|
73
|
+
with_toolboxes: false
|
74
|
+
spawning_chances: 100
|
75
75
|
|
76
76
|
|
77
77
|
=== Config file reading order and priority
|
data/doc/install_fr.rdoc
CHANGED
@@ -13,11 +13,11 @@ Les fichiers sont classés par Release
|
|
13
13
|
|
14
14
|
*Remarque* : Cette étape n'est necessaire que si on choisit de télécharger les sources
|
15
15
|
|
16
|
-
Exemple version 2.
|
16
|
+
Exemple version 2.1 :
|
17
17
|
|
18
|
-
$ wget http://www.ultragreen.net/attachments/download/51/UG_RRobots-2.
|
19
|
-
$ tar xvzf G_RRobots-2.
|
20
|
-
$ cd UG_RRobots-2.
|
18
|
+
$ wget http://www.ultragreen.net/attachments/download/51/UG_RRobots-2.1.tgz
|
19
|
+
$ tar xvzf G_RRobots-2.1.tgz
|
20
|
+
$ cd UG_RRobots-2.1/
|
21
21
|
$ rake clean
|
22
22
|
$ rake clobber
|
23
23
|
$ rake gem
|
@@ -30,14 +30,14 @@ si vous installez depuis le gem fraîchement crée la partie wget du Rubygem est
|
|
30
30
|
|
31
31
|
sinon pour récupéré le gem
|
32
32
|
|
33
|
-
$ wget http://www.ultragreen.net/attachments/download/52/UG_RRobots-2.
|
33
|
+
$ wget http://www.ultragreen.net/attachments/download/52/UG_RRobots-2.1.gem
|
34
34
|
|
35
35
|
== Installation gem
|
36
36
|
|
37
37
|
On doit être root pour installer :
|
38
38
|
|
39
39
|
$ sudo bash
|
40
|
-
# gem install UG_RRobots-2.
|
40
|
+
# gem install UG_RRobots-2.1.gem
|
41
41
|
|
42
42
|
Pour désinstaller :
|
43
43
|
|
@@ -52,26 +52,26 @@ Pour désinstaller :
|
|
52
52
|
fichier YAML : rrobots.yaml
|
53
53
|
|
54
54
|
battlefield:
|
55
|
-
|
56
|
-
|
55
|
+
width: 800
|
56
|
+
height: 800
|
57
57
|
bullets:
|
58
|
-
|
58
|
+
speed: 30
|
59
59
|
filename: rrobots.yml
|
60
60
|
game:
|
61
|
-
|
61
|
+
timeout: 50000
|
62
62
|
mines:
|
63
|
-
|
64
|
-
|
65
|
-
|
63
|
+
with_mines: false
|
64
|
+
bullet_energy_resistance: 2
|
65
|
+
energy_hit_points: 20
|
66
66
|
robots:
|
67
|
-
|
68
|
-
|
69
|
-
|
67
|
+
nb_mines: 3
|
68
|
+
radar_mine_scanning_performance: 500
|
69
|
+
energy_max: 100
|
70
70
|
toolboxes:
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
71
|
+
energy_heal_points: 20
|
72
|
+
life_time: 200
|
73
|
+
with_toolboxes: false
|
74
|
+
spawning_chances: 100
|
75
75
|
|
76
76
|
|
77
77
|
=== priorité de lecture des fichiers
|
data/lib/GUI/gosu.rb
ADDED
@@ -0,0 +1,237 @@
|
|
1
|
+
def load_gui(battlefield, xres, yres, speed_multiplier)
|
2
|
+
arena = GUI::RRobotsGameWindow.new(battlefield, xres, yres)
|
3
|
+
game_over_counter = battlefield.teams.all?{|k,t| t.size < 2} ? 250 : 500
|
4
|
+
outcome_printed = false
|
5
|
+
arena.on_game_over{|battlefield|
|
6
|
+
unless outcome_printed
|
7
|
+
print_outcome(battlefield)
|
8
|
+
outcome_printed = true
|
9
|
+
end
|
10
|
+
if game_over_counter < 0
|
11
|
+
arena.close
|
12
|
+
exit 0
|
13
|
+
end
|
14
|
+
game_over_counter -= 1
|
15
|
+
}
|
16
|
+
arena.show
|
17
|
+
end
|
18
|
+
|
19
|
+
require 'gosu'
|
20
|
+
|
21
|
+
module GUI
|
22
|
+
|
23
|
+
BIG_FONT = 'PortagoITC TT'
|
24
|
+
SMALL_FONT = 'Monaco'
|
25
|
+
COLORS = ['white', 'blue', 'yellow', 'red', 'lime']
|
26
|
+
FONT_COLORS = [0xffffffff, 0xff0008ff, 0xfffff706, 0xffff0613, 0xff00ff04]
|
27
|
+
|
28
|
+
BUTTONS = [Gosu::Button::KbNumpad0, Gosu::Button::KbNumpad1, Gosu::Button::KbNumpad2, Gosu::Button::KbNumpad3, Gosu::Button::KbNumpad4, Gosu::Button::KbNumpad5, Gosu::Button::KbNumpad6, Gosu::Button::KbNumpad7, Gosu::Button::KbNumpad8, Gosu::Button::KbNumpad9, Gosu::Button::KbNumpadMultiply]
|
29
|
+
GosuRobot = Struct.new(:body, :gun, :radar, :speech, :info, :status, :color, :font_color)
|
30
|
+
|
31
|
+
module ZOrder
|
32
|
+
Background, Mines, Toolboxes, Robot, Explosions, UI = *0..5
|
33
|
+
end
|
34
|
+
|
35
|
+
class LeaderBoard
|
36
|
+
def initialize(window, robots, xres, yres, position = :right_top)
|
37
|
+
@font_size = (xres / 45).to_i
|
38
|
+
@position = position
|
39
|
+
@robots = robots
|
40
|
+
@font = Gosu::Font.new(window, BIG_FONT, @font_size)
|
41
|
+
case position
|
42
|
+
when :right_top
|
43
|
+
@x_offset = xres-(@font_size * 9)
|
44
|
+
when :left_top
|
45
|
+
@x_offset = @font_size
|
46
|
+
end
|
47
|
+
@y_offset = @font_size * 2
|
48
|
+
end
|
49
|
+
|
50
|
+
def draw
|
51
|
+
if @robots
|
52
|
+
@robots.sort_by{|k,v| -k.energy}.each_with_index do |r, i|
|
53
|
+
y = @y_offset + (i * (@font_size * 1.5).to_i) - (@font_size * 1.5).to_i
|
54
|
+
@font.draw("#{r.first.name}", @x_offset, y, ZOrder::UI, 1.0, 1.0, r.last.font_color)
|
55
|
+
@font.draw("#{r.first.energy.to_i}", @x_offset + (@font_size * 6), y, ZOrder::UI, 1.0, 1.0, r.last.font_color)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
class RRobotsGameWindow < Gosu::Window
|
62
|
+
|
63
|
+
attr_reader :battlefield, :xres, :yres
|
64
|
+
attr_accessor :on_game_over_handlers
|
65
|
+
attr_accessor :boom, :robots, :bullets, :explosions, :toolboxes, :mines
|
66
|
+
|
67
|
+
def initialize(battlefield, xres, yres)
|
68
|
+
super(xres,yres, false, 16)
|
69
|
+
self.caption = 'RRobots - GOSU POWERED'
|
70
|
+
@font = Gosu::Font.new(self, BIG_FONT, xres / 20)
|
71
|
+
@small_font = Gosu::Font.new(self, SMALL_FONT, xres/100)
|
72
|
+
@engine = 'gosu'
|
73
|
+
@path_prefix = "#{gem_path}/medias/#{@engine}"
|
74
|
+
@background_image = Gosu::Image.new(self, "#{@path_prefix}/images/space.png", true)
|
75
|
+
@battlefield = battlefield
|
76
|
+
@xres, @yres = xres, yres
|
77
|
+
@on_game_over_handlers = []
|
78
|
+
init_window
|
79
|
+
init_simulation
|
80
|
+
@leaderboard = LeaderBoard.new(self, @robots, xres, yres, :left_top)
|
81
|
+
|
82
|
+
# for ultimate win
|
83
|
+
#@theme = Gosu::Song.new(self, 'music/song.mod')
|
84
|
+
#@theme.play
|
85
|
+
@sound_boom = Gosu::Sample.new(self, "#{@path_prefix}/sounds/sunexp.wav")
|
86
|
+
@sound_gun = Gosu::Sample.new(self, "#{@path_prefix}/sounds/shotborn.wav")
|
87
|
+
end
|
88
|
+
|
89
|
+
def on_game_over(&block)
|
90
|
+
@on_game_over_handlers << block
|
91
|
+
end
|
92
|
+
|
93
|
+
def init_window
|
94
|
+
@boom = (0..14).map do |i|
|
95
|
+
Gosu::Image.new(self, "#{@path_prefix}/images/explosion#{i.to_s.rjust(2, '0')}.bmp")
|
96
|
+
end
|
97
|
+
@bullet_image = Gosu::Image.new(self, "#{@path_prefix}/images/bullet.png")
|
98
|
+
@mine_image = Gosu::Image.new(self, "#{@path_prefix}/images/mine.png")
|
99
|
+
@toolbox_image = Gosu::Image.new(self, "#{@path_prefix}/images/toolbox.png")
|
100
|
+
end
|
101
|
+
|
102
|
+
def init_simulation
|
103
|
+
@robots, @bullets, @explosions, @toolboxes, @mines = {}, {}, {}, {}, {}
|
104
|
+
end
|
105
|
+
|
106
|
+
|
107
|
+
def draw
|
108
|
+
robot_keys
|
109
|
+
simulate
|
110
|
+
draw_battlefield
|
111
|
+
play_sounds
|
112
|
+
@leaderboard.draw
|
113
|
+
if button_down? Gosu::Button::KbEscape
|
114
|
+
self.close
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
def robot_keys
|
119
|
+
pressed = []
|
120
|
+
BUTTONS.each do |b|
|
121
|
+
pressed << b if button_down?(b)
|
122
|
+
end
|
123
|
+
@battlefield.robots.each do |ai|
|
124
|
+
ai.pressed_button(pressed)
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
def play_sounds
|
129
|
+
@battlefield.robots.each do |ai|
|
130
|
+
if !ai.robot.events['got_hit'].empty?
|
131
|
+
pan = -1.0 + (2.0 * ai.x / @battlefield.width)
|
132
|
+
@sound_boom.play_pan(pan, 0.4)
|
133
|
+
end
|
134
|
+
|
135
|
+
if ai.actions[:fire] > 0 && ai.gun_heat <= 0
|
136
|
+
pan = -1.0 + (2.0 * ai.x / @battlefield.width)
|
137
|
+
@sound_gun.play_pan(pan, [ai.actions[:fire]*3, 1].min)
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
def draw_battlefield
|
143
|
+
draw_robots
|
144
|
+
draw_bullets
|
145
|
+
draw_explosions
|
146
|
+
draw_mines
|
147
|
+
draw_toolboxes
|
148
|
+
end
|
149
|
+
|
150
|
+
def simulate(ticks=1)
|
151
|
+
@explosions.reject!{|e,tko| e.dead }
|
152
|
+
@bullets.reject!{|b,tko| b.dead }
|
153
|
+
@robots.reject! { |ai,tko| ai.dead}
|
154
|
+
@mines.reject! { |m,tko| m.dead}
|
155
|
+
@toolboxes.reject! { |t,tko| t.dead}
|
156
|
+
ticks.times do
|
157
|
+
if @battlefield.game_over
|
158
|
+
@on_game_over_handlers.each{|h| h.call(@battlefield) }
|
159
|
+
winner = @robots.keys.first
|
160
|
+
whohaswon = if winner.nil?
|
161
|
+
I18n.t('gui.draw')
|
162
|
+
elsif @battlefield.teams.all?{|k,t|t.size<2}
|
163
|
+
I18n.t('gui.no_team_won', :winner_name => winner.name)
|
164
|
+
else
|
165
|
+
I18n.t('gui.team_won', :winner_team => winner.team)
|
166
|
+
end
|
167
|
+
text_color = winner ? winner.team : 7
|
168
|
+
@font.draw_rel("#{whohaswon}", xres/2, yres/2, ZOrder::UI, 0.5, 0.5, 1, 1, 0xffffff00)
|
169
|
+
end
|
170
|
+
@battlefield.tick
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
def draw_robots
|
175
|
+
@battlefield.robots.each_with_index do |ai, i|
|
176
|
+
next if ai.dead
|
177
|
+
col = COLORS[i % COLORS.size]
|
178
|
+
font_col = FONT_COLORS[i % FONT_COLORS.size]
|
179
|
+
@robots[ai] ||= GosuRobot.new(
|
180
|
+
Gosu::Image.new(self, "#{@path_prefix}/images/#{col}_body000.bmp"),
|
181
|
+
Gosu::Image.new(self, "#{@path_prefix}/images/#{col}_turret000.bmp"),
|
182
|
+
Gosu::Image.new(self, "#{@path_prefix}/images/#{col}_radar000.bmp"),
|
183
|
+
@small_font,
|
184
|
+
@small_font,
|
185
|
+
@small_font,
|
186
|
+
col,
|
187
|
+
font_col
|
188
|
+
)
|
189
|
+
|
190
|
+
@robots[ai].body.draw_rot(ai.x / 2, ai.y / 2, ZOrder::Robot, (-(ai.heading-90)) % 360)
|
191
|
+
@robots[ai].gun.draw_rot(ai.x / 2, ai.y / 2, ZOrder::Robot, (-(ai.gun_heading-90)) % 360)
|
192
|
+
@robots[ai].radar.draw_rot(ai.x / 2, ai.y / 2, ZOrder::Robot, (-(ai.radar_heading-90)) % 360)
|
193
|
+
|
194
|
+
if @talkative
|
195
|
+
@robots[ai].info.draw("#{ai.name}\n#{'|' * (ai.energy / 5)}",
|
196
|
+
ai.x / 2 - 50, ai.y / 2 + 30, ZOrder::UI, 1.0, 1.0, font_col)
|
197
|
+
@robots[ai].status.draw("#{ai.name.ljust(20)} #{'%.1f' % ai.energy}",
|
198
|
+
ai.x / 2 - 50, ai.y / 2 + 30, ZOrder::UI, 1.0, 1.0, font_col)
|
199
|
+
else
|
200
|
+
@robots[ai].speech.draw_rel(ai.speech.to_s, ai.x / 2, ai.y / 2 - 40, ZOrder::UI, 0.5, 0.5, 1, 1, font_col)
|
201
|
+
@robots[ai].info.draw_rel("#{ai.name}", ai.x / 2, ai.y / 2 + 30, ZOrder::UI, 0.5, 0.5, 1, 1, font_col)
|
202
|
+
end
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
206
|
+
def draw_bullets
|
207
|
+
@battlefield.bullets.each do |bullet|
|
208
|
+
@bullets[bullet] ||= @bullet_image
|
209
|
+
@bullets[bullet].draw(bullet.x / 2, bullet.y / 2, ZOrder::Explosions)
|
210
|
+
end
|
211
|
+
end
|
212
|
+
|
213
|
+
def draw_explosions
|
214
|
+
@battlefield.explosions.each do |explosion|
|
215
|
+
@explosions[explosion] = boom[explosion.t % 14]
|
216
|
+
@explosions[explosion].draw_rot(explosion.x / 2, explosion.y / 2, ZOrder::Explosions, 0)
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
220
|
+
def draw_toolboxes
|
221
|
+
@battlefield.toolboxes.each do |toolbox|
|
222
|
+
@toolboxes[toolbox] ||= @toolbox_image
|
223
|
+
@toolboxes[toolbox].draw(toolbox.x / 2, toolbox.y / 2, ZOrder::Toolboxes)
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
227
|
+
def draw_mines
|
228
|
+
@battlefield.mines.each do |mine|
|
229
|
+
@mines[mine] ||= @mine_image
|
230
|
+
@mines[mine].draw(mine.x / 2, mine.y / 2, ZOrder::Mines)
|
231
|
+
end
|
232
|
+
end
|
233
|
+
|
234
|
+
end
|
235
|
+
|
236
|
+
end
|
237
|
+
|