lotu 0.1.5 → 0.1.6
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/hello_world.rb +1 -1
- data/examples/mouse_pointer/mouse_pointer.rb +1 -1
- data/examples/steering_behaviors/steering.rb +1 -1
- data/lib/lotu/behaviors/resourceful.rb +1 -1
- data/lib/lotu/misc/vector2d.rb +18 -2
- data/lib/lotu/systems/steering.rb +15 -2
- data/lib/lotu/text_box.rb +3 -0
- data/lotu.gemspec +1 -1
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.6
|
data/lib/lotu/misc/vector2d.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
1
2
|
module Lotu
|
2
3
|
class Vector2d
|
3
4
|
attr_reader :x, :y
|
@@ -108,15 +109,30 @@ module Lotu
|
|
108
109
|
Gosu.angle_diff(angle, v.angle)
|
109
110
|
end
|
110
111
|
|
111
|
-
def sign_to(
|
112
|
-
if @y *
|
112
|
+
def sign_to(vector)
|
113
|
+
if @y * vector.x > @x * vector.y
|
113
114
|
return -1
|
114
115
|
else
|
115
116
|
return 1
|
116
117
|
end
|
117
118
|
end
|
118
119
|
|
120
|
+
def clockwise?(vector)
|
121
|
+
sign_to(vector) == 1
|
122
|
+
end
|
123
|
+
|
124
|
+
def counter_clockwise?(vector)
|
125
|
+
!clockwise?
|
126
|
+
end
|
127
|
+
|
128
|
+
def facing_to?(vector)
|
129
|
+
dot(vector) > 0
|
130
|
+
end
|
131
|
+
|
119
132
|
def to_s
|
133
|
+
# TODO tratar de reducir la cantidad de vectores creados, al
|
134
|
+
# menos cuando no se está moviendo
|
135
|
+
#format('%d %.2f, %.2f', object_id, @x, @y)
|
120
136
|
format('%.2f, %.2f', @x, @y)
|
121
137
|
end
|
122
138
|
|
@@ -185,7 +185,18 @@ module Lotu
|
|
185
185
|
end
|
186
186
|
|
187
187
|
def distance_to_target
|
188
|
-
|
188
|
+
(@target - @pos).length
|
189
|
+
end
|
190
|
+
|
191
|
+
def facing_target?
|
192
|
+
@heading.facing_to?(@target - @pos)
|
193
|
+
end
|
194
|
+
|
195
|
+
def draw
|
196
|
+
super
|
197
|
+
$window.draw_line(0, 0, 0xff999999, @pos.x, @pos.y, 0xff333333)
|
198
|
+
$window.draw_line(@pos.x, @pos.y, 0xffffffff, (@pos + @heading*50).x, (@pos+@heading*50).y, 0xffff0000)
|
199
|
+
$window.draw_line(@pos.x, @pos.y, 0xffffffff, @target.x, @target.y, 0xff00ff00) if @target
|
189
200
|
end
|
190
201
|
|
191
202
|
# to_s utility methods
|
@@ -195,7 +206,9 @@ module Lotu
|
|
195
206
|
"@heading(#{@heading})",
|
196
207
|
"@vel |#{format('%.2f', @vel.length)}| (#{@vel})",
|
197
208
|
"@accel |#{format('%.2f', @accel.length)}| (#{@accel})",
|
198
|
-
"
|
209
|
+
"facing_target? #{facing_target? if @target}",
|
210
|
+
"angle_to(@target) #{format('%.2f', @heading.angle_to(@target - @pos)) if @target}",
|
211
|
+
"@seek_target(#{@target})"]
|
199
212
|
end
|
200
213
|
|
201
214
|
end
|
data/lib/lotu/text_box.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
1
2
|
module Lotu
|
2
3
|
class TextBox < Actor
|
3
4
|
|
@@ -7,6 +8,8 @@ module Lotu
|
|
7
8
|
}
|
8
9
|
opts = default_opts.merge!(opts)
|
9
10
|
super(opts)
|
11
|
+
#TODO puede especificar a quién watchear y sus opciones de
|
12
|
+
#dibujado en los parámetros
|
10
13
|
@watch_list = []
|
11
14
|
@subject_opts = {}
|
12
15
|
@font_size = opts[:font_size]
|
data/lotu.gemspec
CHANGED