zyps 0.5.2 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (150) hide show
  1. data/README.txt +18 -0
  2. data/bin/zyps +13 -9
  3. data/bin/zyps_demo +3 -0
  4. data/bin/zyps_server +262 -0
  5. data/doc/classes/Zyps.html +161 -0
  6. data/doc/classes/Zyps/AccelerateAction.html +200 -0
  7. data/doc/classes/Zyps/AccelerateAction.src/M000020.html +19 -0
  8. data/doc/classes/Zyps/AccelerateAction.src/M000021.html +19 -0
  9. data/doc/classes/Zyps/AccelerateAction.src/M000022.html +18 -0
  10. data/doc/classes/Zyps/Accelerator.html +181 -0
  11. data/doc/classes/Zyps/Accelerator.src/M000044.html +19 -0
  12. data/doc/classes/Zyps/Accelerator.src/M000045.html +18 -0
  13. data/doc/classes/Zyps/Action.html +217 -0
  14. data/doc/classes/Zyps/Action.src/M000014.html +18 -0
  15. data/doc/classes/Zyps/Action.src/M000015.html +18 -0
  16. data/doc/classes/Zyps/Action.src/M000016.html +17 -0
  17. data/doc/classes/Zyps/Action.src/M000017.html +18 -0
  18. data/doc/classes/Zyps/AgeCondition.html +181 -0
  19. data/doc/classes/Zyps/AgeCondition.src/M000058.html +18 -0
  20. data/doc/classes/Zyps/AgeCondition.src/M000059.html +18 -0
  21. data/doc/classes/Zyps/ApproachAction.html +207 -0
  22. data/doc/classes/Zyps/ApproachAction.src/M000074.html +19 -0
  23. data/doc/classes/Zyps/ApproachAction.src/M000075.html +19 -0
  24. data/doc/classes/Zyps/ApproachAction.src/M000076.html +38 -0
  25. data/doc/classes/Zyps/Behavior.html +206 -0
  26. data/doc/classes/Zyps/Behavior.src/M000012.html +20 -0
  27. data/doc/classes/Zyps/Behavior.src/M000013.html +31 -0
  28. data/doc/classes/Zyps/BlendAction.html +181 -0
  29. data/doc/classes/Zyps/BlendAction.src/M000066.html +18 -0
  30. data/doc/classes/Zyps/BlendAction.src/M000067.html +18 -0
  31. data/doc/classes/Zyps/Clock.html +180 -0
  32. data/doc/classes/Zyps/Clock.src/M000069.html +18 -0
  33. data/doc/classes/Zyps/Clock.src/M000070.html +21 -0
  34. data/doc/classes/Zyps/Clock.src/M000071.html +18 -0
  35. data/doc/classes/Zyps/CollisionCondition.html +148 -0
  36. data/doc/classes/Zyps/CollisionCondition.src/M000083.html +18 -0
  37. data/doc/classes/Zyps/Color.html +299 -0
  38. data/doc/classes/Zyps/Color.src/M000038.html +18 -0
  39. data/doc/classes/Zyps/Color.src/M000039.html +16 -0
  40. data/doc/classes/Zyps/Color.src/M000040.html +16 -0
  41. data/doc/classes/Zyps/Color.src/M000041.html +16 -0
  42. data/doc/classes/Zyps/Color.src/M000042.html +18 -0
  43. data/doc/classes/Zyps/Color.src/M000043.html +22 -0
  44. data/doc/classes/Zyps/Condition.html +118 -0
  45. data/doc/classes/Zyps/Creature.html +190 -0
  46. data/doc/classes/Zyps/Creature.src/M000025.html +19 -0
  47. data/doc/classes/Zyps/Creature.src/M000026.html +18 -0
  48. data/doc/classes/Zyps/DestroyAction.html +181 -0
  49. data/doc/classes/Zyps/DestroyAction.src/M000054.html +18 -0
  50. data/doc/classes/Zyps/DestroyAction.src/M000055.html +20 -0
  51. data/doc/classes/Zyps/EatAction.html +149 -0
  52. data/doc/classes/Zyps/EatAction.src/M000068.html +21 -0
  53. data/doc/classes/Zyps/Enclosure.html +206 -0
  54. data/doc/classes/Zyps/Enclosure.src/M000010.html +18 -0
  55. data/doc/classes/Zyps/Enclosure.src/M000011.html +31 -0
  56. data/doc/classes/Zyps/Environment.html +203 -0
  57. data/doc/classes/Zyps/Environment.src/M000081.html +19 -0
  58. data/doc/classes/Zyps/Environment.src/M000082.html +67 -0
  59. data/doc/classes/Zyps/EnvironmentalFactor.html +118 -0
  60. data/doc/classes/Zyps/FaceAction.html +148 -0
  61. data/doc/classes/Zyps/FaceAction.src/M000080.html +18 -0
  62. data/doc/classes/Zyps/FleeAction.html +207 -0
  63. data/doc/classes/Zyps/FleeAction.src/M000084.html +19 -0
  64. data/doc/classes/Zyps/FleeAction.src/M000085.html +19 -0
  65. data/doc/classes/Zyps/FleeAction.src/M000086.html +38 -0
  66. data/doc/classes/Zyps/Friction.html +181 -0
  67. data/doc/classes/Zyps/Friction.src/M000072.html +19 -0
  68. data/doc/classes/Zyps/Friction.src/M000073.html +18 -0
  69. data/doc/classes/Zyps/GameObject.html +282 -0
  70. data/doc/classes/Zyps/GameObject.src/M000060.html +19 -0
  71. data/doc/classes/Zyps/GameObject.src/M000061.html +16 -0
  72. data/doc/classes/Zyps/GameObject.src/M000062.html +19 -0
  73. data/doc/classes/Zyps/GameObject.src/M000063.html +16 -0
  74. data/doc/classes/Zyps/GameObject.src/M000064.html +16 -0
  75. data/doc/classes/Zyps/Gravity.html +145 -0
  76. data/doc/classes/Zyps/Gravity.src/M000065.html +16 -0
  77. data/doc/classes/Zyps/Location.html +167 -0
  78. data/doc/classes/Zyps/Location.src/M000037.html +18 -0
  79. data/doc/classes/Zyps/NoMatchException.html +111 -0
  80. data/doc/classes/Zyps/PopulationLimit.html +183 -0
  81. data/doc/classes/Zyps/PopulationLimit.src/M000027.html +19 -0
  82. data/doc/classes/Zyps/PopulationLimit.src/M000028.html +20 -0
  83. data/doc/classes/Zyps/ProximityCondition.html +182 -0
  84. data/doc/classes/Zyps/ProximityCondition.src/M000056.html +18 -0
  85. data/doc/classes/Zyps/ProximityCondition.src/M000057.html +18 -0
  86. data/doc/classes/Zyps/PullAction.html +199 -0
  87. data/doc/classes/Zyps/PullAction.src/M000046.html +19 -0
  88. data/doc/classes/Zyps/PullAction.src/M000047.html +19 -0
  89. data/doc/classes/Zyps/PullAction.src/M000048.html +23 -0
  90. data/doc/classes/Zyps/PushAction.html +199 -0
  91. data/doc/classes/Zyps/PushAction.src/M000049.html +19 -0
  92. data/doc/classes/Zyps/PushAction.src/M000050.html +19 -0
  93. data/doc/classes/Zyps/PushAction.src/M000051.html +23 -0
  94. data/doc/classes/Zyps/SpeedLimit.html +181 -0
  95. data/doc/classes/Zyps/SpeedLimit.src/M000023.html +18 -0
  96. data/doc/classes/Zyps/SpeedLimit.src/M000024.html +18 -0
  97. data/doc/classes/Zyps/TagAction.html +181 -0
  98. data/doc/classes/Zyps/TagAction.src/M000052.html +18 -0
  99. data/doc/classes/Zyps/TagAction.src/M000053.html +18 -0
  100. data/doc/classes/Zyps/TagCondition.html +181 -0
  101. data/doc/classes/Zyps/TagCondition.src/M000018.html +18 -0
  102. data/doc/classes/Zyps/TagCondition.src/M000019.html +18 -0
  103. data/doc/classes/Zyps/TrailsView.html +209 -0
  104. data/doc/classes/Zyps/TrailsView.src/M000008.html +40 -0
  105. data/doc/classes/Zyps/TrailsView.src/M000009.html +78 -0
  106. data/doc/classes/Zyps/TurnAction.html +200 -0
  107. data/doc/classes/Zyps/TurnAction.src/M000077.html +19 -0
  108. data/doc/classes/Zyps/TurnAction.src/M000078.html +19 -0
  109. data/doc/classes/Zyps/TurnAction.src/M000079.html +18 -0
  110. data/doc/classes/Zyps/Utility.html +251 -0
  111. data/doc/classes/Zyps/Utility.src/M000001.html +26 -0
  112. data/doc/classes/Zyps/Utility.src/M000002.html +22 -0
  113. data/doc/classes/Zyps/Utility.src/M000003.html +18 -0
  114. data/doc/classes/Zyps/Utility.src/M000004.html +21 -0
  115. data/doc/classes/Zyps/Utility.src/M000005.html +25 -0
  116. data/doc/classes/Zyps/Utility.src/M000006.html +21 -0
  117. data/doc/classes/Zyps/Utility.src/M000007.html +21 -0
  118. data/doc/classes/Zyps/Vector.html +281 -0
  119. data/doc/classes/Zyps/Vector.src/M000029.html +19 -0
  120. data/doc/classes/Zyps/Vector.src/M000030.html +16 -0
  121. data/doc/classes/Zyps/Vector.src/M000031.html +21 -0
  122. data/doc/classes/Zyps/Vector.src/M000032.html +16 -0
  123. data/doc/classes/Zyps/Vector.src/M000033.html +18 -0
  124. data/doc/classes/Zyps/Vector.src/M000034.html +16 -0
  125. data/doc/classes/Zyps/Vector.src/M000035.html +18 -0
  126. data/doc/classes/Zyps/Vector.src/M000036.html +25 -0
  127. data/doc/created.rid +1 -0
  128. data/doc/files/COPYING_LESSER_txt.html +311 -0
  129. data/doc/files/COPYING_txt.html +1003 -0
  130. data/doc/files/README_txt.html +236 -0
  131. data/doc/files/lib/zyps/actions_rb.html +134 -0
  132. data/doc/files/lib/zyps/conditions_rb.html +134 -0
  133. data/doc/files/lib/zyps/environmental_factors_rb.html +134 -0
  134. data/doc/files/lib/zyps/views/trails_rb.html +134 -0
  135. data/doc/files/lib/zyps_rb.html +134 -0
  136. data/doc/fr_class_index.html +62 -0
  137. data/doc/fr_file_index.html +34 -0
  138. data/doc/fr_method_index.html +112 -0
  139. data/doc/index.html +24 -0
  140. data/doc/rdoc-style.css +208 -0
  141. data/lib/zyps.rb +40 -9
  142. data/lib/zyps/actions.rb +8 -1
  143. data/lib/zyps/conditions.rb +6 -0
  144. data/lib/zyps/environmental_factors.rb +74 -0
  145. data/lib/zyps/views/trails.rb +6 -0
  146. data/test/test_zyps.rb +3 -0
  147. data/test/zyps/test_actions.rb +3 -0
  148. data/test/zyps/test_conditions.rb +3 -0
  149. data/test/zyps/test_environmental_factors.rb +90 -7
  150. metadata +185 -9
@@ -0,0 +1,18 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html>
7
+ <head>
8
+ <title>new (Zyps::AgeCondition)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File lib/zyps/conditions.rb, line 42</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">age</span>)
15
+ <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">age</span> = <span class="ruby-identifier">age</span>
16
+ <span class="ruby-keyword kw">end</span></pre>
17
+ </body>
18
+ </html>
@@ -0,0 +1,18 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html>
7
+ <head>
8
+ <title>met? (Zyps::AgeCondition)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File lib/zyps/conditions.rb, line 46</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">met?</span>(<span class="ruby-identifier">actor</span>, <span class="ruby-identifier">target</span>)
15
+ <span class="ruby-identifier">target</span>.<span class="ruby-identifier">age</span> <span class="ruby-operator">&gt;</span> <span class="ruby-ivar">@age</span>
16
+ <span class="ruby-keyword kw">end</span></pre>
17
+ </body>
18
+ </html>
@@ -0,0 +1,207 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
+ <head>
8
+ <title>Class: Zyps::ApproachAction</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
12
+ <script type="text/javascript">
13
+ // <![CDATA[
14
+
15
+ function popupCode( url ) {
16
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
+ }
18
+
19
+ function toggleCode( id ) {
20
+ if ( document.getElementById )
21
+ elem = document.getElementById( id );
22
+ else if ( document.all )
23
+ elem = eval( "document.all." + id );
24
+ else
25
+ return false;
26
+
27
+ elemStyle = elem.style;
28
+
29
+ if ( elemStyle.display != "block" ) {
30
+ elemStyle.display = "block"
31
+ } else {
32
+ elemStyle.display = "none"
33
+ }
34
+
35
+ return true;
36
+ }
37
+
38
+ // Make codeblocks hidden by default
39
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
+
41
+ // ]]>
42
+ </script>
43
+
44
+ </head>
45
+ <body>
46
+
47
+
48
+
49
+ <div id="classHeader">
50
+ <table class="header-table">
51
+ <tr class="top-aligned-row">
52
+ <td><strong>Class</strong></td>
53
+ <td class="class-name-in-header">Zyps::ApproachAction</td>
54
+ </tr>
55
+ <tr class="top-aligned-row">
56
+ <td><strong>In:</strong></td>
57
+ <td>
58
+ <a href="../../files/lib/zyps/actions_rb.html">
59
+ lib/zyps/actions.rb
60
+ </a>
61
+ <br />
62
+ </td>
63
+ </tr>
64
+
65
+ <tr class="top-aligned-row">
66
+ <td><strong>Parent:</strong></td>
67
+ <td>
68
+ <a href="Action.html">
69
+ Action
70
+ </a>
71
+ </td>
72
+ </tr>
73
+ </table>
74
+ </div>
75
+ <!-- banner header -->
76
+
77
+ <div id="bodyContent">
78
+
79
+
80
+
81
+ <div id="contextContent">
82
+
83
+ <div id="description">
84
+ <p>
85
+ Approaches the target, but obeys law of inertia.
86
+ </p>
87
+
88
+ </div>
89
+
90
+
91
+ </div>
92
+
93
+ <div id="method-list">
94
+ <h3 class="section-bar">Methods</h3>
95
+
96
+ <div class="name-list">
97
+ <a href="#M000076">do</a>&nbsp;&nbsp;
98
+ <a href="#M000074">new</a>&nbsp;&nbsp;
99
+ <a href="#M000075">start</a>&nbsp;&nbsp;
100
+ </div>
101
+ </div>
102
+
103
+ </div>
104
+
105
+
106
+ <!-- if includes -->
107
+
108
+ <div id="section">
109
+
110
+
111
+
112
+
113
+
114
+ <div id="attribute-list">
115
+ <h3 class="section-bar">Attributes</h3>
116
+
117
+ <div class="name-list">
118
+ <table>
119
+ <tr class="top-aligned-row context-row">
120
+ <td class="context-item-name">heading</td>
121
+ <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
122
+ <td class="context-item-desc">
123
+ Direction/speed actor is accelerating in.
124
+
125
+ </td>
126
+ </tr>
127
+ <tr class="top-aligned-row context-row">
128
+ <td class="context-item-name">turn_rate</td>
129
+ <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
130
+ <td class="context-item-desc">
131
+ Degrees per second the direction of acceleration can change.
132
+
133
+ </td>
134
+ </tr>
135
+ </table>
136
+ </div>
137
+ </div>
138
+
139
+
140
+
141
+ <!-- if method_list -->
142
+ <div id="methods">
143
+ <h3 class="section-bar">Public Class methods</h3>
144
+
145
+ <div id="method-M000074" class="method-detail">
146
+ <a name="M000074"></a>
147
+
148
+ <div class="method-heading">
149
+ <a href="ApproachAction.src/M000074.html" target="Code" class="method-signature"
150
+ onclick="popupCode('ApproachAction.src/M000074.html');return false;">
151
+ <span class="method-name">new</span><span class="method-args">(heading = Vector.new, turn_rate = 360)</span>
152
+ </a>
153
+ </div>
154
+
155
+ <div class="method-description">
156
+ </div>
157
+ </div>
158
+
159
+ <h3 class="section-bar">Public Instance methods</h3>
160
+
161
+ <div id="method-M000076" class="method-detail">
162
+ <a name="M000076"></a>
163
+
164
+ <div class="method-heading">
165
+ <a href="ApproachAction.src/M000076.html" target="Code" class="method-signature"
166
+ onclick="popupCode('ApproachAction.src/M000076.html');return false;">
167
+ <span class="method-name">do</span><span class="method-args">(actor, target)</span>
168
+ </a>
169
+ </div>
170
+
171
+ <div class="method-description">
172
+ <p>
173
+ Accelerate toward the target, but limited by turn rate.
174
+ </p>
175
+ </div>
176
+ </div>
177
+
178
+ <div id="method-M000075" class="method-detail">
179
+ <a name="M000075"></a>
180
+
181
+ <div class="method-heading">
182
+ <a href="ApproachAction.src/M000075.html" target="Code" class="method-signature"
183
+ onclick="popupCode('ApproachAction.src/M000075.html');return false;">
184
+ <span class="method-name">start</span><span class="method-args">(actor, target)</span>
185
+ </a>
186
+ </div>
187
+
188
+ <div class="method-description">
189
+ <p>
190
+ Begin tracking time between actions.
191
+ </p>
192
+ </div>
193
+ </div>
194
+
195
+
196
+ </div>
197
+
198
+
199
+ </div>
200
+
201
+
202
+ <div id="validator-badges">
203
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
204
+ </div>
205
+
206
+ </body>
207
+ </html>
@@ -0,0 +1,19 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html>
7
+ <head>
8
+ <title>new (Zyps::ApproachAction)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File lib/zyps/actions.rb, line 81</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">heading</span> = <span class="ruby-constant">Vector</span>.<span class="ruby-identifier">new</span>, <span class="ruby-identifier">turn_rate</span> = <span class="ruby-value">360</span>)
15
+ <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">heading</span>, <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">turn_rate</span> = <span class="ruby-identifier">heading</span>, <span class="ruby-identifier">turn_rate</span>
16
+ <span class="ruby-ivar">@clock</span> = <span class="ruby-constant">Clock</span>.<span class="ruby-identifier">new</span>
17
+ <span class="ruby-keyword kw">end</span></pre>
18
+ </body>
19
+ </html>
@@ -0,0 +1,19 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html>
7
+ <head>
8
+ <title>start (Zyps::ApproachAction)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File lib/zyps/actions.rb, line 86</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">start</span>(<span class="ruby-identifier">actor</span>, <span class="ruby-identifier">target</span>)
15
+ <span class="ruby-keyword kw">super</span>
16
+ <span class="ruby-ivar">@clock</span>.<span class="ruby-identifier">reset_elapsed_time</span>
17
+ <span class="ruby-keyword kw">end</span></pre>
18
+ </body>
19
+ </html>
@@ -0,0 +1,38 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html>
7
+ <head>
8
+ <title>do (Zyps::ApproachAction)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File lib/zyps/actions.rb, line 91</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">do</span>(<span class="ruby-identifier">actor</span>, <span class="ruby-identifier">target</span>)
15
+ <span class="ruby-comment cmt">#Find the difference between the current heading and the angle to the target.</span>
16
+ <span class="ruby-identifier">turn_angle</span> = <span class="ruby-constant">Utility</span>.<span class="ruby-identifier">find_angle</span>(<span class="ruby-identifier">actor</span>.<span class="ruby-identifier">location</span>, <span class="ruby-identifier">target</span>.<span class="ruby-identifier">location</span>) <span class="ruby-operator">-</span> <span class="ruby-ivar">@heading</span>.<span class="ruby-identifier">pitch</span>
17
+ <span class="ruby-comment cmt">#If the angle is the long way around from the current heading, change it to the smaller angle.</span>
18
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">turn_angle</span> <span class="ruby-operator">&gt;</span> <span class="ruby-value">180</span> <span class="ruby-keyword kw">then</span>
19
+ <span class="ruby-identifier">turn_angle</span> <span class="ruby-operator">-=</span> <span class="ruby-value">360.0</span>
20
+ <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">turn_angle</span> <span class="ruby-operator">&lt;</span> <span class="ruby-value">-180</span> <span class="ruby-keyword kw">then</span>
21
+ <span class="ruby-identifier">turn_angle</span> <span class="ruby-operator">+=</span> <span class="ruby-value">360.0</span>
22
+ <span class="ruby-keyword kw">end</span>
23
+ <span class="ruby-comment cmt">#The creature can only turn as fast as the elapsed time, of course.</span>
24
+ <span class="ruby-identifier">maximum_turn</span> = <span class="ruby-identifier">turn_rate</span> <span class="ruby-operator">*</span> <span class="ruby-ivar">@clock</span>.<span class="ruby-identifier">elapsed_time</span>
25
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">turn_angle</span>.<span class="ruby-identifier">abs</span> <span class="ruby-operator">&gt;</span> <span class="ruby-identifier">maximum_turn</span>
26
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">turn_angle</span> <span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span>
27
+ <span class="ruby-identifier">turn_angle</span> = <span class="ruby-identifier">maximum_turn</span>
28
+ <span class="ruby-keyword kw">else</span>
29
+ <span class="ruby-identifier">turn_angle</span> = <span class="ruby-identifier">maximum_turn</span> <span class="ruby-operator">*</span> <span class="ruby-value">-1</span>
30
+ <span class="ruby-keyword kw">end</span>
31
+ <span class="ruby-keyword kw">end</span>
32
+ <span class="ruby-comment cmt">#Turn the appropriate amount.</span>
33
+ <span class="ruby-ivar">@heading</span>.<span class="ruby-identifier">pitch</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">turn_angle</span>
34
+ <span class="ruby-comment cmt">#Apply the heading to the creature's movement vector.</span>
35
+ <span class="ruby-identifier">actor</span>.<span class="ruby-identifier">vector</span> <span class="ruby-operator">+=</span> <span class="ruby-ivar">@heading</span>
36
+ <span class="ruby-keyword kw">end</span></pre>
37
+ </body>
38
+ </html>
@@ -0,0 +1,206 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
+ <head>
8
+ <title>Class: Zyps::Behavior</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
12
+ <script type="text/javascript">
13
+ // <![CDATA[
14
+
15
+ function popupCode( url ) {
16
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
+ }
18
+
19
+ function toggleCode( id ) {
20
+ if ( document.getElementById )
21
+ elem = document.getElementById( id );
22
+ else if ( document.all )
23
+ elem = eval( "document.all." + id );
24
+ else
25
+ return false;
26
+
27
+ elemStyle = elem.style;
28
+
29
+ if ( elemStyle.display != "block" ) {
30
+ elemStyle.display = "block"
31
+ } else {
32
+ elemStyle.display = "none"
33
+ }
34
+
35
+ return true;
36
+ }
37
+
38
+ // Make codeblocks hidden by default
39
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
+
41
+ // ]]>
42
+ </script>
43
+
44
+ </head>
45
+ <body>
46
+
47
+
48
+
49
+ <div id="classHeader">
50
+ <table class="header-table">
51
+ <tr class="top-aligned-row">
52
+ <td><strong>Class</strong></td>
53
+ <td class="class-name-in-header">Zyps::Behavior</td>
54
+ </tr>
55
+ <tr class="top-aligned-row">
56
+ <td><strong>In:</strong></td>
57
+ <td>
58
+ <a href="../../files/lib/zyps_rb.html">
59
+ lib/zyps.rb
60
+ </a>
61
+ <br />
62
+ </td>
63
+ </tr>
64
+
65
+ <tr class="top-aligned-row">
66
+ <td><strong>Parent:</strong></td>
67
+ <td>
68
+ Object
69
+ </td>
70
+ </tr>
71
+ </table>
72
+ </div>
73
+ <!-- banner header -->
74
+
75
+ <div id="bodyContent">
76
+
77
+
78
+
79
+ <div id="contextContent">
80
+
81
+ <div id="description">
82
+ <p>
83
+ A behavior that a <a href="Creature.html">Creature</a> engages in. The
84
+ target can have its tags or colors changed, it can be &quot;herded&quot;,
85
+ it can be destroyed, or any other action the library user can dream up.
86
+ Likewise, the subject can change its own attributes, it can approach or
87
+ flee from the target, it can spawn <a href="Behavior.html#M000012">new</a>
88
+ Creatures or GameObjects (like bullets), or anything else.
89
+ </p>
90
+
91
+ </div>
92
+
93
+
94
+ </div>
95
+
96
+ <div id="method-list">
97
+ <h3 class="section-bar">Methods</h3>
98
+
99
+ <div class="name-list">
100
+ <a href="#M000012">new</a>&nbsp;&nbsp;
101
+ <a href="#M000013">perform</a>&nbsp;&nbsp;
102
+ </div>
103
+ </div>
104
+
105
+ </div>
106
+
107
+
108
+ <!-- if includes -->
109
+
110
+ <div id="section">
111
+
112
+
113
+
114
+
115
+
116
+ <div id="attribute-list">
117
+ <h3 class="section-bar">Attributes</h3>
118
+
119
+ <div class="name-list">
120
+ <table>
121
+ <tr class="top-aligned-row context-row">
122
+ <td class="context-item-name">actions</td>
123
+ <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
124
+ <td class="context-item-desc">
125
+ A list of <a href="Action.html">Action</a> objects, which are called with
126
+ the object and its target when all conditions are met. An action can act on
127
+ the subject or its target.
128
+
129
+ </td>
130
+ </tr>
131
+ <tr class="top-aligned-row context-row">
132
+ <td class="context-item-name">conditions</td>
133
+ <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
134
+ <td class="context-item-desc">
135
+ A list of <a href="Condition.html">Condition</a> objects, which are called
136
+ with the object itself and its target. A condition can consider the tags on
137
+ the target, the distance from the subject, or any other criteria. If any
138
+ condition returns false, the behavior will not be carried out (or stopped
139
+ if it has begun).
140
+
141
+ </td>
142
+ </tr>
143
+ </table>
144
+ </div>
145
+ </div>
146
+
147
+
148
+
149
+ <!-- if method_list -->
150
+ <div id="methods">
151
+ <h3 class="section-bar">Public Class methods</h3>
152
+
153
+ <div id="method-M000012" class="method-detail">
154
+ <a name="M000012"></a>
155
+
156
+ <div class="method-heading">
157
+ <a href="Behavior.src/M000012.html" target="Code" class="method-signature"
158
+ onclick="popupCode('Behavior.src/M000012.html');return false;">
159
+ <span class="method-name">new</span><span class="method-args">(actions = [], conditions = [])</span>
160
+ </a>
161
+ </div>
162
+
163
+ <div class="method-description">
164
+ <p>
165
+ Optionally takes an array of actions and one of conditions.
166
+ </p>
167
+ </div>
168
+ </div>
169
+
170
+ <h3 class="section-bar">Public Instance methods</h3>
171
+
172
+ <div id="method-M000013" class="method-detail">
173
+ <a name="M000013"></a>
174
+
175
+ <div class="method-heading">
176
+ <a href="Behavior.src/M000013.html" target="Code" class="method-signature"
177
+ onclick="popupCode('Behavior.src/M000013.html');return false;">
178
+ <span class="method-name">perform</span><span class="method-args">(actor, environment)</span>
179
+ </a>
180
+ </div>
181
+
182
+ <div class="method-description">
183
+ <p>
184
+ Test all conditions against each object in the evironment. For the first
185
+ object that meets all of them, mark it active (and operate on it first next
186
+ time). Then call start() (if applicable) and <a
187
+ href="Behavior.html#M000013">perform</a>() for all actions against the
188
+ active target. If any action or condition returns false, stop all actions,
189
+ and deselect the active target.
190
+ </p>
191
+ </div>
192
+ </div>
193
+
194
+
195
+ </div>
196
+
197
+
198
+ </div>
199
+
200
+
201
+ <div id="validator-badges">
202
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
203
+ </div>
204
+
205
+ </body>
206
+ </html>