lotu 0.1.4 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.rdoc CHANGED
@@ -37,14 +37,22 @@ If you have any questions of suggestions don't hesitate and send me a message!
37
37
  * Pathfinding and more AI stuff
38
38
 
39
39
 
40
- == Other frameworks
41
- I saw another framework around called *Chingu*, It's been around for a little while and I recommend you take a look at it:
42
- http://github.com/ippa/chingu
43
-
44
- There is also *gamebox*, it's based on Rubygame though:
45
- http://github.com/shawn42/gamebox
46
-
47
- I did find many of the ideas I have for my framework already implemented in it. But be sure I will take inspiration from many others. ;)
40
+ == Game frameworks
41
+ Here are some other Gosu based frameworks:
42
+ * [Chingu] (http://github.com/ippa/chingu)
43
+ * [Exuberant] (http://github.com/adamsanderson/lexery/tree/master/lib/exuberant)
44
+ * [FWD] (http://github.com/walski/FWD)
45
+ * [Nimo] (http://github.com/moonpxi/nimo)
46
+ * [PuitUniverse] (http://github.com/oneup/puituniverse)
47
+ * [Ramverk] (http://github.com/deps/Ramverk)
48
+ * [Space Shooter Engine] (http://github.com/belen-albeza/space-shooter/tree/master/engine/)
49
+ * [SpriteJam] (http://github.com/richardeden/spritejam)
50
+
51
+ There are others not base on Gosu you might like to check out:
52
+ * [gamebox](http://github.com/shawn42/gamebox)
53
+ * [jemini](http://github.com/jemini/jemini-core)
54
+
55
+ Be sure I will take inspiration from them. ;)
48
56
  Nevertheless I'm doing this because I want to become better at architecturing software. And this seems like fitting practice. :D
49
57
 
50
58
 
data/TODO CHANGED
@@ -1,4 +1,5 @@
1
1
  * Work metaphors for Gamestate & Viewport (Scene & Camera) ?
2
2
  * Input system
3
3
  * AI system (steering behaviors, pathfinding, etc)
4
- * Make gems (number to words, vector2d)
4
+
5
+ * Cambiar mi README.rdoc a README.markdown
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.4
1
+ 0.1.5
@@ -4,7 +4,7 @@ require File.expand_path(LIB_PATH)
4
4
  include Gosu::Button
5
5
 
6
6
  class WarpingRuby < Lotu::Actor
7
- def initialize
7
+ def initialize(opts={})
8
8
  super
9
9
  set_image 'CptnRuby Gem.png'
10
10
  end
@@ -23,7 +23,7 @@ class Example < Lotu::Window
23
23
  load_images '../media'
24
24
  end
25
25
 
26
- @ruby = WarpingRuby.new
26
+ @ruby = WarpingRuby.new(:x => width/2, :y => height/2)
27
27
  @cursor1 = Lotu::Cursor.new(:image => 'crosshair.png',
28
28
  :keys => {MsLeft => [:click, false]},
29
29
  :color => 0xff0099ff)
@@ -35,7 +35,7 @@ class Example < Lotu::Window
35
35
  @cursor = Lotu::Cursor.new(:image => 'crosshair.png',
36
36
  :keys => {MsLeft => [:click, false]})
37
37
  @cursor.on(:click) do |x,y|
38
- @ruby.pursuer = @ruby2#Lotu::Vector2d.new(x, y)
38
+ @ruby.pursuer = @ruby2
39
39
  @ruby2.evader = @ruby
40
40
  end
41
41
 
data/lib/lotu/actor.rb CHANGED
@@ -5,13 +5,11 @@ module Lotu
5
5
  def initialize(opts={})
6
6
  default_opts = {
7
7
  :x => 0,
8
- :y => 0,
9
- :color => 0xffffffff
8
+ :y => 0
10
9
  }
11
- opts = default_opts.merge!(opts)
12
- @x = opts[:x]
13
- @y = opts[:y]
14
- @color = opts[:color]
10
+ @opts = default_opts.merge!(opts)
11
+ @x = @opts[:x]
12
+ @y = @opts[:y]
15
13
  @parent = $window
16
14
  @parent.update_queue << self
17
15
 
@@ -7,17 +7,31 @@ module Lotu
7
7
 
8
8
  def init_behavior
9
9
  class << self
10
- attr_accessor :angle
10
+ attr_accessor :z, :angle, :center_x, :center_y,
11
+ :factor_x, :factor_y, :color, :mode
11
12
  end
12
13
 
14
+ default_opts = {
15
+ :z => 0,
16
+ :angle => 0.0,
17
+ :center_x => 0.5,
18
+ :center_y => 0.5,
19
+ :factor_x => 1.0,
20
+ :factor_y => 1.0,
21
+ :color => 0xffffffff,
22
+ :mode => :default
23
+ }
24
+ @opts = default_opts.merge!(@opts)
25
+
13
26
  @image = nil
14
- @z = 0
15
- @angle = 0.0
16
- @center_x = 0.5
17
- @center_y = 0.5
18
- @factor_x = 1.0
19
- @factor_y = 1.0
20
- @mode = :default
27
+ @z = @opts[:z]
28
+ @angle = @opts[:angle]
29
+ @center_x = @opts[:center_x]
30
+ @center_y = @opts[:center_y]
31
+ @factor_x = @opts[:factor_x]
32
+ @factor_y = @opts[:factor_y]
33
+ @color = @opts[:color]
34
+ @mode = @opts[:mode]
21
35
  end
22
36
 
23
37
  def draw_me
data/lib/lotu/cursor.rb CHANGED
@@ -7,10 +7,14 @@ module Lotu
7
7
  def initialize(opts={})
8
8
  default_opts = {
9
9
  :use_mouse => true,
10
- :speed => 100
10
+ :speed => 100,
11
+ :x => $window.width/2,
12
+ :y => $window.height/2
11
13
  }
12
14
  opts = default_opts.merge!(opts)
13
15
  super
16
+ $window.mouse_x = opts[:x]
17
+ $window.mouse_y = opts[:y]
14
18
  @clicked_x = @clicked_y = 0
15
19
  @speed = opts[:speed]
16
20
  @use_mouse = opts[:use_mouse]
@@ -61,7 +65,8 @@ module Lotu
61
65
  end
62
66
 
63
67
  def to_s
64
- "@pos(#{format('%.2f, %.2f', @x, @y)}) @clicked(#{format('%.2f, %.2f', @clicked_x, @clicked_y)})"
68
+ ["@pos(#{format('%.2f, %.2f', @x, @y)})",
69
+ "@clicked(#{format('%.2f, %.2f', @clicked_x, @clicked_y)})"]
65
70
  end
66
71
 
67
72
  end
@@ -30,6 +30,8 @@ module Lotu
30
30
  @behaviors = {}
31
31
  @force = Vector2d.new
32
32
  @zero = Vector2d.new
33
+ actor.pos.x = actor.x
34
+ actor.pos.y = actor.y
33
35
  end
34
36
 
35
37
  def update
@@ -182,6 +184,10 @@ module Lotu
182
184
  @systems[Steering].activate(behavior)
183
185
  end
184
186
 
187
+ def distance_to_target
188
+ @target && (@target - @pos).length
189
+ end
190
+
185
191
  # to_s utility methods
186
192
  def to_s
187
193
  ["@angle(#{format('%.2f', @angle)}°)",
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.4"
8
+ s.version = "0.1.5"
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{2010-03-21}
12
+ s.date = %q{2010-03-22}
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 = [
@@ -60,7 +60,8 @@ Gem::Specification.new do |s|
60
60
  "lib/lotu/systems/steering.rb",
61
61
  "lib/lotu/text_box.rb",
62
62
  "lib/lotu/window.rb",
63
- "lotu.gemspec"
63
+ "lotu.gemspec",
64
+ "test/actor_test.rb"
64
65
  ]
65
66
  s.homepage = %q{http://github.com/lobo-tuerto/lotu}
66
67
  s.rdoc_options = ["--charset=UTF-8"]
@@ -68,7 +69,8 @@ Gem::Specification.new do |s|
68
69
  s.rubygems_version = %q{1.3.6}
69
70
  s.summary = %q{A simple, agile Ruby game development framework.}
70
71
  s.test_files = [
71
- "examples/steering_behaviors/steering.rb",
72
+ "test/actor_test.rb",
73
+ "examples/steering_behaviors/steering.rb",
72
74
  "examples/hello_world/hello_world.rb",
73
75
  "examples/mouse_pointer/mouse_pointer.rb"
74
76
  ]
@@ -0,0 +1,46 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'rubygems'
3
+ require 'protest'
4
+ require 'rr'
5
+ require File.dirname(__FILE__) + '/../lib/lotu'
6
+
7
+ class Protest::TestCase
8
+ include RR::Adapters::TestUnit
9
+ end
10
+
11
+ Protest.report_with(:documentation)
12
+
13
+ Protest.context('An Actor') do
14
+ setup do
15
+ $window = Lotu::Window.new
16
+ @actor = Lotu::Actor.new
17
+ end
18
+
19
+ it 'has an x coordinate. (default: 0)' do
20
+ assert_equal 0, @actor.x
21
+ end
22
+
23
+ it 'has an y coordinate. (default: 0)' do
24
+ assert_equal 0, @actor.y
25
+ end
26
+
27
+ # faltaría el attr_reader :color en actor.rb
28
+ #
29
+ it 'has a color. (default: 0xffffffff)' do
30
+ pending
31
+ #assert_equal Gosu::Color::WHITE, @actor.color
32
+ end
33
+
34
+ it 'has a window reference.' do
35
+ assert_equal $window, @actor.parent
36
+ end
37
+
38
+ # some context...
39
+ #
40
+ context 'when dying' do
41
+ it 'removes itself from Window update_queue.' do
42
+ mock.proxy($window.update_queue).delete(@actor)
43
+ @actor.die
44
+ end
45
+ end
46
+ end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 4
9
- version: 0.1.4
8
+ - 5
9
+ version: 0.1.5
10
10
  platform: ruby
11
11
  authors:
12
12
  - lobo_tuerto
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-03-21 00:00:00 -06:00
17
+ date: 2010-03-22 00:00:00 -06:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -85,6 +85,7 @@ files:
85
85
  - lib/lotu/text_box.rb
86
86
  - lib/lotu/window.rb
87
87
  - lotu.gemspec
88
+ - test/actor_test.rb
88
89
  - TODO
89
90
  has_rdoc: true
90
91
  homepage: http://github.com/lobo-tuerto/lotu
@@ -117,6 +118,7 @@ signing_key:
117
118
  specification_version: 3
118
119
  summary: A simple, agile Ruby game development framework.
119
120
  test_files:
121
+ - test/actor_test.rb
120
122
  - examples/steering_behaviors/steering.rb
121
123
  - examples/hello_world/hello_world.rb
122
124
  - examples/mouse_pointer/mouse_pointer.rb