lotu 0.1.15 → 0.1.16
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/examples/{hello_world → 01_hello_world}/moving_portraits.rb +5 -3
- data/examples/{screen_cursor → 02_screen_cursor}/mouse_and_keyboard_cursors.rb +6 -26
- data/examples/03_collisions/box.rb +83 -0
- data/examples/{steering_behaviors → 04_steering_behaviors}/pursuit_and_evade.rb +4 -23
- data/examples/{steering_behaviors → 04_steering_behaviors}/pursuit_and_evade_multiple.rb +4 -23
- data/lib/lotu/actor.rb +21 -13
- data/lib/lotu/behavior.rb +19 -0
- data/lib/lotu/behaviors/collidable.rb +28 -7
- data/lib/lotu/behaviors/controllable.rb +1 -1
- data/lib/lotu/behaviors/eventful.rb +2 -5
- data/lib/lotu/behaviors/resource_manager.rb +104 -0
- data/lib/lotu/behaviors/system_user.rb +41 -3
- data/lib/lotu/game.rb +27 -116
- data/lib/lotu/helpers/kernel.rb +8 -0
- data/lib/lotu/{misc → helpers}/string.rb +0 -0
- data/lib/lotu/{misc → helpers}/vector2d.rb +1 -1
- data/lib/lotu/systems/animation_system.rb +3 -3
- data/lib/lotu/{system.rb → systems/base_system.rb} +3 -2
- data/lib/lotu/systems/collision_system.rb +1 -1
- data/lib/lotu/systems/{input_system.rb → input_manager_system.rb} +4 -4
- data/lib/lotu/systems/interpolation_system.rb +1 -1
- data/lib/lotu/systems/stalker_system.rb +1 -1
- data/lib/lotu/systems/steering_system.rb +2 -2
- data/lib/lotu/text_box.rb +8 -3
- data/lib/lotu.rb +6 -4
- data/lotu.gemspec +21 -15
- data/spec/lotu/actor_spec.rb +36 -0
- data/spec/lotu/game_spec.rb +22 -15
- data/spec/lotu/shared_spec.rb +41 -0
- metadata +25 -19
- data/lib/lotu/systems/fps_system.rb +0 -31
data/lib/lotu/game.rb
CHANGED
@@ -1,12 +1,17 @@
|
|
1
1
|
module Lotu
|
2
2
|
class Game < Gosu::Window
|
3
|
-
|
4
|
-
|
3
|
+
extend Behavior
|
4
|
+
|
5
|
+
behave_like SystemUser
|
6
|
+
use InputManagerSystem
|
7
|
+
|
8
|
+
behave_like ResourceManager
|
9
|
+
|
10
|
+
# Accessors for elapsed time since last update (time delta) and fonts
|
11
|
+
attr_reader :dt
|
5
12
|
# Accessors for queues
|
6
13
|
attr_accessor :update_queue, :draw_queue, :input_listeners
|
7
14
|
|
8
|
-
include SystemUser
|
9
|
-
|
10
15
|
def initialize(opts={})
|
11
16
|
default_opts = {
|
12
17
|
:width => 1024,
|
@@ -24,14 +29,19 @@ module Lotu
|
|
24
29
|
|
25
30
|
# For timer initialization
|
26
31
|
@last_time = Gosu::milliseconds
|
27
|
-
|
28
|
-
|
32
|
+
|
33
|
+
# so it can start behaving
|
34
|
+
init_behavior opts
|
29
35
|
|
30
36
|
# Call hook methods
|
31
37
|
load_resources
|
32
|
-
setup_systems
|
33
38
|
setup_actors
|
34
39
|
setup_input
|
40
|
+
setup_events
|
41
|
+
end
|
42
|
+
|
43
|
+
def fps
|
44
|
+
Gosu::fps
|
35
45
|
end
|
36
46
|
|
37
47
|
def pause!
|
@@ -51,13 +61,10 @@ module Lotu
|
|
51
61
|
end
|
52
62
|
|
53
63
|
# Hook methods, these are meant to be replaced by subclasses
|
54
|
-
def load_resources;end
|
55
|
-
def setup_actors;end
|
56
|
-
def setup_input;end
|
57
|
-
|
58
|
-
def setup_systems
|
59
|
-
use(InputSystem)
|
60
|
-
end
|
64
|
+
def load_resources; end
|
65
|
+
def setup_actors; end
|
66
|
+
def setup_input; end
|
67
|
+
def setup_events; end
|
61
68
|
|
62
69
|
# Setup various containers
|
63
70
|
def setup_containers
|
@@ -65,12 +72,6 @@ module Lotu
|
|
65
72
|
@update_queue = []
|
66
73
|
@draw_queue = []
|
67
74
|
@input_register = Hash.new{|hash,key| hash[key] = []}
|
68
|
-
|
69
|
-
# For resource management
|
70
|
-
@images = {}
|
71
|
-
@sounds = {}
|
72
|
-
@songs = {}
|
73
|
-
@animations = Hash.new{|h,k| h[k] = []}
|
74
75
|
end
|
75
76
|
|
76
77
|
# Main update loop
|
@@ -79,10 +80,9 @@ module Lotu
|
|
79
80
|
@dt = (new_time - @last_time)/1000.0
|
80
81
|
@last_time = new_time
|
81
82
|
|
82
|
-
#
|
83
|
-
|
84
|
-
|
85
|
-
end
|
83
|
+
# to call update on behaviors (that in turn wil call
|
84
|
+
# update on systems, for example)
|
85
|
+
super
|
86
86
|
|
87
87
|
# Update each actor
|
88
88
|
@update_queue.each do |actor|
|
@@ -92,10 +92,9 @@ module Lotu
|
|
92
92
|
|
93
93
|
# Main draw loop
|
94
94
|
def draw
|
95
|
-
#
|
96
|
-
|
97
|
-
|
98
|
-
end
|
95
|
+
# to call draw on behaviors (that in turn will call
|
96
|
+
# draw on systems, for example)
|
97
|
+
super
|
99
98
|
|
100
99
|
# Draw each actor in queue
|
101
100
|
@draw_queue.each do |actor|
|
@@ -134,93 +133,5 @@ module Lotu
|
|
134
133
|
@update_queue << controller
|
135
134
|
end
|
136
135
|
|
137
|
-
# These are for managing resources
|
138
|
-
def image(name)
|
139
|
-
@images[name]
|
140
|
-
end
|
141
|
-
|
142
|
-
def sound(name)
|
143
|
-
@sounds[name]
|
144
|
-
end
|
145
|
-
|
146
|
-
def song(name)
|
147
|
-
@songs[name]
|
148
|
-
end
|
149
|
-
|
150
|
-
def animation(name)
|
151
|
-
@animations[name]
|
152
|
-
end
|
153
|
-
|
154
|
-
def load_images(path)
|
155
|
-
count = 0
|
156
|
-
with_files(/\.png$|\.jpg$|\.bmp$/, path) do |file_name, file_path|
|
157
|
-
count += 1
|
158
|
-
@images[file_name] = Gosu::Image.new($lotu, file_path)
|
159
|
-
end
|
160
|
-
puts "\n#{count} image(s) loaded."
|
161
|
-
end
|
162
|
-
|
163
|
-
def load_sounds(path)
|
164
|
-
count = 0
|
165
|
-
with_files(/\.ogg$|\.mp3$|\.wav$/, path) do |file_name, file_path|
|
166
|
-
count += 1
|
167
|
-
@sounds[file_name] = Gosu::Sample.new($lotu, file_path)
|
168
|
-
end
|
169
|
-
puts "\n#{count} sounds(s) loaded."
|
170
|
-
end
|
171
|
-
|
172
|
-
def load_songs(path)
|
173
|
-
count = 0
|
174
|
-
with_files(/\.ogg$|\.mp3$|\.wav$/, path) do |file_name, file_path|
|
175
|
-
count += 1
|
176
|
-
@songs[file_name] = Gosu::Song.new($lotu, file_path)
|
177
|
-
end
|
178
|
-
puts "\n#{count} song(s) loaded."
|
179
|
-
end
|
180
|
-
|
181
|
-
def load_animations(path)
|
182
|
-
count = 0
|
183
|
-
coords = Hash.new{|h,k| h[k] = []}
|
184
|
-
|
185
|
-
with_files(/\.txt$/, path) do |file_name, file_path|
|
186
|
-
name = File.basename(file_name, '.txt')
|
187
|
-
File.open(file_path) do |file|
|
188
|
-
file.lines.each do |line|
|
189
|
-
coords[name] << line.scan(/\d+/).map!(&:to_i)
|
190
|
-
end
|
191
|
-
end
|
192
|
-
false
|
193
|
-
end
|
194
|
-
|
195
|
-
with_files(/\.png$|\.jpg$|\.bmp$/, path) do |file_name, file_path|
|
196
|
-
name, extension = file_name.split('.')
|
197
|
-
count += 1 if coords[name]
|
198
|
-
coords[name].each do |index, x, y, width, height|
|
199
|
-
@animations[file_name] << Gosu::Image.new($lotu, file_path, true, x, y, width, height)
|
200
|
-
end
|
201
|
-
end
|
202
|
-
puts "\n#{count} animation(s) loaded."
|
203
|
-
end
|
204
|
-
|
205
|
-
def with_path_from_file(path, &blk)
|
206
|
-
@path = File.expand_path(File.dirname path)
|
207
|
-
yield
|
208
|
-
end
|
209
|
-
|
210
|
-
def with_files(regexp, path)
|
211
|
-
path = File.expand_path(File.join(@path, path))
|
212
|
-
puts "\nLoading from: #{path}".blue if @debug
|
213
|
-
|
214
|
-
Dir.entries(path).grep(regexp).each do |entry|
|
215
|
-
begin
|
216
|
-
report = yield(entry, File.join(path, entry))
|
217
|
-
print '.'.green if report
|
218
|
-
rescue Exception => e
|
219
|
-
print '.'.red
|
220
|
-
puts e, File.join(path, entry) if @debug
|
221
|
-
end
|
222
|
-
end
|
223
|
-
end
|
224
|
-
|
225
136
|
end
|
226
137
|
end
|
File without changes
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module Lotu
|
2
|
-
class AnimationSystem <
|
2
|
+
class AnimationSystem < BaseSystem
|
3
3
|
|
4
4
|
def initialize(user, opts={})
|
5
5
|
super
|
@@ -40,8 +40,8 @@ module Lotu
|
|
40
40
|
def to_s
|
41
41
|
["Name: #{@name}",
|
42
42
|
"Current frame: #{@current_frame}",
|
43
|
-
"Accumulated time: #{format('%.2f', @accum_time)}",
|
44
|
-
"Time per frame: #{format('%.2f', @time_per_frame)}",
|
43
|
+
"Accumulated time: #{format('%.2f', @accum_time || 0)}",
|
44
|
+
"Time per frame: #{format('%.2f', @time_per_frame || 0)}",
|
45
45
|
"Length: #{@length}"]
|
46
46
|
end
|
47
47
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module Lotu
|
2
|
-
class
|
2
|
+
class InputManagerSystem < BaseSystem
|
3
3
|
|
4
4
|
def initialize(user, opts={})
|
5
5
|
super
|
@@ -59,15 +59,15 @@ module Lotu
|
|
59
59
|
|
60
60
|
module UserMethods
|
61
61
|
def set_keys(keys)
|
62
|
-
systems[
|
62
|
+
systems[InputManagerSystem].set_keys(self, keys)
|
63
63
|
end
|
64
64
|
|
65
65
|
def button_down(key)
|
66
|
-
systems[
|
66
|
+
systems[InputManagerSystem].button_down(key)
|
67
67
|
end
|
68
68
|
|
69
69
|
def button_up(key)
|
70
|
-
systems[
|
70
|
+
systems[InputManagerSystem].button_up(key)
|
71
71
|
end
|
72
72
|
end
|
73
73
|
|
@@ -1,9 +1,10 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
module Lotu
|
3
|
-
class SteeringSystem <
|
3
|
+
class SteeringSystem < BaseSystem
|
4
4
|
|
5
5
|
def initialize(user, opts={})
|
6
6
|
super
|
7
|
+
|
7
8
|
# Add new functionality to Actor
|
8
9
|
@user.extend UserMethods
|
9
10
|
|
@@ -17,7 +18,6 @@ module Lotu
|
|
17
18
|
:wander_distance => 240.0
|
18
19
|
}
|
19
20
|
opts = default_opts.merge!(opts)
|
20
|
-
|
21
21
|
@user.mass = opts[:mass]
|
22
22
|
@user.max_speed = opts[:max_speed]
|
23
23
|
@user.max_turn_rate = opts[:max_turn_rate]
|
data/lib/lotu/text_box.rb
CHANGED
@@ -51,13 +51,18 @@ module Lotu
|
|
51
51
|
@watch_list.each do |watched, opts|
|
52
52
|
my_size = opts[:size] || @size
|
53
53
|
my_color = opts[:color] || @color
|
54
|
-
|
54
|
+
if watched.kind_of?(Proc)
|
55
|
+
my_text = watched.call.to_s
|
56
|
+
else
|
57
|
+
my_text = watched.to_s
|
58
|
+
end
|
59
|
+
|
55
60
|
if my_text.is_a?(String)
|
56
|
-
$lotu.
|
61
|
+
$lotu.default_font[my_size].draw(my_text, @x, @y + pos_y, @z, @factor_x, @factor_y, my_color)
|
57
62
|
pos_y += my_size
|
58
63
|
else
|
59
64
|
my_text.each do |line|
|
60
|
-
$lotu.
|
65
|
+
$lotu.default_font[my_size].draw(line, @x, @y + pos_y, @z, @factor_x, @factor_y, my_color)
|
61
66
|
pos_y += my_size
|
62
67
|
end
|
63
68
|
end
|
data/lib/lotu.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
LOTU_ROOT = File.expand_path(File.join(File.dirname(__FILE__), 'lotu'))
|
2
2
|
$LOAD_PATH.unshift(LOTU_ROOT)
|
3
3
|
|
4
|
+
require 'rubygems'
|
4
5
|
require 'gosu'
|
5
|
-
%w{vector2d string}.each{|file| require "
|
6
|
-
%w{system_user collidable controllable eventful}.each{|file| require "behaviors/#{file}"}
|
7
|
-
%w{
|
8
|
-
%w{
|
6
|
+
%w{vector2d string kernel}.each{|file| require "helpers/#{file}"}
|
7
|
+
%w{resource_manager system_user collidable controllable eventful}.each{|file| require "behaviors/#{file}"}
|
8
|
+
%w{base interpolation animation input_manager stalker collision steering}.map{|s| "#{s}_system"}.each{|file| require "systems/#{file}"}
|
9
|
+
%w{behavior actor cursor text_box game}.each{|file| require file}
|
10
|
+
|
data/lotu.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{lotu}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.16"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["lobo_tuerto"]
|
12
|
-
s.date = %q{2011-02-
|
12
|
+
s.date = %q{2011-02-24}
|
13
13
|
s.description = %q{lotu aims to bring an agile and simple game development framework to life. It provides useful abstractions so you can concentrate on developing your game.}
|
14
14
|
s.email = %q{dev@lobotuerto.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -24,7 +24,11 @@ Gem::Specification.new do |s|
|
|
24
24
|
"README.rdoc",
|
25
25
|
"Rakefile",
|
26
26
|
"VERSION",
|
27
|
-
"examples/
|
27
|
+
"examples/01_hello_world/moving_portraits.rb",
|
28
|
+
"examples/02_screen_cursor/mouse_and_keyboard_cursors.rb",
|
29
|
+
"examples/03_collisions/box.rb",
|
30
|
+
"examples/04_steering_behaviors/pursuit_and_evade.rb",
|
31
|
+
"examples/04_steering_behaviors/pursuit_and_evade_multiple.rb",
|
28
32
|
"examples/media/animations/missile.png",
|
29
33
|
"examples/media/animations/missile.txt",
|
30
34
|
"examples/media/images/cohete-big.png",
|
@@ -36,24 +40,23 @@ Gem::Specification.new do |s|
|
|
36
40
|
"examples/media/images/lobo_tuerto.png",
|
37
41
|
"examples/media/images/missile-med.png",
|
38
42
|
"examples/media/images/silo.png",
|
39
|
-
"examples/screen_cursor/mouse_and_keyboard_cursors.rb",
|
40
|
-
"examples/steering_behaviors/pursuit_and_evade.rb",
|
41
|
-
"examples/steering_behaviors/pursuit_and_evade_multiple.rb",
|
42
43
|
"lib/lotu.rb",
|
43
44
|
"lib/lotu/actor.rb",
|
45
|
+
"lib/lotu/behavior.rb",
|
44
46
|
"lib/lotu/behaviors/collidable.rb",
|
45
47
|
"lib/lotu/behaviors/controllable.rb",
|
46
48
|
"lib/lotu/behaviors/eventful.rb",
|
49
|
+
"lib/lotu/behaviors/resource_manager.rb",
|
47
50
|
"lib/lotu/behaviors/system_user.rb",
|
48
51
|
"lib/lotu/cursor.rb",
|
49
52
|
"lib/lotu/game.rb",
|
50
|
-
"lib/lotu/
|
51
|
-
"lib/lotu/
|
52
|
-
"lib/lotu/
|
53
|
+
"lib/lotu/helpers/kernel.rb",
|
54
|
+
"lib/lotu/helpers/string.rb",
|
55
|
+
"lib/lotu/helpers/vector2d.rb",
|
53
56
|
"lib/lotu/systems/animation_system.rb",
|
57
|
+
"lib/lotu/systems/base_system.rb",
|
54
58
|
"lib/lotu/systems/collision_system.rb",
|
55
|
-
"lib/lotu/systems/
|
56
|
-
"lib/lotu/systems/input_system.rb",
|
59
|
+
"lib/lotu/systems/input_manager_system.rb",
|
57
60
|
"lib/lotu/systems/interpolation_system.rb",
|
58
61
|
"lib/lotu/systems/stalker_system.rb",
|
59
62
|
"lib/lotu/systems/steering_system.rb",
|
@@ -61,6 +64,7 @@ Gem::Specification.new do |s|
|
|
61
64
|
"lotu.gemspec",
|
62
65
|
"spec/lotu/actor_spec.rb",
|
63
66
|
"spec/lotu/game_spec.rb",
|
67
|
+
"spec/lotu/shared_spec.rb",
|
64
68
|
"test/actor_test.rb"
|
65
69
|
]
|
66
70
|
s.homepage = %q{http://github.com/lobo-tuerto/lotu}
|
@@ -68,12 +72,14 @@ Gem::Specification.new do |s|
|
|
68
72
|
s.rubygems_version = %q{1.5.0}
|
69
73
|
s.summary = %q{A simple, agile Ruby game development framework.}
|
70
74
|
s.test_files = [
|
71
|
-
"examples/
|
72
|
-
"examples/
|
73
|
-
"examples/
|
74
|
-
"examples/
|
75
|
+
"examples/01_hello_world/moving_portraits.rb",
|
76
|
+
"examples/02_screen_cursor/mouse_and_keyboard_cursors.rb",
|
77
|
+
"examples/03_collisions/box.rb",
|
78
|
+
"examples/04_steering_behaviors/pursuit_and_evade.rb",
|
79
|
+
"examples/04_steering_behaviors/pursuit_and_evade_multiple.rb",
|
75
80
|
"spec/lotu/actor_spec.rb",
|
76
81
|
"spec/lotu/game_spec.rb",
|
82
|
+
"spec/lotu/shared_spec.rb",
|
77
83
|
"test/actor_test.rb"
|
78
84
|
]
|
79
85
|
|
data/spec/lotu/actor_spec.rb
CHANGED
@@ -1,15 +1,51 @@
|
|
1
1
|
require 'lotu'
|
2
2
|
|
3
|
+
class Actress < Lotu::Actor
|
4
|
+
use Lotu::SteeringSystem
|
5
|
+
end
|
6
|
+
|
3
7
|
describe "Actor" do
|
8
|
+
|
4
9
|
before :each do
|
5
10
|
@game = Lotu::Game.new
|
6
11
|
@actor = Lotu::Actor.new
|
12
|
+
@actress = Actress.new
|
13
|
+
@user = @actor
|
7
14
|
end
|
8
15
|
|
9
16
|
after :each do
|
10
17
|
@actor.die
|
11
18
|
end
|
12
19
|
|
20
|
+
describe "Behavior" do
|
21
|
+
it_should_behave_like "system user"
|
22
|
+
it_should_behave_like "eventful"
|
23
|
+
it_should_behave_like "collidable"
|
24
|
+
it_should_behave_like "controllable"
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "Descendants" do
|
28
|
+
it "should have a different object hash for behavior_options" do
|
29
|
+
@actress.class.behavior_options[Actress].should_not be @actor.class.behavior_options[Lotu::Actor]
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should have different values in behavior_options" do
|
33
|
+
@actress.class.behavior_options[Actress].should_not == @actor.class.behavior_options[Lotu::Actor]
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should have the appropiate number of systems" do
|
38
|
+
@actor.systems.length.should be 2
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should have the appropiate type of systems" do
|
42
|
+
@actor.systems.keys.should == [Lotu::AnimationSystem, Lotu::InterpolationSystem]
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should have the appropiate behavior options set" do
|
46
|
+
@actor.class.behavior_options.should == {Lotu::SystemUser=>{Lotu::AnimationSystem=>{}, Lotu::InterpolationSystem=>{}}, Lotu::Collidable=>{}}
|
47
|
+
end
|
48
|
+
|
13
49
|
it{ @actor.should respond_to :x }
|
14
50
|
it{ @actor.should respond_to :y }
|
15
51
|
it{ @actor.should respond_to :parent }
|
data/spec/lotu/game_spec.rb
CHANGED
@@ -1,13 +1,32 @@
|
|
1
1
|
require 'lotu'
|
2
2
|
|
3
3
|
describe "Game" do
|
4
|
-
|
5
|
-
|
4
|
+
it_should_behave_like "system user"
|
5
|
+
it_should_behave_like "resource manager"
|
6
|
+
|
7
|
+
before :all do
|
8
|
+
@game = Lotu::Game.new #:debug => true
|
9
|
+
@game.with_path_from_file(__FILE__) do |g|
|
10
|
+
load_images '../../examples/media/images'
|
11
|
+
end
|
12
|
+
|
13
|
+
@user = @game
|
6
14
|
end
|
7
15
|
|
8
|
-
it{ @game.should respond_to :close }
|
9
16
|
it{ @game.should respond_to :update }
|
10
17
|
it{ @game.should respond_to :draw }
|
18
|
+
it{ @game.should respond_to :dt }
|
19
|
+
it{ @game.should respond_to :update_queue }
|
20
|
+
it{ @game.should respond_to :draw_queue }
|
21
|
+
it{ @game.should respond_to :image }
|
22
|
+
it{ @game.should respond_to :sound }
|
23
|
+
it{ @game.should respond_to :song }
|
24
|
+
it{ @game.should respond_to :animation }
|
25
|
+
it{ @game.should respond_to :load_images }
|
26
|
+
it{ @game.should respond_to :load_sounds }
|
27
|
+
it{ @game.should respond_to :load_songs }
|
28
|
+
it{ @game.should respond_to :load_animations }
|
29
|
+
it{ @game.should respond_to :fps }
|
11
30
|
|
12
31
|
describe "every game tick" do
|
13
32
|
before :each do
|
@@ -30,15 +49,3 @@ describe "Game" do
|
|
30
49
|
end
|
31
50
|
|
32
51
|
end
|
33
|
-
|
34
|
-
%Q{
|
35
|
-
1.upto(100) do |i|
|
36
|
-
if i % 3 == 0 || i % 5 == 0
|
37
|
-
print 'Fizz' if i % 3 == 0
|
38
|
-
print 'Buzz' if i % 5 == 0
|
39
|
-
else
|
40
|
-
print i
|
41
|
-
end
|
42
|
-
print "\n"
|
43
|
-
end
|
44
|
-
}.size
|
@@ -0,0 +1,41 @@
|
|
1
|
+
shared_examples_for "system user" do
|
2
|
+
it{ @user.should be_kind_of Lotu::SystemUser }
|
3
|
+
describe "the user class" do
|
4
|
+
it{ @user.class.should respond_to :use }
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
shared_examples_for "eventful" do
|
9
|
+
it{ @user.should be_kind_of Lotu::Eventful }
|
10
|
+
it{ @user.should respond_to :on }
|
11
|
+
it{ @user.should respond_to :fire }
|
12
|
+
end
|
13
|
+
|
14
|
+
shared_examples_for "collidable" do
|
15
|
+
it{ @user.should be_kind_of Lotu::Collidable }
|
16
|
+
it{ @user.should respond_to :collides_with }
|
17
|
+
describe "the user class" do
|
18
|
+
it{ @user.class.should respond_to :collides_as }
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
shared_examples_for "controllable" do
|
23
|
+
it{ @user.should be_kind_of Lotu::Controllable }
|
24
|
+
it{ @user.should respond_to :set_keys }
|
25
|
+
end
|
26
|
+
|
27
|
+
shared_examples_for "resource manager" do
|
28
|
+
it{ @user.should be_kind_of Lotu::ResourceManager }
|
29
|
+
it{ @user.should respond_to :image }
|
30
|
+
it{ @user.should respond_to :images }
|
31
|
+
it{ @user.should respond_to :sound }
|
32
|
+
it{ @user.should respond_to :sounds }
|
33
|
+
it{ @user.should respond_to :song }
|
34
|
+
it{ @user.should respond_to :songs }
|
35
|
+
it{ @user.should respond_to :animation }
|
36
|
+
it{ @user.should respond_to :animations }
|
37
|
+
it{ @user.should respond_to :load_images }
|
38
|
+
it{ @user.should respond_to :load_sounds }
|
39
|
+
it{ @user.should respond_to :load_songs }
|
40
|
+
it{ @user.should respond_to :load_animations }
|
41
|
+
end
|