lotu 0.1.16 → 0.1.18
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/examples/01_hello_world/moving_portraits.rb +2 -2
- data/examples/02_screen_cursor/mouse_and_keyboard_cursors.rb +3 -4
- data/examples/03_collisions/box.rb +20 -12
- data/examples/04_steering_behaviors/pursuit_and_evade.rb +1 -2
- data/examples/04_steering_behaviors/pursuit_and_evade_multiple.rb +1 -2
- data/lib/lotu/actor.rb +16 -9
- data/lib/lotu/behavior.rb +3 -5
- data/lib/lotu/behaviors/collidable.rb +37 -13
- data/lib/lotu/behaviors/system_user.rb +1 -0
- data/lib/lotu/cursor.rb +2 -0
- data/lib/lotu/game.rb +31 -10
- data/lib/lotu/helpers/string.rb +1 -1
- data/lib/lotu/helpers/util.rb +64 -0
- data/lib/lotu/systems/collision_system.rb +1 -1
- data/lib/lotu.rb +1 -1
- data/lotu.gemspec +4 -3
- data/spec/lotu/actor_spec.rb +75 -28
- data/spec/lotu/game_spec.rb +3 -2
- data/spec/lotu/shared_spec.rb +1 -1
- metadata +14 -13
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.18
|
@@ -36,7 +36,6 @@ end
|
|
36
36
|
|
37
37
|
# Let's subclass the Game class and write some code!
|
38
38
|
class MyPortraits < Game
|
39
|
-
use StalkerSystem, :stalk => [Actor, TextBox, Portrait, Object]
|
40
39
|
|
41
40
|
def initialize
|
42
41
|
# This will call the hooks:
|
@@ -80,10 +79,11 @@ class MyPortraits < Game
|
|
80
79
|
|
81
80
|
# Create a TextBox so we can display a message on screen
|
82
81
|
@info = TextBox.new
|
82
|
+
|
83
83
|
# Add some text
|
84
84
|
@info.text("Hello world!")
|
85
85
|
@info.watch lambda{ "FPS: #{ fps }" }
|
86
|
-
|
86
|
+
|
87
87
|
# Add more text, but specify the color and size in pixels
|
88
88
|
@info.text("Move the portraits around with arrow keys", :size => 16, :color => 0xff33ccff)
|
89
89
|
end
|
@@ -26,7 +26,6 @@ class Lobo < Actor
|
|
26
26
|
end
|
27
27
|
|
28
28
|
class Cursors < Game
|
29
|
-
use StalkerSystem, :stalk => [Actor, Cursor, TextBox, Lobo, Object]
|
30
29
|
|
31
30
|
def load_resources
|
32
31
|
with_path_from_file(__FILE__) do
|
@@ -102,14 +101,14 @@ class Cursors < Game
|
|
102
101
|
# Create a TextBox with default option :size => 15
|
103
102
|
@info = TextBox.new(:size => 15)
|
104
103
|
@info.text("Press F1 to hide this text", :size => 24)
|
104
|
+
|
105
105
|
# Watch the FPS, so we get a nice FPS report on the screen
|
106
106
|
@info.watch(lambda{ "FPS: #{ fps }" }, :size => 20)
|
107
|
-
|
108
|
-
# classes we specified up in "use StalkerSystem" are around
|
109
|
-
@info.watch( @systems[StalkerSystem], :color => 0xff3ffccf )
|
107
|
+
|
110
108
|
# We can change the size for a specific line of text
|
111
109
|
@info.text("@cursor1 data:", :size => 20)
|
112
110
|
@info.text("move with Mouse | click with LeftMouseButton")
|
111
|
+
|
113
112
|
# And color
|
114
113
|
@info.watch(@cursor1, :color => @cursor1.color)
|
115
114
|
|
@@ -6,8 +6,10 @@ require File.expand_path(LIB_PATH)
|
|
6
6
|
include Lotu
|
7
7
|
include Gosu
|
8
8
|
|
9
|
-
class
|
10
|
-
|
9
|
+
class Painting < Actor
|
10
|
+
# available collision shapes include :circle and :box
|
11
|
+
# if no :shape is specified, :circle is assumed
|
12
|
+
collides_as :canvas, :shape => :box
|
11
13
|
|
12
14
|
def initialize( opts )
|
13
15
|
# It's important to call super so we take advantage of automatic
|
@@ -16,7 +18,14 @@ class Box < Actor
|
|
16
18
|
# Use the image which filename is "lobo_tuerto.png", and scale
|
17
19
|
# it's size to half width and half height
|
18
20
|
set_image 'lobo_tuerto.png', :factor_x => 0.5, :factor_y => 0.5
|
19
|
-
|
21
|
+
end
|
22
|
+
|
23
|
+
# if you want to try the :shape => :circle thing
|
24
|
+
# you are going to need a function that specifies
|
25
|
+
# the collision radius called:
|
26
|
+
|
27
|
+
def collision_radius
|
28
|
+
@width / 2.0 * @factor_x
|
20
29
|
end
|
21
30
|
|
22
31
|
# Let's define some basic movement methods
|
@@ -28,12 +37,10 @@ end
|
|
28
37
|
|
29
38
|
class Example < Game
|
30
39
|
use CollisionSystem
|
31
|
-
use StalkerSystem, :stalk => [Game, Box, Actor, BaseSystem, Object]
|
32
40
|
|
33
41
|
def initialize
|
34
42
|
super
|
35
|
-
set_keys(KbEscape => :close,
|
36
|
-
KbD => [:debug!, false])
|
43
|
+
set_keys(KbEscape => :close, KbD => [:debug!, false])
|
37
44
|
end
|
38
45
|
|
39
46
|
# This method is called when we call super inside initialize
|
@@ -46,7 +53,7 @@ class Example < Game
|
|
46
53
|
end
|
47
54
|
|
48
55
|
def setup_events
|
49
|
-
when_colliding( :
|
56
|
+
when_colliding( :canvas, :canvas ) do |b1, b2|
|
50
57
|
b1.color = Gosu::Color.from_hsv(rand(360), 1, 1)
|
51
58
|
b2.color = Gosu::Color.from_hsv(rand(360), 1, 1)
|
52
59
|
end
|
@@ -55,7 +62,7 @@ class Example < Game
|
|
55
62
|
# This method is called when we call super inside initialize
|
56
63
|
def setup_actors
|
57
64
|
# Create a portrait in the middle of the screen
|
58
|
-
@lobo1 =
|
65
|
+
@lobo1 = Painting.new(:x => width/2 - 100, :y => height/2)
|
59
66
|
# Map keys to some methods
|
60
67
|
@lobo1.set_keys(KbRight => :move_right,
|
61
68
|
KbLeft => :move_left,
|
@@ -63,18 +70,19 @@ class Example < Game
|
|
63
70
|
KbDown => :move_down)
|
64
71
|
|
65
72
|
# Rinse and repeat... but invert some keys
|
66
|
-
@lobo2 =
|
73
|
+
@lobo2 = Painting.new(:x => width/2 + 100, :y => height/2)
|
67
74
|
@lobo2.set_keys(KbRight => :move_left,
|
68
75
|
KbLeft => :move_right,
|
69
|
-
KbUp => :
|
70
|
-
KbDown => :
|
76
|
+
KbUp => :move_down,
|
77
|
+
KbDown => :move_up)
|
71
78
|
|
72
79
|
# Create a TextBox so we can display a message on screen
|
73
80
|
@info = TextBox.new
|
81
|
+
|
74
82
|
# Add some text
|
75
83
|
@info.text("Hello world!")
|
76
84
|
@info.watch lambda{ "FPS: #{ fps }" }
|
77
|
-
|
85
|
+
|
78
86
|
# Add more text, but specify the color and size in pixels
|
79
87
|
@info.text("Move the portraits around with arrow keys", :size => 16, :color => 0xff33ccff)
|
80
88
|
end
|
@@ -15,6 +15,7 @@ include Lotu
|
|
15
15
|
# control it's movement
|
16
16
|
class Missile < Actor
|
17
17
|
use SteeringSystem
|
18
|
+
use AnimationSystem
|
18
19
|
|
19
20
|
def teleport(x, y)
|
20
21
|
@pos.x, @pos.y = x, y
|
@@ -23,7 +24,6 @@ end
|
|
23
24
|
|
24
25
|
# The main app class
|
25
26
|
class SteeringMissiles < Game
|
26
|
-
use StalkerSystem, :stalk => [Actor, Missile, Vector2d, Object]
|
27
27
|
|
28
28
|
# Let's load some images and animations, check out the animations
|
29
29
|
# directory, the animation there was created with:
|
@@ -59,7 +59,6 @@ class SteeringMissiles < Game
|
|
59
59
|
@window_info = TextBox.new(:size => 15)
|
60
60
|
@window_info.text("Press F1 to hide this text", :size => 24)
|
61
61
|
@window_info.watch(lambda{ "FPS: #{fps}" }, :size => 20)
|
62
|
-
@window_info.watch( @systems[StalkerSystem], :color => 0xff33ccff)
|
63
62
|
@window_info.watch(@cursor, :color => @cursor.color)
|
64
63
|
@window_info.text("Click to start the simulation", :color => 0xffffff00)
|
65
64
|
@window_info.text("One will pursuit while the other evades, right click to center evader on screen")
|
@@ -15,6 +15,7 @@ include Lotu
|
|
15
15
|
# control it's movement
|
16
16
|
class Missile < Actor
|
17
17
|
use SteeringSystem
|
18
|
+
use AnimationSystem
|
18
19
|
|
19
20
|
def teleport(x, y)
|
20
21
|
@pos.x, @pos.y = x, y
|
@@ -23,7 +24,6 @@ end
|
|
23
24
|
|
24
25
|
# The main app class
|
25
26
|
class EvadeMultiple < Game
|
26
|
-
use StalkerSystem, :stalk => [Actor, Missile, Vector2d, Object]
|
27
27
|
|
28
28
|
# Let's load some images and animations, check out the animations
|
29
29
|
# directory, the animation there was created with:
|
@@ -63,7 +63,6 @@ class EvadeMultiple < Game
|
|
63
63
|
@window_info = TextBox.new(:size => 15)
|
64
64
|
@window_info.text("Press F1 to hide this text", :size => 24)
|
65
65
|
@window_info.watch(lambda{ "FPS: #{fps}" }, :size => 20)
|
66
|
-
@window_info.watch( @systems[StalkerSystem], :color => 0xff33ccff)
|
67
66
|
@window_info.watch(@cursor, :color => @cursor.color)
|
68
67
|
@window_info.text("Click to start the simulation", :color => 0xffffff00)
|
69
68
|
@window_info.text("Little missiles will pursuit while the big one evades, right click to center big one on screen")
|
data/lib/lotu/actor.rb
CHANGED
@@ -1,14 +1,12 @@
|
|
1
1
|
module Lotu
|
2
2
|
class Actor
|
3
|
-
|
3
|
+
include Lotu::Helpers::Util
|
4
|
+
extend Lotu::Behavior
|
4
5
|
|
5
|
-
behave_like SystemUser
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
behave_like Eventful
|
10
|
-
behave_like Collidable
|
11
|
-
behave_like Controllable
|
6
|
+
behave_like Lotu::SystemUser
|
7
|
+
behave_like Lotu::Eventful
|
8
|
+
behave_like Lotu::Collidable
|
9
|
+
behave_like Lotu::Controllable
|
12
10
|
|
13
11
|
attr_accessor :parent, :x, :y,
|
14
12
|
:z, :angle, :center_x, :center_y,
|
@@ -16,6 +14,9 @@ module Lotu
|
|
16
14
|
:width, :height
|
17
15
|
|
18
16
|
def initialize(opts={})
|
17
|
+
# if debug is set, print out class info
|
18
|
+
class_debug_info
|
19
|
+
|
19
20
|
default_opts = {
|
20
21
|
:x => 0,
|
21
22
|
:y => 0,
|
@@ -38,8 +39,11 @@ module Lotu
|
|
38
39
|
@color = rand_color if opts[:rand_color]
|
39
40
|
set_keys(opts[:keys]) unless opts[:keys].nil?
|
40
41
|
|
41
|
-
#
|
42
|
+
# start behaving as
|
42
43
|
init_behavior opts
|
44
|
+
|
45
|
+
# if debug is set, print out instance info
|
46
|
+
instance_debug_info
|
43
47
|
end
|
44
48
|
|
45
49
|
# Easy access to delta-time
|
@@ -118,6 +122,9 @@ module Lotu
|
|
118
122
|
|
119
123
|
# Remove ourselves from the update queue
|
120
124
|
def die
|
125
|
+
# to call die on behaviors (that in turn wil call
|
126
|
+
# die on systems, for example)
|
127
|
+
super
|
121
128
|
@parent.kill_me(self)
|
122
129
|
end
|
123
130
|
|
data/lib/lotu/behavior.rb
CHANGED
@@ -2,17 +2,15 @@ module Lotu
|
|
2
2
|
module Behavior
|
3
3
|
|
4
4
|
def behave_like something
|
5
|
+
include something
|
5
6
|
class << self
|
6
7
|
attr_accessor :behavior_options
|
7
8
|
end
|
8
|
-
|
9
|
-
|
10
|
-
@behavior_options ||= Hash.new{ |h,k| h[k] = {} }
|
9
|
+
@behavior_options ||= Hash.new
|
11
10
|
end
|
12
11
|
|
13
12
|
def inherited subclass
|
14
|
-
subclass.behavior_options =
|
15
|
-
behavior_options.inject({}){ |hash, opts| hash[opts[0]] = opts[1].deep_copy; hash }
|
13
|
+
subclass.behavior_options = behavior_options.deep_copy
|
16
14
|
end
|
17
15
|
|
18
16
|
end
|
@@ -1,6 +1,8 @@
|
|
1
1
|
module Lotu
|
2
2
|
module Collidable
|
3
3
|
|
4
|
+
attr_accessor :collision_tags
|
5
|
+
|
4
6
|
def self.included base
|
5
7
|
base.extend ClassMethods
|
6
8
|
end
|
@@ -17,30 +19,52 @@ module Lotu
|
|
17
19
|
|
18
20
|
def init_behavior opts
|
19
21
|
super if defined? super
|
22
|
+
@collision_tags = self.class.behavior_options[Collidable]
|
23
|
+
setup_tags
|
24
|
+
end
|
20
25
|
|
21
|
-
|
22
|
-
class << self
|
23
|
-
attr_accessor :collision_radius
|
24
|
-
end
|
25
|
-
|
26
|
-
@collision_tag = self.class.behavior_options[Collidable]
|
26
|
+
def setup_tags
|
27
27
|
# TODO: Change @parent for @manager (could be a Game or a Scene)
|
28
|
-
@
|
28
|
+
@collision_tags.each do |tag, opts|
|
29
|
+
@parent.systems[CollisionSystem].add_entity(self, tag) if @parent.systems[CollisionSystem]
|
30
|
+
end if @collision_tags
|
29
31
|
end
|
30
32
|
|
31
|
-
def collides_with(other)
|
33
|
+
def collides_with?(other, tag)
|
32
34
|
return false if self.equal? other
|
33
|
-
|
35
|
+
strategy = self.class.behavior_options[Collidable][tag][:shape]
|
36
|
+
send(strategy, other)
|
37
|
+
end
|
38
|
+
|
39
|
+
def box other
|
40
|
+
# horizontal checks
|
41
|
+
return false if @x > other.x + other.width * other.factor_x
|
42
|
+
return false if @x + width * @factor_x < other.x
|
43
|
+
|
44
|
+
# vertical checks
|
45
|
+
return false if @y > other.y + other.height * other.factor_y
|
46
|
+
return false if @y + height * @factor_y < other.y
|
47
|
+
true
|
48
|
+
end
|
49
|
+
|
50
|
+
def circle other
|
51
|
+
# distance between them is smaller than the sum of their radii?
|
52
|
+
Gosu.distance(@x, @y, other.x, other.y) < collision_radius + other.collision_radius
|
34
53
|
end
|
35
54
|
|
36
55
|
def die
|
37
|
-
super
|
38
|
-
@
|
56
|
+
super if defined? super
|
57
|
+
@collision_tags.each do |tag, options|
|
58
|
+
@parent.systems[CollisionSystem].remove_entity(self, tag) if @parent.systems[CollisionSystem]
|
59
|
+
end if @collision_tags
|
39
60
|
end
|
40
61
|
|
41
62
|
module ClassMethods
|
42
|
-
def collides_as tag
|
43
|
-
|
63
|
+
def collides_as tag, opts={}
|
64
|
+
default_opts = { :shape => :circle }
|
65
|
+
opts = default_opts.merge!(opts)
|
66
|
+
behavior_options[Collidable] ||= Hash.new
|
67
|
+
behavior_options[Collidable][tag] = opts
|
44
68
|
end
|
45
69
|
end
|
46
70
|
|
data/lib/lotu/cursor.rb
CHANGED
data/lib/lotu/game.rb
CHANGED
@@ -1,36 +1,54 @@
|
|
1
1
|
module Lotu
|
2
2
|
class Game < Gosu::Window
|
3
|
-
|
3
|
+
include Lotu::Helpers::Util
|
4
|
+
extend Lotu::Behavior
|
4
5
|
|
5
|
-
behave_like SystemUser
|
6
|
-
use InputManagerSystem
|
6
|
+
behave_like Lotu::SystemUser
|
7
|
+
use Lotu::InputManagerSystem
|
7
8
|
|
8
|
-
behave_like ResourceManager
|
9
|
+
behave_like Lotu::ResourceManager
|
9
10
|
|
10
|
-
# Accessors for elapsed time since last update (time delta) and
|
11
|
-
attr_reader :dt
|
11
|
+
# Accessors for elapsed time since last update (time delta) and debug
|
12
|
+
attr_reader :dt, :debug
|
12
13
|
# Accessors for queues
|
13
14
|
attr_accessor :update_queue, :draw_queue, :input_listeners
|
14
15
|
|
15
16
|
def initialize(opts={})
|
17
|
+
# parse and merge options passed from
|
18
|
+
# the CLI (Command Line Interface)
|
19
|
+
# CLI options have the greatest precedence
|
20
|
+
if opts[:parse_cli_options] || opts[:parse_cli_options].nil?
|
21
|
+
opts.merge!(parse_cli_options)
|
22
|
+
end
|
23
|
+
|
24
|
+
# set some sane default opts
|
16
25
|
default_opts = {
|
17
26
|
:width => 1024,
|
18
27
|
:height => 768,
|
19
|
-
:fullscreen => false
|
28
|
+
:fullscreen => false,
|
29
|
+
:debug => false
|
20
30
|
}
|
31
|
+
# fill in any missing options using the defaults
|
21
32
|
opts = default_opts.merge!(opts)
|
22
|
-
super(opts[:width], opts[:height], opts[:fullscreen])
|
23
33
|
|
24
34
|
# Handy global window variable
|
25
35
|
$lotu = self
|
26
|
-
|
36
|
+
|
37
|
+
# Game setup
|
38
|
+
@debug = opts[:debug]
|
27
39
|
@pause = false
|
28
40
|
setup_containers
|
29
41
|
|
42
|
+
# if debug is set, print out class info
|
43
|
+
class_debug_info
|
44
|
+
|
45
|
+
# call the Gosu::Window constructor
|
46
|
+
super(opts[:width], opts[:height], opts[:fullscreen])
|
47
|
+
|
30
48
|
# For timer initialization
|
31
49
|
@last_time = Gosu::milliseconds
|
32
50
|
|
33
|
-
#
|
51
|
+
# start behaving as
|
34
52
|
init_behavior opts
|
35
53
|
|
36
54
|
# Call hook methods
|
@@ -38,6 +56,9 @@ module Lotu
|
|
38
56
|
setup_actors
|
39
57
|
setup_input
|
40
58
|
setup_events
|
59
|
+
|
60
|
+
# if debug is set, print out instance info
|
61
|
+
instance_debug_info
|
41
62
|
end
|
42
63
|
|
43
64
|
def fps
|
data/lib/lotu/helpers/string.rb
CHANGED
@@ -8,7 +8,7 @@ class String
|
|
8
8
|
def yellow; colorize(self, "\e[1m\e[33m") end
|
9
9
|
def blue; colorize(self, "\e[1m\e[34m") end
|
10
10
|
def dark_blue; colorize(self, "\e[34m") end
|
11
|
-
def
|
11
|
+
def purple; colorize(self, "\e[1m\e[35m") end
|
12
12
|
def colorize(text, color_code) "#{color_code}#{text}\e[0m" end
|
13
13
|
|
14
14
|
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
|
3
|
+
module Lotu
|
4
|
+
module Helpers
|
5
|
+
module Util
|
6
|
+
|
7
|
+
def class_debug_info
|
8
|
+
if $lotu.debug
|
9
|
+
puts "[#{self.class.to_s.green}] Behavior options: #{self.class.behavior_options}\n" if self.class.respond_to? :behavior_options
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def instance_debug_info
|
14
|
+
if $lotu.debug
|
15
|
+
puts "[#{self.class.to_s.yellow}] Systems: #{systems.keys}\n" if systems
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
# As seen in: http://ruby.about.com/od/advancedruby/a/optionparser.htm
|
20
|
+
def parse_cli_options
|
21
|
+
# This hash will hold all of the options
|
22
|
+
# parsed from the command-line by
|
23
|
+
# OptionParser.
|
24
|
+
options = {}
|
25
|
+
|
26
|
+
optparse = OptionParser.new do|opts|
|
27
|
+
# Set a banner, displayed at the top
|
28
|
+
# of the help screen.
|
29
|
+
opts.banner = "Usage: #{$0} [options]"
|
30
|
+
|
31
|
+
# Define the options, and what they do
|
32
|
+
options[:debug] = false
|
33
|
+
opts.on( '-d', '--debug', 'Output debug info' ) do
|
34
|
+
options[:debug] = true
|
35
|
+
end
|
36
|
+
|
37
|
+
options[:fullscreen] = false
|
38
|
+
opts.on( '-f', '--fullscreen', 'Runs the game in fullscreen mode' ) do
|
39
|
+
options[:fullscreen] = true
|
40
|
+
end
|
41
|
+
|
42
|
+
# This displays the help screen, all programs are
|
43
|
+
# assumed to have this option.
|
44
|
+
opts.on( '-h', '--help', 'Display this screen' ) do
|
45
|
+
puts opts
|
46
|
+
exit
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
# Parse the command-line. Remember there are two forms
|
51
|
+
# of the parse method. The 'parse' method simply parses
|
52
|
+
# ARGV, while the 'parse!' method parses ARGV and removes
|
53
|
+
# any options found there, as well as any parameters for
|
54
|
+
# the options. What's left is the list of files to resize.
|
55
|
+
optparse.parse!
|
56
|
+
|
57
|
+
puts "Showing debug info".red if options[:debug]
|
58
|
+
puts "Running in fullscreen mode".red if options[:fullscreen]
|
59
|
+
options
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
data/lib/lotu.rb
CHANGED
@@ -3,7 +3,7 @@ $LOAD_PATH.unshift(LOTU_ROOT)
|
|
3
3
|
|
4
4
|
require 'rubygems'
|
5
5
|
require 'gosu'
|
6
|
-
%w{vector2d string kernel}.each{|file| require "helpers/#{file}"}
|
6
|
+
%w{vector2d string kernel util}.each{|file| require "helpers/#{file}"}
|
7
7
|
%w{resource_manager system_user collidable controllable eventful}.each{|file| require "behaviors/#{file}"}
|
8
8
|
%w{base interpolation animation input_manager stalker collision steering}.map{|s| "#{s}_system"}.each{|file| require "systems/#{file}"}
|
9
9
|
%w{behavior actor cursor text_box game}.each{|file| require file}
|
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.18"
|
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-25}
|
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 = [
|
@@ -52,6 +52,7 @@ Gem::Specification.new do |s|
|
|
52
52
|
"lib/lotu/game.rb",
|
53
53
|
"lib/lotu/helpers/kernel.rb",
|
54
54
|
"lib/lotu/helpers/string.rb",
|
55
|
+
"lib/lotu/helpers/util.rb",
|
55
56
|
"lib/lotu/helpers/vector2d.rb",
|
56
57
|
"lib/lotu/systems/animation_system.rb",
|
57
58
|
"lib/lotu/systems/base_system.rb",
|
@@ -69,7 +70,7 @@ Gem::Specification.new do |s|
|
|
69
70
|
]
|
70
71
|
s.homepage = %q{http://github.com/lobo-tuerto/lotu}
|
71
72
|
s.require_paths = ["lib"]
|
72
|
-
s.rubygems_version = %q{1.5.
|
73
|
+
s.rubygems_version = %q{1.5.2}
|
73
74
|
s.summary = %q{A simple, agile Ruby game development framework.}
|
74
75
|
s.test_files = [
|
75
76
|
"examples/01_hello_world/moving_portraits.rb",
|
data/spec/lotu/actor_spec.rb
CHANGED
@@ -1,20 +1,54 @@
|
|
1
1
|
require 'lotu'
|
2
2
|
|
3
3
|
class Actress < Lotu::Actor
|
4
|
+
collides_as :actress_in_distress
|
4
5
|
use Lotu::SteeringSystem
|
5
6
|
end
|
6
7
|
|
8
|
+
class Fan < Actress
|
9
|
+
use Lotu::StalkerSystem
|
10
|
+
end
|
11
|
+
|
7
12
|
describe "Actor" do
|
8
13
|
|
9
14
|
before :each do
|
10
|
-
@game = Lotu::Game.new
|
15
|
+
@game = Lotu::Game.new(:parse_cli_options => false)
|
11
16
|
@actor = Lotu::Actor.new
|
12
17
|
@actress = Actress.new
|
18
|
+
@fan = Fan.new
|
13
19
|
@user = @actor
|
14
20
|
end
|
15
21
|
|
16
22
|
after :each do
|
17
23
|
@actor.die
|
24
|
+
@actress.die
|
25
|
+
@fan.die
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "When just created" do
|
29
|
+
it "should have the appropiate number of systems" do
|
30
|
+
@actor.systems.length.should be 0
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should have the appropiate type of systems" do
|
34
|
+
@actor.systems.keys.should == []
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should have the appropiate behavior options set" do
|
38
|
+
@actor.class.behavior_options.should == {}
|
39
|
+
end
|
40
|
+
|
41
|
+
it "#x == 0" do
|
42
|
+
@actor.x.should == 0
|
43
|
+
end
|
44
|
+
|
45
|
+
it "#y == 0" do
|
46
|
+
@actor.y.should == 0
|
47
|
+
end
|
48
|
+
|
49
|
+
it "#z == 0" do
|
50
|
+
@actor.z.should == 0
|
51
|
+
end
|
18
52
|
end
|
19
53
|
|
20
54
|
describe "Behavior" do
|
@@ -24,45 +58,58 @@ describe "Actor" do
|
|
24
58
|
it_should_behave_like "controllable"
|
25
59
|
end
|
26
60
|
|
27
|
-
describe "
|
61
|
+
describe "Actor subclasses" do
|
62
|
+
before :each do
|
63
|
+
@user = @actress
|
64
|
+
end
|
65
|
+
|
66
|
+
describe "Behavior" do
|
67
|
+
it_should_behave_like "system user"
|
68
|
+
it_should_behave_like "eventful"
|
69
|
+
it_should_behave_like "collidable"
|
70
|
+
it_should_behave_like "controllable"
|
71
|
+
end
|
72
|
+
|
28
73
|
it "should have a different object hash for behavior_options" do
|
29
|
-
@
|
74
|
+
@user.class.behavior_options.should_not be @actor.class.behavior_options
|
30
75
|
end
|
31
76
|
|
32
77
|
it "should have different values in behavior_options" do
|
33
|
-
@
|
78
|
+
@user.class.behavior_options.should_not == @actor.class.behavior_options
|
34
79
|
end
|
35
|
-
end
|
36
80
|
|
37
|
-
|
38
|
-
|
39
|
-
|
81
|
+
describe "When just created" do
|
82
|
+
it "should have the appropiate number of systems" do
|
83
|
+
@user.systems.length.should be 1
|
84
|
+
end
|
40
85
|
|
41
|
-
|
42
|
-
|
43
|
-
|
86
|
+
it "should have the appropiate type of systems" do
|
87
|
+
@user.systems.keys.should == [Lotu::SteeringSystem]
|
88
|
+
end
|
44
89
|
|
45
|
-
|
46
|
-
|
47
|
-
|
90
|
+
it "should have the appropiate behavior options set" do
|
91
|
+
@user.class.behavior_options.should == {Lotu::Collidable=>{:actress_in_distress=>{:shape=>:circle}},
|
92
|
+
Lotu::SystemUser=>{Lotu::SteeringSystem=>{}}}
|
93
|
+
end
|
48
94
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
it{ @actor.should respond_to :color }
|
95
|
+
it "#x == 0" do
|
96
|
+
@user.x.should == 0
|
97
|
+
end
|
53
98
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
end
|
99
|
+
it "#y == 0" do
|
100
|
+
@user.y.should == 0
|
101
|
+
end
|
58
102
|
|
59
|
-
|
60
|
-
|
103
|
+
it "#z == 0" do
|
104
|
+
@user.z.should == 0
|
105
|
+
end
|
61
106
|
end
|
107
|
+
end
|
62
108
|
|
63
|
-
|
64
|
-
|
65
|
-
|
109
|
+
describe "Basic methods and properties" do
|
110
|
+
it{ @actor.should respond_to :x }
|
111
|
+
it{ @actor.should respond_to :y }
|
112
|
+
it{ @actor.should respond_to :parent }
|
113
|
+
it{ @actor.should respond_to :color }
|
66
114
|
end
|
67
|
-
|
68
115
|
end
|
data/spec/lotu/game_spec.rb
CHANGED
@@ -5,14 +5,15 @@ describe "Game" do
|
|
5
5
|
it_should_behave_like "resource manager"
|
6
6
|
|
7
7
|
before :all do
|
8
|
-
@game = Lotu::Game.new
|
8
|
+
@game = Lotu::Game.new(:parse_cli_options => false)
|
9
9
|
@game.with_path_from_file(__FILE__) do |g|
|
10
10
|
load_images '../../examples/media/images'
|
11
11
|
end
|
12
|
-
|
13
12
|
@user = @game
|
14
13
|
end
|
15
14
|
|
15
|
+
it "should spec the collision system"
|
16
|
+
|
16
17
|
it{ @game.should respond_to :update }
|
17
18
|
it{ @game.should respond_to :draw }
|
18
19
|
it{ @game.should respond_to :dt }
|
data/spec/lotu/shared_spec.rb
CHANGED
@@ -13,7 +13,7 @@ end
|
|
13
13
|
|
14
14
|
shared_examples_for "collidable" do
|
15
15
|
it{ @user.should be_kind_of Lotu::Collidable }
|
16
|
-
it{ @user.should respond_to :collides_with }
|
16
|
+
it{ @user.should respond_to :collides_with? }
|
17
17
|
describe "the user class" do
|
18
18
|
it{ @user.class.should respond_to :collides_as }
|
19
19
|
end
|
metadata
CHANGED
@@ -1,20 +1,20 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lotu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
5
|
-
prerelease:
|
4
|
+
version: 0.1.18
|
5
|
+
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- lobo_tuerto
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-02-
|
13
|
-
default_executable:
|
12
|
+
date: 2011-02-25 00:00:00.000000000 -06:00
|
13
|
+
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: gosu
|
17
|
-
requirement: &
|
17
|
+
requirement: &23259460 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -22,10 +22,10 @@ dependencies:
|
|
22
22
|
version: 0.7.27.1
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *23259460
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: rspec
|
28
|
-
requirement: &
|
28
|
+
requirement: &23258660 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ! '>='
|
@@ -33,7 +33,7 @@ dependencies:
|
|
33
33
|
version: 2.5.0
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
36
|
+
version_requirements: *23258660
|
37
37
|
description: lotu aims to bring an agile and simple game development framework to
|
38
38
|
life. It provides useful abstractions so you can concentrate on developing your
|
39
39
|
game.
|
@@ -79,6 +79,7 @@ files:
|
|
79
79
|
- lib/lotu/game.rb
|
80
80
|
- lib/lotu/helpers/kernel.rb
|
81
81
|
- lib/lotu/helpers/string.rb
|
82
|
+
- lib/lotu/helpers/util.rb
|
82
83
|
- lib/lotu/helpers/vector2d.rb
|
83
84
|
- lib/lotu/systems/animation_system.rb
|
84
85
|
- lib/lotu/systems/base_system.rb
|
@@ -97,7 +98,7 @@ files:
|
|
97
98
|
has_rdoc: true
|
98
99
|
homepage: http://github.com/lobo-tuerto/lotu
|
99
100
|
licenses: []
|
100
|
-
post_install_message:
|
101
|
+
post_install_message:
|
101
102
|
rdoc_options: []
|
102
103
|
require_paths:
|
103
104
|
- lib
|
@@ -114,9 +115,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
114
115
|
- !ruby/object:Gem::Version
|
115
116
|
version: '0'
|
116
117
|
requirements: []
|
117
|
-
rubyforge_project:
|
118
|
-
rubygems_version: 1.5.
|
119
|
-
signing_key:
|
118
|
+
rubyforge_project:
|
119
|
+
rubygems_version: 1.5.2
|
120
|
+
signing_key:
|
120
121
|
specification_version: 3
|
121
122
|
summary: A simple, agile Ruby game development framework.
|
122
123
|
test_files:
|