limelight 0.0.1-java

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.
Files changed (165) hide show
  1. data/bin/icons/icon.ico +0 -0
  2. data/bin/icons/icon_48.gif +0 -0
  3. data/bin/icons/limelight.icns +0 -0
  4. data/bin/icons/splash.png +0 -0
  5. data/bin/limelight +6 -0
  6. data/bin/ll +10 -0
  7. data/bin/ll.bat +5 -0
  8. data/lib/init.rb +11 -0
  9. data/lib/limelight/build_exception.rb +45 -0
  10. data/lib/limelight/button_group_cache.rb +11 -0
  11. data/lib/limelight/casting_director.rb +72 -0
  12. data/lib/limelight/commands.rb +66 -0
  13. data/lib/limelight/file_chooser.rb +55 -0
  14. data/lib/limelight/file_filter.rb +26 -0
  15. data/lib/limelight/java_util.rb +29 -0
  16. data/lib/limelight/limelight_exception.rb +9 -0
  17. data/lib/limelight/loaders/file_scene_loader.rb +48 -0
  18. data/lib/limelight/menu_bar.rb +49 -0
  19. data/lib/limelight/paint_action.rb +25 -0
  20. data/lib/limelight/pen.rb +53 -0
  21. data/lib/limelight/players/button.rb +29 -0
  22. data/lib/limelight/players/check_box.rb +38 -0
  23. data/lib/limelight/players/combo_box.rb +44 -0
  24. data/lib/limelight/players/radio_button.rb +47 -0
  25. data/lib/limelight/players/text_area.rb +25 -0
  26. data/lib/limelight/players/text_box.rb +25 -0
  27. data/lib/limelight/players.rb +9 -0
  28. data/lib/limelight/producer.rb +141 -0
  29. data/lib/limelight/production.rb +64 -0
  30. data/lib/limelight/production_builder.rb +49 -0
  31. data/lib/limelight/prop.rb +241 -0
  32. data/lib/limelight/prop_builder.rb +60 -0
  33. data/lib/limelight/scene.rb +75 -0
  34. data/lib/limelight/stage.rb +93 -0
  35. data/lib/limelight/stage_builder.rb +62 -0
  36. data/lib/limelight/styles.rb +37 -0
  37. data/lib/limelight/styles_builder.rb +61 -0
  38. data/lib/limelight/theater.rb +42 -0
  39. data/lib/limelight/util.rb +26 -0
  40. data/lib/limelight/version.rb +20 -0
  41. data/lib/limelight.jar +0 -0
  42. data/productions/examples/8thlight.com/about/about.txt +24 -0
  43. data/productions/examples/8thlight.com/about/props.rb +11 -0
  44. data/productions/examples/8thlight.com/about/styles.rb +2 -0
  45. data/productions/examples/8thlight.com/footer.rb +6 -0
  46. data/productions/examples/8thlight.com/home/props.rb +28 -0
  47. data/productions/examples/8thlight.com/home/styles.rb +2 -0
  48. data/productions/examples/8thlight.com/images/anvil.jpg +0 -0
  49. data/productions/examples/8thlight.com/images/bg.jpg +0 -0
  50. data/productions/examples/8thlight.com/images/botticelli.jpg +0 -0
  51. data/productions/examples/8thlight.com/images/button_bg.jpg +0 -0
  52. data/productions/examples/8thlight.com/images/canvas_bg.jpg +0 -0
  53. data/productions/examples/8thlight.com/images/footer_bg.jpg +0 -0
  54. data/productions/examples/8thlight.com/images/header.jpg +0 -0
  55. data/productions/examples/8thlight.com/images/moses.jpg +0 -0
  56. data/productions/examples/8thlight.com/images/statemachine_thumbnail.png +0 -0
  57. data/productions/examples/8thlight.com/images/thumbnail_book.jpg +0 -0
  58. data/productions/examples/8thlight.com/menu.rb +11 -0
  59. data/productions/examples/8thlight.com/services/props.rb +11 -0
  60. data/productions/examples/8thlight.com/services/services.txt +8 -0
  61. data/productions/examples/8thlight.com/services/styles.rb +2 -0
  62. data/productions/examples/8thlight.com/stages.rb +8 -0
  63. data/productions/examples/8thlight.com/styles.rb +205 -0
  64. data/productions/examples/calculator/players/button.rb +24 -0
  65. data/productions/examples/calculator/players/calculator.rb +15 -0
  66. data/productions/examples/calculator/players/calculator_model.rb +13 -0
  67. data/productions/examples/calculator/props.rb +23 -0
  68. data/productions/examples/calculator/styles.rb +38 -0
  69. data/productions/examples/langstons_ant/html_javascript/ant.css +39 -0
  70. data/productions/examples/langstons_ant/html_javascript/ant.html +22 -0
  71. data/productions/examples/langstons_ant/html_javascript/ant.js +23 -0
  72. data/productions/examples/langstons_ant/players/ant.rb +103 -0
  73. data/productions/examples/langstons_ant/players/log.rb +29 -0
  74. data/productions/examples/langstons_ant/players/start_stop_button.rb +37 -0
  75. data/productions/examples/langstons_ant/players/world.rb +61 -0
  76. data/productions/examples/langstons_ant/props.rb +22 -0
  77. data/productions/examples/langstons_ant/styles.rb +105 -0
  78. data/productions/examples/sandbox/click_me/players/chromaton.rb +47 -0
  79. data/productions/examples/sandbox/click_me/props.rb +8 -0
  80. data/productions/examples/sandbox/click_me/styles.rb +12 -0
  81. data/productions/examples/sandbox/floaters/players/floater.rb +92 -0
  82. data/productions/examples/sandbox/floaters/players/surface.rb +17 -0
  83. data/productions/examples/sandbox/floaters/props.rb +10 -0
  84. data/productions/examples/sandbox/floaters/styles.rb +25 -0
  85. data/productions/examples/sandbox/gradients/players/spinner.rb +23 -0
  86. data/productions/examples/sandbox/gradients/players/teaser.rb +26 -0
  87. data/productions/examples/sandbox/gradients/players/wave.rb +26 -0
  88. data/productions/examples/sandbox/gradients/players/waves.rb +26 -0
  89. data/productions/examples/sandbox/gradients/props.rb +13 -0
  90. data/productions/examples/sandbox/gradients/styles.rb +47 -0
  91. data/productions/examples/sandbox/header.rb +15 -0
  92. data/productions/examples/sandbox/homer/players/homer.rb +20 -0
  93. data/productions/examples/sandbox/homer/props.rb +10 -0
  94. data/productions/examples/sandbox/homer/styles.rb +17 -0
  95. data/productions/examples/sandbox/images/arch.jpg +0 -0
  96. data/productions/examples/sandbox/images/beach.jpg +0 -0
  97. data/productions/examples/sandbox/images/homer.jpg +0 -0
  98. data/productions/examples/sandbox/images/limelight_spotlight.jpg +0 -0
  99. data/productions/examples/sandbox/images/marilyn.jpg +0 -0
  100. data/productions/examples/sandbox/inputs/players/button_input.rb +48 -0
  101. data/productions/examples/sandbox/inputs/players/check_box_input.rb +40 -0
  102. data/productions/examples/sandbox/inputs/players/combo_box_input.rb +41 -0
  103. data/productions/examples/sandbox/inputs/players/radio_button_input.rb +43 -0
  104. data/productions/examples/sandbox/inputs/players/text_area_input.rb +36 -0
  105. data/productions/examples/sandbox/inputs/players/text_box_input.rb +36 -0
  106. data/productions/examples/sandbox/inputs/props.rb +40 -0
  107. data/productions/examples/sandbox/inputs/styles.rb +39 -0
  108. data/productions/examples/sandbox/players/sandbox.rb +11 -0
  109. data/productions/examples/sandbox/rounded_corners/players/box.rb +11 -0
  110. data/productions/examples/sandbox/rounded_corners/props.rb +22 -0
  111. data/productions/examples/sandbox/rounded_corners/styles.rb +18 -0
  112. data/productions/examples/sandbox/scrolling/players/cell.rb +16 -0
  113. data/productions/examples/sandbox/scrolling/props.rb +40 -0
  114. data/productions/examples/sandbox/scrolling/styles.rb +25 -0
  115. data/productions/examples/sandbox/sketching/players/sketchpad.rb +46 -0
  116. data/productions/examples/sandbox/sketching/props.rb +25 -0
  117. data/productions/examples/sandbox/sketching/styles.rb +36 -0
  118. data/productions/examples/sandbox/stages.rb +6 -0
  119. data/productions/examples/sandbox/styles.rb +37 -0
  120. data/productions/examples/sandbox/teaser/players/fader.rb +58 -0
  121. data/productions/examples/sandbox/teaser/props.rb +14 -0
  122. data/productions/examples/sandbox/teaser/styles.rb +22 -0
  123. data/productions/examples/tutorials/tutorial_1/players/sample.rb +11 -0
  124. data/productions/examples/tutorials/tutorial_1/props.rb +9 -0
  125. data/productions/examples/tutorials/tutorial_1/styles.rb +27 -0
  126. data/productions/stage_composer/init.rb +10 -0
  127. data/productions/stage_composer/inspector/players/inspector.rb +80 -0
  128. data/productions/stage_composer/inspector/players/prop_row.rb +12 -0
  129. data/productions/stage_composer/inspector/players/prop_tree.rb +33 -0
  130. data/productions/stage_composer/inspector/players/style_table.rb +12 -0
  131. data/productions/stage_composer/inspector/players/style_value.rb +16 -0
  132. data/productions/stage_composer/inspector/props.rb +19 -0
  133. data/productions/stage_composer/inspector/styles.rb +71 -0
  134. data/productions/stage_composer/lib/init.rb +5 -0
  135. data/productions/stage_composer/lib/limelight/composer/controller.rb +51 -0
  136. data/productions/stage_composer/lib/limelight/composer/lethargy.rb +24 -0
  137. data/productions/stage_composer/production.rb +6 -0
  138. data/productions/stage_composer/stages.rb +15 -0
  139. data/productions/startup/props.rb +5 -0
  140. data/spec/casting_director_spec.rb +94 -0
  141. data/spec/commands_spec.rb +33 -0
  142. data/spec/file_chooser_spec.rb +64 -0
  143. data/spec/file_filter_spec.rb +29 -0
  144. data/spec/java_util_spec.rb +53 -0
  145. data/spec/loaders/file_loader_spec.rb +28 -0
  146. data/spec/paint_action_spec.rb +30 -0
  147. data/spec/pen_spec.rb +62 -0
  148. data/spec/players/button_spec.rb +31 -0
  149. data/spec/players/check_box_spec.rb +40 -0
  150. data/spec/players/combo_box_spec.rb +39 -0
  151. data/spec/players/radio_button_spec.rb +75 -0
  152. data/spec/players/text_area_spec.rb +37 -0
  153. data/spec/players/text_box_spec.rb +37 -0
  154. data/spec/producer_spec.rb +157 -0
  155. data/spec/production_builder_spec.rb +48 -0
  156. data/spec/production_spec.rb +75 -0
  157. data/spec/prop_builder_spec.rb +178 -0
  158. data/spec/prop_spec.rb +216 -0
  159. data/spec/scene_spec.rb +34 -0
  160. data/spec/spec_helper.rb +18 -0
  161. data/spec/stage_builder_spec.rb +90 -0
  162. data/spec/stage_spec.rb +57 -0
  163. data/spec/styles_builder_spec.rb +123 -0
  164. data/spec/theater_spec.rb +66 -0
  165. metadata +275 -0
@@ -0,0 +1,205 @@
1
+ #- Copyright 2008 8th Light, Inc.
2
+ #- Limelight and all included source files are distributed under terms of the GNU LGPL.
3
+
4
+ page {
5
+ width "100%"
6
+ height "100%"
7
+ horizontal_alignment "center"
8
+ background_image "images/bg.jpg"
9
+ }
10
+
11
+ main_column {
12
+ border_width 0
13
+ background_image "images/canvas_bg.jpg"
14
+ width 823
15
+ height :auto
16
+ horizontal_alignment "center"
17
+ }
18
+
19
+ header {
20
+ height 200
21
+ background_image "images/header.jpg"
22
+ width 823
23
+ horizontal_alignment "center"
24
+ }
25
+
26
+ menu {
27
+ height 67
28
+ top_border_width 1
29
+ bottom_border_width 1
30
+ border_color "#333333"
31
+ width 823
32
+ horizontal_alignment :right
33
+ right_margin 25
34
+ left_margin 25
35
+ bottom_margin 15
36
+ }
37
+
38
+ link {
39
+ width 80
40
+ height 50
41
+ text_color "#0049F4"
42
+ font_face "Arial"
43
+ font_size 13
44
+ vertical_alignment :center
45
+ horizontal_alignment :center
46
+ hover {
47
+ text_color "#ffffff"
48
+ background_image "images/button_bg.jpg"
49
+ }
50
+ }
51
+
52
+ tag_line {
53
+ width 823
54
+ height 70
55
+ background_image "images/anvil.jpg"
56
+ right_margin 25
57
+ left_margin 25
58
+ horizontal_alignment :left
59
+ font_style "italics"
60
+ text_color "white"
61
+ font_size 18
62
+ top_padding 10
63
+ left_padding 10
64
+ right_padding 375
65
+ }
66
+
67
+ services_tagline {
68
+ extends :tag_line
69
+ background_image "images/botticelli.jpg"
70
+ horizontal_alignment "right"
71
+ }
72
+
73
+ about_tagline {
74
+ extends :tag_line
75
+ background_image "images/moses.jpg"
76
+ horizontal_alignment "right"
77
+ }
78
+
79
+ section_title {
80
+ width 823
81
+ height 50
82
+ top_margin 20
83
+ left_margin 50
84
+ right_margin 50
85
+ bottom_border_width 1
86
+ border_color "#0049F4"
87
+ text_color "white"
88
+ font_size 20
89
+ font_style "bold"
90
+ }
91
+
92
+ section_body {
93
+ width 823
94
+ height :auto
95
+ left_margin 50
96
+ right_margin 50
97
+ text_color "white"
98
+ font_size 14
99
+ }
100
+
101
+ spot_light {
102
+ width 412
103
+ height 300
104
+ top_margin 20
105
+ left_margin 50
106
+ right_margin 50
107
+ }
108
+
109
+ spot_light_title {
110
+ width 312
111
+ height 45
112
+ bottom_border_width 1
113
+ border_color "#0049F4"
114
+ font_size 20
115
+ text_color "white"
116
+ }
117
+
118
+ book_news {
119
+ height 75
120
+ width "100%"
121
+ bottom_border_width 1
122
+ border_color "#333333"
123
+ top_margin 10
124
+ }
125
+
126
+ book_news_img {
127
+ background_image "images/thumbnail_book.jpg"
128
+ width 59
129
+ height 58
130
+ }
131
+
132
+ book_news_text {
133
+ width 253
134
+ height 58
135
+ left_margin 10
136
+ font_size 15
137
+ font_face "Helvetica"
138
+ text_color "#919191"
139
+ }
140
+
141
+ sm_news {
142
+ height 75
143
+ width "100%"
144
+ bottom_border_width 1
145
+ border_color "#333333"
146
+ top_margin 10
147
+ }
148
+
149
+ sm_news_img {
150
+ background_image "images/statemachine_thumbnail.png"
151
+ width 59
152
+ height 58
153
+ }
154
+
155
+ sm_news_text {
156
+ extends :book_news_text
157
+ }
158
+
159
+ news {
160
+ width 411
161
+ height 320
162
+ top_margin 20
163
+ left_margin 30
164
+ right_margin 50
165
+ }
166
+
167
+ news_title {
168
+ width 311
169
+ height 45
170
+ bottom_border_width 1
171
+ border_color "#0049F4"
172
+ font_size 20
173
+ text_color "white"
174
+ }
175
+
176
+ new_item {
177
+ text_color "#919191"
178
+ font_size 12
179
+ font_face "Helvetica"
180
+ height 50
181
+ width "100%"
182
+ bottom_border_width 1
183
+ border_color "#333333"
184
+ top_margin 10
185
+ background_color "black"
186
+ hover {
187
+ text_color "white"
188
+ background_color "black"
189
+ }
190
+ }
191
+
192
+ footer {
193
+ background_image "images/footer_bg.jpg"
194
+ height 80
195
+ width 823
196
+ }
197
+
198
+ copyright {
199
+ top_margin 40
200
+ vertical_alignment :center
201
+ horizontal_alignment :center
202
+ text_color "#666"
203
+ width 823
204
+ height 80
205
+ }
@@ -0,0 +1,24 @@
1
+ #- Copyright 2008 8th Light, Inc.
2
+ #- Limelight and all included source files are distributed under terms of the GNU LGPL.
3
+
4
+ module Button
5
+
6
+ def self.extended(extended_block)
7
+ puts "Button extended"
8
+ end
9
+
10
+ def mouse_clicked(e)
11
+ screen = scene.find('screen')
12
+ if self.text != "="
13
+ screen.text += self.text
14
+ screen.style.background_color = "yellow"
15
+ screen.update
16
+ else
17
+ result = eval(screen.text)
18
+ screen.text = result.to_s
19
+ screen.style.background_color = "white"
20
+ screen.update
21
+ end
22
+ puts "clicked"
23
+ end
24
+ end
@@ -0,0 +1,15 @@
1
+ #- Copyright 2008 8th Light, Inc.
2
+ #- Limelight and all included source files are distributed under terms of the GNU LGPL.
3
+
4
+ require 'calculator_model'
5
+ module Calculator
6
+
7
+ attr_accessor :calculator_model
8
+
9
+ def extended
10
+ p self
11
+ @calculator_model = ::CalculatorModel.new
12
+ end
13
+
14
+
15
+ end
@@ -0,0 +1,13 @@
1
+ #- Copyright 2008 8th Light, Inc.
2
+ #- Limelight and all included source files are distributed under terms of the GNU LGPL.
3
+
4
+ class CalculatorModel
5
+ attr_accessor :display_text
6
+ def button_pressed(button)
7
+ if(button == "=")
8
+ @display_text = eval(@display_text).to_s
9
+ else
10
+ @display_text = display_text + button
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,23 @@
1
+ #- Copyright 2008 8th Light, Inc.
2
+ #- Limelight and all included source files are distributed under terms of the GNU LGPL.
3
+
4
+ __ :name => "calculator"
5
+ screen :id => "screen", :text => "1000000000"
6
+ buttons do
7
+ button :text => "1"
8
+ button :text => "2"
9
+ button :text => "3"
10
+ button :text => "+"
11
+ button :text => "4"
12
+ button :text => "5"
13
+ button :text => "6"
14
+ button :text => "-"
15
+ button :text => "7"
16
+ button :text => "8"
17
+ button :text => "9"
18
+ button :text => "="
19
+ button :text => ""
20
+ button :text => "0"
21
+ button :text => ""
22
+ button :text => ""
23
+ end
@@ -0,0 +1,38 @@
1
+ #- Copyright 2008 8th Light, Inc.
2
+ #- Limelight and all included source files are distributed under terms of the GNU LGPL.
3
+
4
+ calculator {
5
+ width 1000
6
+ height 900
7
+ horizontal_alignment :center
8
+ vertical_alignment :top
9
+ background_color :blue
10
+ }
11
+
12
+ screen {
13
+ width 1000
14
+ height 100
15
+ background_color :red
16
+ left_margin 250
17
+ right_margin 250
18
+ text_color :black
19
+ font_size 20
20
+ }
21
+
22
+ buttons {
23
+ width 500
24
+ height 500
25
+ background_color :green
26
+ }
27
+
28
+ button {
29
+ width 125
30
+ height 125
31
+ background_color :white
32
+ text_color :black
33
+ font_size 20
34
+ horizontal_alignment :center
35
+ vertical_alignment :center
36
+ border_width 10
37
+ border_color :black
38
+ }
@@ -0,0 +1,39 @@
1
+ body {
2
+ background-color: blue;
3
+ margin-left: auto;
4
+ margin-right: auto;
5
+ width: 600px;
6
+ }
7
+
8
+ #title {
9
+ border: 2px solid orange;
10
+ font-size: 20pt;
11
+ color: orange;
12
+ padding: 20px;
13
+ text-align: center;
14
+ }
15
+
16
+ #description {
17
+ font-size: 15pt;
18
+ margin: auto;
19
+ padding: 10px;
20
+ }
21
+
22
+ #world {
23
+ width: 500px;
24
+ height: 500px;
25
+ margin: auto;
26
+ border: 2px solid gray;
27
+ border-right: 1px solid gray;
28
+ border-bottom: 1px solid gray;
29
+ }
30
+
31
+ .row {
32
+
33
+ }
34
+
35
+ .cell {
36
+ width: 4px;
37
+ height: 4px;
38
+ border: 1px solid gray;
39
+ }
@@ -0,0 +1,22 @@
1
+ <html>
2
+ <head>
3
+ <title>Langston's Ant</title>
4
+ <link rel=StyleSheet href="ant.css" type="text/css" media="screen, print"/>
5
+ <script language="JavaScript" src="ant.js"/>
6
+ </head>
7
+ <body onload="load()">
8
+ <div id="title">
9
+ Langston's Ant
10
+ </div>
11
+ <div id="description">
12
+ The Rules:<br/>
13
+ If the ant is on a black dot, paint it white and go right.<br/>
14
+ If the ant is on a white dot, paint it black and go left.<br/>
15
+ </div>
16
+ <table id="world" cellpadding="0" cellspacing="0">
17
+
18
+ </table>
19
+ <input type="submit" value="Start" onclick="start()">
20
+ </body>
21
+ </html>
22
+
@@ -0,0 +1,23 @@
1
+
2
+ function load()
3
+ {
4
+ var world = document.getElementById('world');
5
+ for(var row = 0; row < 99; row++)
6
+ {
7
+ var r = document.createElement('tr');
8
+ r.setAttribute('class', 'row');
9
+ world.appendChild(r);
10
+ for(var col = 0; col < 99; col++)
11
+ {
12
+ var c = document.createElement('td');
13
+ c.setAttribute('class', 'cell');
14
+ c.setAttribute('id', '' + row + "," + col);
15
+ r.appendChild(c);
16
+ }
17
+ }
18
+ }
19
+
20
+ function start()
21
+ {
22
+
23
+ }
@@ -0,0 +1,103 @@
1
+ #- Copyright 2008 8th Light, Inc.
2
+ #- Limelight and all included source files are distributed under terms of the GNU LGPL.
3
+
4
+ class Ant
5
+
6
+ NORTH = 1
7
+ SOUTH = 2
8
+ EAST = 3
9
+ WEST = 4
10
+
11
+ BLACK = "black"
12
+ WHITE = "white"
13
+
14
+ def initialize(x, y, world, world_size)
15
+ @world = world
16
+ @x = x
17
+ @y = y
18
+ @world_size = world_size
19
+ @direction = NORTH
20
+ @log = @world.scene.find("log")
21
+ @steps = 0
22
+ end
23
+
24
+ def walk
25
+ @walking = true
26
+ while @walking
27
+ make_step
28
+ @steps += 1
29
+ @log.update_counter(@steps)
30
+ @log.update_location("#{@x}, #{@y}")
31
+ # sleep(.25)
32
+ end
33
+ end
34
+
35
+ def stop
36
+ @walking = false
37
+ end
38
+
39
+ def make_step
40
+ if @world.cells["#{@x},#{@y}"] # black
41
+ @world.paint_cell(@x, @y, WHITE)
42
+ @world.cells["#{@x},#{@y}"] = false
43
+ go_right
44
+ else # white
45
+ @world.paint_cell(@x, @y, BLACK)
46
+ @world.cells["#{@x},#{@y}"] = true
47
+ go_left
48
+ end
49
+
50
+ # cell = @world.cell_index["#{@x},#{@y}"]
51
+ # if cell.style.background_color == BLACK
52
+ # cell.style.background_color = WHITE
53
+ # go_right
54
+ # else
55
+ # cell.style.background_color = BLACK
56
+ # go_left
57
+ # end
58
+ # cell.update_now
59
+ wrap_if_needed
60
+ end
61
+
62
+ def go_right
63
+ case @direction
64
+ when NORTH
65
+ @direction = EAST
66
+ @x += 1
67
+ when EAST
68
+ @direction = SOUTH
69
+ @y += 1
70
+ when SOUTH
71
+ @direction = WEST
72
+ @x -= 1
73
+ when WEST
74
+ @direction = NORTH
75
+ @y -= 1
76
+ end
77
+ end
78
+
79
+ def go_left
80
+ case @direction
81
+ when NORTH
82
+ @direction = WEST
83
+ @x -= 1
84
+ when EAST
85
+ @direction = NORTH
86
+ @y -= 1
87
+ when SOUTH
88
+ @direction = EAST
89
+ @x += 1
90
+ when WEST
91
+ @direction = SOUTH
92
+ @y += 1
93
+ end
94
+ end
95
+
96
+ def wrap_if_needed
97
+ @y = 0 if @y >= @world_size
98
+ @y = @world_size - 1 if @y < 0
99
+ @x = 0 if @x >= @world_size
100
+ @x = @world_size - 1 if @x < 0
101
+ end
102
+
103
+ end
@@ -0,0 +1,29 @@
1
+ #- Copyright 2008 8th Light, Inc.
2
+ #- Limelight and all included source files are distributed under terms of the GNU LGPL.
3
+
4
+ module Log
5
+
6
+ def self.extended(prop)
7
+ end
8
+
9
+ def update_counter(steps)
10
+ count.text = steps.to_s
11
+ count.update
12
+ end
13
+
14
+ def update_location(coords)
15
+ location.text = coords.to_s
16
+ location.update
17
+ end
18
+
19
+ def count
20
+ @count = self.find("count") if not @count
21
+ return @count
22
+ end
23
+
24
+ def location
25
+ @location = self.find("location") if not @location
26
+ return @location
27
+ end
28
+
29
+ end
@@ -0,0 +1,37 @@
1
+ #- Copyright 2008 8th Light, Inc.
2
+ #- Limelight and all included source files are distributed under terms of the GNU LGPL.
3
+
4
+ module StartStopButton
5
+
6
+ def self.extended(prop)
7
+ end
8
+
9
+ def mouse_clicked(e)
10
+ if self.text == "Start"
11
+ self.text = "Stop"
12
+ start
13
+ else
14
+ stop
15
+ self.text = "Start"
16
+ end
17
+ end
18
+
19
+ def start
20
+ world = scene.find("world")
21
+ world.draw_grid
22
+ @ant = Ant.new(50, 50, world, 100) if @ant.nil?
23
+ @thread = Thread.new do
24
+ begin
25
+ @ant.walk
26
+ rescue Exception => e
27
+ puts e
28
+ puts e.backtrace
29
+ end
30
+ end
31
+ end
32
+
33
+ def stop
34
+ @ant.stop
35
+ end
36
+
37
+ end
@@ -0,0 +1,61 @@
1
+ #- Copyright 2008 8th Light, Inc.
2
+ #- Limelight and all included source files are distributed under terms of the GNU LGPL.
3
+
4
+ load File.expand_path(File.dirname(__FILE__) + "/ant.rb")
5
+
6
+ module World
7
+
8
+ # def self.extended(prop)
9
+ # create_time = 0
10
+ # add_time = 0
11
+ #
12
+ # prop.cell_index = {}
13
+ # 50.times do |y|
14
+ # 50.times do |x|
15
+ # id = "#{x},#{y}"
16
+ # start = Time.now
17
+ # cell = Limelight::Prop.new(:name => "cell", :id => id)
18
+ # create_time += Time.now - start
19
+ # start = Time.now
20
+ # prop.add(cell)
21
+ # add_time += Time.now - start
22
+ # prop.cell_index[id] = cell
23
+ # end
24
+ # end
25
+ # puts "create_time: #{create_time}"
26
+ # puts "add_time: #{add_time}"
27
+ # # create_time: 3.2059999999998325
28
+ # # add_time: 0.5010000000000002
29
+ #
30
+ # end
31
+
32
+ def self.extended(prop)
33
+ prop.cells = {}
34
+ end
35
+
36
+ attr_accessor :cells
37
+
38
+ def draw_grid()
39
+ area = bordered_area
40
+ pen = self.pen
41
+ pen.color = '#bbb'
42
+ x = 6
43
+ 99.times do |i|
44
+ pen.draw_line(x, area.top, x, area.bottom)
45
+ pen.draw_line(area.left, x, area.right, x)
46
+ x += 5
47
+ end
48
+ end
49
+
50
+ def paint_cell(x, y, color)
51
+ area = bordered_area
52
+ pen = self.pen
53
+ x2 = x * 5 + 2
54
+ y2 = y * 5 + 2
55
+ pen.color = color
56
+ pen.fill_rectangle(x2, y2, 4, 4)
57
+ end
58
+
59
+ attr_accessor :cell_index
60
+
61
+ end
@@ -0,0 +1,22 @@
1
+ #- Copyright 2008 8th Light, Inc.
2
+ #- Limelight and all included source files are distributed under terms of the GNU LGPL.
3
+
4
+ description_text = <<END
5
+ The Rules:
6
+ If the ant is on a black dot, paint it white and go right.
7
+ If the ant is on a white dot, paint it black and go left.
8
+ END
9
+
10
+ __ :name => "earth"
11
+ title :text => "Langston's Ant"
12
+ description :text => description_text
13
+ world :id => "world"
14
+ console {
15
+ start_stop_button :text => "Start", :players => "button"
16
+ log :id => "log" do
17
+ moves_label :text => "Moves:"
18
+ moves_counter :id => "count", :text => "# of moves"
19
+ location_label :text => "Location:"
20
+ location :id => "location", :text => "???"
21
+ end
22
+ }