shoes 4.0.0.pre2 → 4.0.0.pre3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (311) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +32 -21
  3. metadata +18 -337
  4. data/CHANGELOG +0 -84
  5. data/Gemfile +0 -24
  6. data/Guardfile +0 -11
  7. data/Rakefile +0 -14
  8. data/app.yaml +0 -60
  9. data/benchmark/app_clear.rb +0 -21
  10. data/benchmark/clear.rb +0 -69
  11. data/benchmark/memory/text_dispose.rb +0 -9
  12. data/benchmark/para_creator.rb +0 -9
  13. data/benchmark/paras.rb +0 -52
  14. data/benchmark/urls.rb +0 -40
  15. data/bin/ruby-shoes +0 -6
  16. data/bin/shoes-guard +0 -8
  17. data/bin/shoes-stub +0 -59
  18. data/ext/install/Rakefile +0 -29
  19. data/ext/install/shoes.bat +0 -9
  20. data/lib/shoes.rb +0 -5
  21. data/lib/shoes/ui/cli.rb +0 -102
  22. data/lib/shoes/ui/help.rb +0 -535
  23. data/lib/shoes/ui/manual.rb +0 -6
  24. data/lib/shoes/version.rb +0 -3
  25. data/manifests/common.rb +0 -34
  26. data/manifests/shoes.rb +0 -44
  27. data/samples/Gemfile +0 -3
  28. data/samples/Gemfile.lock +0 -35
  29. data/samples/README +0 -97
  30. data/samples/boom.rb +0 -239
  31. data/samples/class-book-adjusted.rb +0 -45
  32. data/samples/class-book.rb +0 -43
  33. data/samples/class-book.yaml +0 -387
  34. data/samples/clicky.rb +0 -24
  35. data/samples/cy.png +0 -0
  36. data/samples/expert-definr.rb +0 -23
  37. data/samples/expert-funnies.rb +0 -60
  38. data/samples/expert-game-of-life-adjusted.rb +0 -249
  39. data/samples/expert-game-of-life.rb +0 -243
  40. data/samples/expert-irb-adjusted.rb +0 -110
  41. data/samples/expert-irb.rb +0 -112
  42. data/samples/expert-minesweeper-adjusted.rb +0 -272
  43. data/samples/expert-minesweeper.rb +0 -267
  44. data/samples/expert-othello-adjusted.rb +0 -325
  45. data/samples/expert-othello.rb +0 -318
  46. data/samples/expert-pong.rb +0 -62
  47. data/samples/expert-snake.rb +0 -78
  48. data/samples/expert-tankspank.rb +0 -385
  49. data/samples/flow.rb +0 -63
  50. data/samples/good-arc.rb +0 -45
  51. data/samples/good-clock.rb +0 -51
  52. data/samples/good-displace.rb +0 -98
  53. data/samples/good-follow.rb +0 -26
  54. data/samples/good-potato-chopping.rb +0 -22
  55. data/samples/good-reminder.rb +0 -174
  56. data/samples/good-vjot.rb +0 -58
  57. data/samples/gray.rb +0 -11
  58. data/samples/loogink.png +0 -0
  59. data/samples/nks_booklist.rb +0 -24
  60. data/samples/nks_breadsticks.rb +0 -7
  61. data/samples/nks_dancing_circle.rb +0 -13
  62. data/samples/nks_dictionary.rb +0 -23
  63. data/samples/nks_edit_box.rb +0 -4
  64. data/samples/nks_edit_line.rb +0 -6
  65. data/samples/nks_notes.rb +0 -16
  66. data/samples/nks_poem.rb +0 -22
  67. data/samples/nks_self.rb +0 -6
  68. data/samples/nks_text_sizes.rb +0 -10
  69. data/samples/nks_trurl.rb +0 -5
  70. data/samples/original-manual-adjusted.rb +0 -475
  71. data/samples/original-manual.rb +0 -472
  72. data/samples/packaging/package_me.rb +0 -6
  73. data/samples/potato_chopping/1258_s001.gif +0 -0
  74. data/samples/potato_chopping/1258_s002.gif +0 -0
  75. data/samples/potato_chopping/1258_s003.gif +0 -0
  76. data/samples/potato_chopping/1258_s004.gif +0 -0
  77. data/samples/potato_chopping/1258_s005.gif +0 -0
  78. data/samples/potato_chopping/1258_s006.gif +0 -0
  79. data/samples/potato_chopping/1258_s007.gif +0 -0
  80. data/samples/potato_chopping/1258_s008.gif +0 -0
  81. data/samples/potato_chopping/1258_s009.gif +0 -0
  82. data/samples/potato_chopping/1258_s010.gif +0 -0
  83. data/samples/potato_chopping/1258_s011.gif +0 -0
  84. data/samples/potato_chopping/1258_s012.gif +0 -0
  85. data/samples/potato_chopping/1258_s013.gif +0 -0
  86. data/samples/potato_chopping/1258_s014.gif +0 -0
  87. data/samples/potato_chopping/1258_s015.gif +0 -0
  88. data/samples/potato_chopping/1258_s016.gif +0 -0
  89. data/samples/potato_chopping/1258_s017.gif +0 -0
  90. data/samples/potato_chopping/1258_s018.gif +0 -0
  91. data/samples/potato_chopping/1258_s019.gif +0 -0
  92. data/samples/potato_chopping/1258_s020.gif +0 -0
  93. data/samples/potato_chopping/1258_s021.gif +0 -0
  94. data/samples/potato_chopping/1258_s022.gif +0 -0
  95. data/samples/potato_chopping/1258_s023.gif +0 -0
  96. data/samples/potato_chopping/1258_s024.gif +0 -0
  97. data/samples/potato_chopping/1258_s025.gif +0 -0
  98. data/samples/potato_chopping/1258_s026.gif +0 -0
  99. data/samples/potato_chopping/1258_s027.gif +0 -0
  100. data/samples/potato_chopping/1258_s028.gif +0 -0
  101. data/samples/potato_chopping/1258_s029.gif +0 -0
  102. data/samples/potato_chopping/1258_s030.gif +0 -0
  103. data/samples/potato_chopping/1258_s031.gif +0 -0
  104. data/samples/potato_chopping/1258_s032.gif +0 -0
  105. data/samples/potato_chopping/1258_s033.gif +0 -0
  106. data/samples/potato_chopping/1258_s034.gif +0 -0
  107. data/samples/potato_chopping/1258_s035.gif +0 -0
  108. data/samples/potato_chopping/1258_s036.gif +0 -0
  109. data/samples/potato_chopping/1258_s037.gif +0 -0
  110. data/samples/potato_chopping/1258_s038.gif +0 -0
  111. data/samples/potato_chopping/1258_s039.gif +0 -0
  112. data/samples/potato_chopping/1258_s040.gif +0 -0
  113. data/samples/potato_chopping/1258_s041.gif +0 -0
  114. data/samples/potato_chopping/1258_s042.gif +0 -0
  115. data/samples/potato_chopping/1258_s043.gif +0 -0
  116. data/samples/potato_chopping/1258_s044.gif +0 -0
  117. data/samples/potato_chopping/1258_s045.gif +0 -0
  118. data/samples/potato_chopping/1258_s046.gif +0 -0
  119. data/samples/potato_chopping/1258_s047.gif +0 -0
  120. data/samples/potato_chopping/1258_s048.gif +0 -0
  121. data/samples/potato_chopping/1258_s049.gif +0 -0
  122. data/samples/potato_chopping/1258_s050.gif +0 -0
  123. data/samples/potato_chopping/1258_s051.gif +0 -0
  124. data/samples/potato_chopping/1258_s052.gif +0 -0
  125. data/samples/potato_chopping/1258_s053.gif +0 -0
  126. data/samples/potato_chopping/1258_s054.gif +0 -0
  127. data/samples/potato_chopping/1258_s055.gif +0 -0
  128. data/samples/potato_chopping/1258_s056.gif +0 -0
  129. data/samples/potato_chopping/1258_s057.gif +0 -0
  130. data/samples/potato_chopping/1258_s058.gif +0 -0
  131. data/samples/potato_chopping/1258_s059.gif +0 -0
  132. data/samples/present.rb +0 -27
  133. data/samples/progress.rb +0 -10
  134. data/samples/sample1.rb +0 -30
  135. data/samples/sample12.rb +0 -21
  136. data/samples/sample13.rb +0 -13
  137. data/samples/sample14.rb +0 -64
  138. data/samples/sample15.rb +0 -18
  139. data/samples/sample16.rb +0 -10
  140. data/samples/sample17.rb +0 -10
  141. data/samples/sample2.rb +0 -14
  142. data/samples/sample21.rb +0 -5
  143. data/samples/sample23.rb +0 -8
  144. data/samples/sample24.rb +0 -21
  145. data/samples/sample27.rb +0 -18
  146. data/samples/sample3.rb +0 -14
  147. data/samples/sample31.rb +0 -22
  148. data/samples/sample34.rb +0 -27
  149. data/samples/sample35.rb +0 -32
  150. data/samples/sample37.rb +0 -8
  151. data/samples/sample4.rb +0 -7
  152. data/samples/sample42.rb +0 -14
  153. data/samples/sample45.rb +0 -11
  154. data/samples/sample56.rb +0 -10
  155. data/samples/sample6.rb +0 -9
  156. data/samples/sample7.rb +0 -3
  157. data/samples/sample8.rb +0 -7
  158. data/samples/sample9.rb +0 -10
  159. data/samples/simple-accordion.rb +0 -75
  160. data/samples/simple-anim-shapes.rb +0 -17
  161. data/samples/simple-anim-text.rb +0 -13
  162. data/samples/simple-animate.rb +0 -12
  163. data/samples/simple-arc.rb +0 -23
  164. data/samples/simple-bounce.rb +0 -24
  165. data/samples/simple-brightness-transitions.rb +0 -8
  166. data/samples/simple-button-animate.rb +0 -16
  167. data/samples/simple-calc-2.rb +0 -34
  168. data/samples/simple-calc.rb +0 -70
  169. data/samples/simple-color-selector.rb +0 -10
  170. data/samples/simple-color-transitions.rb +0 -11
  171. data/samples/simple-control-sizes.rb +0 -24
  172. data/samples/simple-curve.rb +0 -26
  173. data/samples/simple-dialogs-outside.rb +0 -12
  174. data/samples/simple-dialogs.rb +0 -32
  175. data/samples/simple-displace.rb +0 -15
  176. data/samples/simple-downloader.rb +0 -27
  177. data/samples/simple-draw.rb +0 -13
  178. data/samples/simple-editor.rb +0 -28
  179. data/samples/simple-face.rb +0 -14
  180. data/samples/simple-flow-wrap.rb +0 -11
  181. data/samples/simple-font.rb +0 -17
  182. data/samples/simple-form.rb +0 -29
  183. data/samples/simple-form.shy +0 -0
  184. data/samples/simple-fullscreen.rb +0 -4
  185. data/samples/simple-guess-game.rb +0 -28
  186. data/samples/simple-keypress.rb +0 -14
  187. data/samples/simple-manual.rb +0 -2
  188. data/samples/simple-mask.rb +0 -21
  189. data/samples/simple-menu.rb +0 -47
  190. data/samples/simple-mouse-follow.rb +0 -8
  191. data/samples/simple-move.rb +0 -13
  192. data/samples/simple-oval.rb +0 -3
  193. data/samples/simple-sample-executor.rb +0 -6
  194. data/samples/simple-shoes-intro.rb +0 -22
  195. data/samples/simple-slide.rb +0 -56
  196. data/samples/simple-sound.rb +0 -30
  197. data/samples/simple-sphere.rb +0 -28
  198. data/samples/simple-stripes.rb +0 -8
  199. data/samples/simple-tictactoe.rb +0 -238
  200. data/samples/simple-timer.rb +0 -15
  201. data/samples/simple-video.rb +0 -13
  202. data/samples/simple-visibility.rb +0 -11
  203. data/samples/simple-widget.rb +0 -9
  204. data/samples/sounds/102719__sarge4267__explosion.mp3 +0 -0
  205. data/samples/sounds/145622__andybrannan__train-fog-horn-long-wyomming.aiff +0 -0
  206. data/samples/sounds/46492__phreaksaccount__shields1.ogg +0 -0
  207. data/samples/sounds/61847__simon-rue__boink-v3.wav +0 -0
  208. data/samples/swt-raw.rb +0 -20
  209. data/samples/troll.rb +0 -22
  210. data/shoes.gemspec +0 -29
  211. data/snapshots/sample1.png +0 -0
  212. data/snapshots/sample10.png +0 -0
  213. data/snapshots/sample11.png +0 -0
  214. data/snapshots/sample12.png +0 -0
  215. data/snapshots/sample13.png +0 -0
  216. data/snapshots/sample14.png +0 -0
  217. data/snapshots/sample15.png +0 -0
  218. data/snapshots/sample16.png +0 -0
  219. data/snapshots/sample17.png +0 -0
  220. data/snapshots/sample18.png +0 -0
  221. data/snapshots/sample19.png +0 -0
  222. data/snapshots/sample2.png +0 -0
  223. data/snapshots/sample20.png +0 -0
  224. data/snapshots/sample21.png +0 -0
  225. data/snapshots/sample22.png +0 -0
  226. data/snapshots/sample23.png +0 -0
  227. data/snapshots/sample24.png +0 -0
  228. data/snapshots/sample27.png +0 -0
  229. data/snapshots/sample28.png +0 -0
  230. data/snapshots/sample29.png +0 -0
  231. data/snapshots/sample3.png +0 -0
  232. data/snapshots/sample30.png +0 -0
  233. data/snapshots/sample31.png +0 -0
  234. data/snapshots/sample34.png +0 -0
  235. data/snapshots/sample35.png +0 -0
  236. data/snapshots/sample36.png +0 -0
  237. data/snapshots/sample37.png +0 -0
  238. data/snapshots/sample4.png +0 -0
  239. data/snapshots/sample42.png +0 -0
  240. data/snapshots/sample44.png +0 -0
  241. data/snapshots/sample45.png +0 -0
  242. data/snapshots/sample46.png +0 -0
  243. data/snapshots/sample5.png +0 -0
  244. data/snapshots/sample56.png +0 -0
  245. data/snapshots/sample6.png +0 -0
  246. data/snapshots/sample7.png +0 -0
  247. data/snapshots/sample8.png +0 -0
  248. data/snapshots/sample9.png +0 -0
  249. data/snapshots/sample99.png +0 -0
  250. data/static/PKGBUILD +0 -47
  251. data/static/Shoes.icns +0 -0
  252. data/static/avatar.png +0 -0
  253. data/static/code_highlighter.js +0 -188
  254. data/static/code_highlighter_ruby.js +0 -26
  255. data/static/downloading.png +0 -0
  256. data/static/icon-debug.png +0 -0
  257. data/static/icon-error.png +0 -0
  258. data/static/icon-info.png +0 -0
  259. data/static/icon-warn.png +0 -0
  260. data/static/listbox_button1.png +0 -0
  261. data/static/listbox_button2.png +0 -0
  262. data/static/man-app.png +0 -0
  263. data/static/man-builds.png +0 -0
  264. data/static/man-builds1.png +0 -0
  265. data/static/man-editor-notepad.png +0 -0
  266. data/static/man-editor-osx.png +0 -0
  267. data/static/man-ele-background.png +0 -0
  268. data/static/man-ele-border.png +0 -0
  269. data/static/man-ele-button.png +0 -0
  270. data/static/man-ele-check.png +0 -0
  271. data/static/man-ele-editbox.png +0 -0
  272. data/static/man-ele-editline.png +0 -0
  273. data/static/man-ele-image.png +0 -0
  274. data/static/man-ele-listbox.png +0 -0
  275. data/static/man-ele-progress.png +0 -0
  276. data/static/man-ele-radio.png +0 -0
  277. data/static/man-ele-shape.png +0 -0
  278. data/static/man-ele-textblock.png +0 -0
  279. data/static/man-ele-video.png +0 -0
  280. data/static/man-intro-dmg.png +0 -0
  281. data/static/man-intro-exe.png +0 -0
  282. data/static/man-look-tiger.png +0 -0
  283. data/static/man-look-ubuntu.png +0 -0
  284. data/static/man-look-vista.png +0 -0
  285. data/static/man-run-osx.png +0 -0
  286. data/static/man-run-vista.png +0 -0
  287. data/static/man-run-xp.png +0 -0
  288. data/static/man-shot1.png +0 -0
  289. data/static/manual-en.txt +0 -3531
  290. data/static/manual-ja.txt +0 -2829
  291. data/static/manual.css +0 -184
  292. data/static/menu-corner1.png +0 -0
  293. data/static/menu-corner2.png +0 -0
  294. data/static/menu-gray.png +0 -0
  295. data/static/menu-left.png +0 -0
  296. data/static/menu-right.png +0 -0
  297. data/static/menu-top.png +0 -0
  298. data/static/shoes-dmg.jpg +0 -0
  299. data/static/shoes-icon-blue.png +0 -0
  300. data/static/shoes-icon-brown.png +0 -0
  301. data/static/shoes-icon.png +0 -0
  302. data/static/shoes-manual-apps.gif +0 -0
  303. data/static/shoes-manual-apps.png +0 -0
  304. data/static/shoes_main_window.png +0 -0
  305. data/static/stripe.png +0 -0
  306. data/static/tutor-back.png +0 -0
  307. data/tasks/changelog.rb +0 -92
  308. data/tasks/gem.rb +0 -38
  309. data/tasks/rspec.rb +0 -106
  310. data/tasks/sample.rb +0 -66
  311. data/tasks/yard.rb +0 -13
@@ -1,385 +0,0 @@
1
- # Tankspank
2
- # kevin conner
3
- # connerk@gmail.com
4
- # version 3, 13 March 2008
5
- # this code is free, do what you like with it!
6
-
7
- $width, $height = 700, 500
8
- $camera_tightness = 0.1
9
-
10
- module Collisions
11
- def contains? x, y
12
- not (x < west or x > east or y < north or y > south)
13
- end
14
-
15
- def intersects? other
16
- not (other.east < west or other.west > east or
17
- other.south < north or other.north > south)
18
- end
19
- end
20
-
21
- class Building
22
- include Collisions
23
-
24
- attr_reader :west, :east, :north, :south
25
-
26
- def initialize(west, east, north, south)
27
- @west, @east, @north, @south = west, east, north, south
28
- @top, @bottom = 1.1 + rand(3) * 0.15, 1.0
29
-
30
- color = (1..3).collect { 0.2 + 0.4 * rand }
31
- color << 0.9
32
- @stroke = $app.rgb *color
33
- color[-1] = 0.3
34
- @fill = $app.rgb *color
35
- end
36
-
37
- def draw
38
- $app.stroke @stroke
39
- $app.fill @fill
40
- Opp.draw_opp_box(@west, @east, @north, @south, @top, @bottom)
41
- end
42
- end
43
-
44
- module Guidance
45
- def guidance_system x, y, dest_x, dest_y, angle
46
- vx, vy = dest_x - x, dest_y - y
47
- if vx.abs < 0.1 and vy.abs <= 0.1
48
- yield 0, 0
49
- else
50
- length = Math.sqrt(vx * vx + vy * vy)
51
- vx /= length
52
- vy /= length
53
- ax, ay = Math.cos(angle), Math.sin(angle)
54
- cos_between = vx * ax + vy * ay
55
- sin_between = vx * -ay + vy * ax
56
- yield sin_between, cos_between
57
- end
58
- end
59
- end
60
-
61
- module Life
62
- attr_reader :health
63
- def dead?
64
- @health == 0
65
- end
66
- def hurt damage
67
- @health = [@health - damage, 0].max
68
- end
69
- end
70
-
71
- class Tank
72
- include Collisions
73
- include Guidance
74
- include Life
75
- # ^ sounds like insurance
76
-
77
- @@collide_size = 15
78
- def west; @x - @@collide_size; end
79
- def east; @x + @@collide_size; end
80
- def north; @y - @@collide_size; end
81
- def south; @y + @@collide_size; end
82
-
83
- attr_reader :x, :y
84
-
85
- def initialize
86
- @x, @y = 0, -125
87
- @last_x, @last_y = @x, @y
88
- @tank_angle = 0.0
89
- @dest_x, @dest_y = 0, 0
90
- @acceleration = 0.0
91
- @speed = 0.0
92
- @moving = false
93
-
94
- @aim_angle = 0.0
95
- @target_x, @target_y = 0, 0
96
- @aimed = false
97
-
98
- @health = 100
99
- end
100
-
101
- def set_destination
102
- @dest_x, @dest_y = @target_x, @target_y
103
- @moving = true
104
- end
105
-
106
- def fire
107
- Opp.add_shell Shell.new(@x + 30 * Math.cos(@aim_angle),
108
- @y + 30 * Math.sin(@aim_angle), @aim_angle)
109
- end
110
-
111
- def update button, mouse_x, mouse_y
112
- @target_x, @target_y = mouse_x, mouse_y
113
-
114
- if @moving
115
- guidance_system @x, @y, @dest_x, @dest_y, @tank_angle do |direction, on_target|
116
- turn direction
117
- @acceleration = on_target * 0.25
118
- end
119
-
120
- distance = Math.sqrt((@dest_x - @x) ** 2 + (@dest_y - @y) ** 2)
121
- @moving = false if distance < 50
122
- else
123
- @acceleration = 0.0
124
- end
125
-
126
- guidance_system @x, @y, @target_x, @target_y, @aim_angle do |direction, on_target|
127
- aim direction
128
- @aimed = on_target > 0.98
129
- end
130
-
131
- integrity = @health / 100.0 # the more hurt you are, the slower you go
132
- @speed = [[@speed + @acceleration, 5.0 * integrity].min, -3.0 * integrity].max
133
- @speed *= 0.9 if !@moving
134
-
135
- @last_x, @last_y = @x, @y
136
- @x += @speed * Math.cos(@tank_angle)
137
- @y += @speed * Math.sin(@tank_angle)
138
- end
139
-
140
- def collide_and_stop
141
- @x, @y = @last_x, @last_y
142
- hurt @speed.abs * 3 + 5
143
- @speed = 0
144
- @moving = false
145
- end
146
-
147
- def turn direction
148
- @tank_angle += [[-0.03, direction].max, 0.03].min
149
- end
150
-
151
- def aim direction
152
- @aim_angle += [[-0.1, direction].max, 0.1].min
153
- end
154
-
155
- def draw
156
- $app.stroke $app.blue
157
- $app.fill $app.blue(0.4)
158
- Opp.draw_opp_rect @x - 20, @x + 20, @y - 15, @y + 15, 1.05, @tank_angle
159
- #Opp.draw_opp_box @x - 20, @x + 20, @y - 20, @y + 20, 1.03, 1.0
160
- Opp.draw_opp_rect @x - 10, @x + 10, @y - 7, @y + 7, 1.05, @aim_angle
161
- x, unused1, y, unused2 = Opp.project(@x, 0, @y, 0, 1.05)
162
- $app.line x, y, x + 25 * Math.cos(@aim_angle), y + 25 * Math.sin(@aim_angle)
163
-
164
- $app.stroke $app.red
165
- $app.fill $app.red(@aimed ? 0.4 : 0.1)
166
- Opp.draw_opp_oval @target_x - 10, @target_x + 10, @target_y - 10, @target_y + 10, 1.00
167
-
168
- if @moving
169
- $app.stroke $app.green
170
- $app.fill $app.green(0.2)
171
- Opp.draw_opp_oval @dest_x - 20, @dest_x + 20, @dest_y - 20, @dest_y + 20, 1.00
172
- end
173
- end
174
- end
175
-
176
- class Shell
177
- attr_reader :x, :y
178
-
179
- def initialize x, y, angle
180
- @x, @y, @angle = x, y, angle
181
- @speed = 10.0
182
- end
183
-
184
- def update
185
- @x += @speed * Math.cos(@angle)
186
- @y += @speed * Math.sin(@angle)
187
- end
188
-
189
- def draw
190
- $app.stroke $app.red
191
- $app.fill $app.red(0.1)
192
- Opp.draw_opp_box @x - 2, @x + 2, @y - 2, @y + 2, 1.05, 1.04
193
- end
194
- end
195
-
196
- class Opp
197
- def self.new_game
198
- @offset_x, @offset_y = 0, 0
199
- @buildings = [
200
- [-1000, -750, -750, -250],
201
- [-500, 250, -750, -250],
202
- [500, 1000, -750, -500],
203
- [750, 1250, -250, 0],
204
- [750, 1250, 250, 750],
205
- [250, 500, 0, 750],
206
- [-250, 0, 0, 500],
207
- [-500, 0, 750, 1000],
208
- [-1000, -500, 0, 500],
209
- [400, 600, -350, -150]
210
- ].collect { |p| Building.new *p }
211
- @shells = []
212
- @boundary = [-1250, 1500, -1250, 1250]
213
- @tank = Tank.new
214
- @center_x, @center_y = $app.width / 2, $app.height / 2
215
- end
216
-
217
- def self.tank
218
- @tank
219
- end
220
-
221
- def self.read_input
222
- @input = $app.mouse
223
- end
224
-
225
- def self.update_scene
226
- button, x, y = @input
227
- x += @offset_x - @center_x
228
- y += @offset_y - @center_y
229
-
230
- @tank.update(button, x, y) if !@tank.dead?
231
- @buildings.each do |b|
232
- @tank.collide_and_stop if b.intersects? @tank
233
- end
234
-
235
- @shells.each { |s| s.update }
236
- @buildings.each do |b|
237
- @shells.reject! do |s|
238
- b.contains?(s.x, s.y)
239
- end
240
- end
241
- #collide shells with tanks -- don't need this until there are enemy tanks
242
- #@shells.reject! do |s|
243
- # @tank.contains?(s.x, s.y)
244
- #end
245
-
246
- $app.clear do
247
- @offset_x += $camera_tightness * (@tank.x - @offset_x)
248
- @offset_y += $camera_tightness * (@tank.y - @offset_y)
249
-
250
- $app.background $app.black
251
- @center_x, @center_y = $app.width / 2, $app.height / 2
252
-
253
- $app.stroke $app.red(0.9)
254
- $app.nofill
255
- draw_opp_box *(@boundary + [1.1, 1.0, false])
256
-
257
- @tank.draw
258
- @shells.each { |s| s.draw }
259
- @buildings.each { |b| b.draw }
260
- end
261
- end
262
-
263
- def self.add_shell shell
264
- @shells << shell
265
- @shells.shift if @shells.size > 10
266
- end
267
-
268
- def self.project left, right, top, bottom, depth
269
- [left, right].collect { |x| @center_x + depth * (x - @offset_x) } +
270
- [top, bottom].collect { |y| @center_y + depth * (y - @offset_y) }
271
- end
272
-
273
- # here "front" and "back" push the rect into and out of the window.
274
- # 1.0 means your x and y units are pixels on the surface.
275
- # greater than that brings the box closer. less pushes it back. 0.0 => infinity.
276
- # the front will be filled but the rest is wireframe only.
277
- def self.draw_opp_box left, right, top, bottom, front, back, occlude = true
278
- near_left, near_right, near_top, near_bottom = project(left, right, top, bottom, front)
279
- far_left, far_right, far_top, far_bottom = project(left, right, top, bottom, back)
280
-
281
- # determine which sides of the box are visible
282
- if occlude
283
- draw_left = @center_x < near_left
284
- draw_right = near_right < @center_x
285
- draw_top = @center_y < near_top
286
- draw_bottom = near_bottom < @center_y
287
- else
288
- draw_left, draw_right, draw_top, draw_bottom = [true] * 4
289
- end
290
-
291
- # draw lines for the back edges
292
- $app.line far_left, far_top, far_right, far_top if draw_top
293
- $app.line far_left, far_bottom, far_right, far_bottom if draw_bottom
294
- $app.line far_left, far_top, far_left, far_bottom if draw_left
295
- $app.line far_right, far_top, far_right, far_bottom if draw_right
296
-
297
- # draw lines to connect the front and back
298
- $app.line near_left, near_top, far_left, far_top if draw_left or draw_top
299
- $app.line near_right, near_top, far_right, far_top if draw_right or draw_top
300
- $app.line near_left, near_bottom, far_left, far_bottom if draw_left or draw_bottom
301
- $app.line near_right, near_bottom, far_right, far_bottom if draw_right or draw_bottom
302
-
303
- # draw the front, filled
304
- $app.rect near_left, near_top, near_right - near_left, near_bottom - near_top
305
- end
306
-
307
- def self.draw_opp_rect left, right, top, bottom, depth, angle, with_x = false
308
- pl, pr, pt, pb = project(left, right, top, bottom, depth)
309
- cos = Math.cos(angle)
310
- sin = Math.sin(angle)
311
- cx, cy = (pr + pl) / 2.0, (pb + pt) / 2.0
312
- points = [[pl, pt], [pr, pt], [pr, pb], [pl, pb]].collect do |x, y|
313
- [cx + (x - cx) * cos - (y - cy) * sin,
314
- cy + (x - cx) * sin + (y - cy) * cos]
315
- end
316
-
317
- $app.line *(points[0] + points[1])
318
- $app.line *(points[1] + points[2])
319
- $app.line *(points[2] + points[3])
320
- $app.line *(points[3] + points[0])
321
- end
322
-
323
- def self.draw_opp_oval left, right, top, bottom, depth
324
- pl, pr, pt, pb = project(left, right, top, bottom, depth)
325
- $app.oval(pl, pt, pr - pl, pb - pt)
326
- end
327
-
328
- def self.draw_opp_plane x1, y1, x2, y2, front, back, stroke_color
329
- near_x1, near_x2, near_y1, near_y2 = project(x1, x2, y1, y2, front)
330
- far_x1, far_x2, far_y1, far_y2 = project(x1, x2, y1, y2, back)
331
-
332
- $app.stroke stroke_color
333
-
334
- $app.line far_x1, far_y1, far_x2, far_y2
335
- $app.line far_x1, far_y1, near_x1, near_y1
336
- $app.line far_x2, far_y2, near_x2, near_y2
337
- $app.line near_x1, near_y1, near_x2, near_y2
338
- end
339
- end
340
-
341
- Shoes.app width: $width, height: $height do
342
- $app = self
343
-
344
- Opp.new_game
345
- @playing = true
346
-
347
- keypress do |key|
348
- if @playing
349
- if key == "1" or key == "z"
350
- Opp.tank.set_destination
351
- elsif key == "2" or key == "x" or key == " "
352
- Opp.tank.fire
353
- end
354
- else
355
- if key == "n"
356
- Opp.new_game
357
- @playing = true
358
- end
359
- end
360
- end
361
-
362
- click do |button, x, y|
363
- if @playing
364
- if button == 1
365
- Opp.tank.set_destination
366
- else
367
- Opp.tank.fire
368
- end
369
- end
370
- end
371
-
372
- game_over_count = -1
373
- animate(60) do
374
- Opp.read_input if @playing
375
- Opp.update_scene
376
-
377
- @playing = false if Opp.tank.dead?
378
- if !@playing
379
- stack do
380
- banner "Game Over", stroke: white, margin: 10
381
- caption "learn to drive!", stroke: white, margin: 20
382
- end
383
- end
384
- end
385
- end
data/samples/flow.rb DELETED
@@ -1,63 +0,0 @@
1
- #require 'pry'
2
- #require 'pry-nav'
3
- #require 'shoes/swt/tooling/leak_hunter'
4
-
5
- Shoes.app width: 250, height: 500 do
6
- @r = rect 100, 100, 100, 100, fill:gradient(red, blue) #"/Users/jclark/.hacketyhack/princess/king.jpg")
7
- oval 100, 100, 100, 200, angle: 120
8
-
9
- button "change" do
10
- @r.style(fill: green)
11
- end
12
- #COLORS = [red, green, blue, yellow, orange, purple]
13
- #3.times do
14
- #flow do
15
- #COLORS.each do |color|
16
- #para "Boo Hoo Hoo Hoo", fill: color, size: 24
17
- #end
18
- #end
19
- #end
20
- end
21
- #Shoes.app do
22
- ##rect 100, 100, 100, 100, fill: blue
23
- ##line 10, 10, 20, 20
24
-
25
- #button "booo" do
26
- #@p.cursor ||= 0
27
- #@p.cursor += 100
28
- #end
29
-
30
- #keypress do |key|
31
- #if key == :right
32
- #@p.cursor ||= 0
33
- #@p.cursor += 1
34
- #elsif key == :left
35
- #@p.cursor ||= 0
36
- #@p.cursor -= 1
37
- #end
38
- #end
39
- #@p = para 'Hello ' * 20, cursor: 0, width:200
40
- #puts "#{@p.height}, #{@p.width}"
41
-
42
- #button "boo" do
43
- #alert "#{@p.height}, #{@p.width}"
44
- #end
45
- ##stack do
46
- ##rect 100, 100, 100, 100, fill: red, stroke: blue
47
- ###background lightgreen, stroke: blue
48
- ##para "Some of this text will not be seen", underline: 1, undercolor: orange, size: 16, fill: red, stroke: blue, margin: 10
49
- ##para "Nope", strikethrough: 1, strikecolor: orange, size: 16, stroke: blue, margin: 10
50
- ###para("wat", click: proc { alert "Boo" })
51
- ###flow width:100 do
52
- ###background lightgreen
53
- ###para "I am important!", size: 16
54
- ###end
55
- ##end
56
-
57
- ##keypress do |key|
58
- ##if key == :'control_alt_q'
59
- ##clear
60
- ##quit
61
- ##end
62
- ##end
63
- #end
data/samples/good-arc.rb DELETED
@@ -1,45 +0,0 @@
1
- #
2
- # a translation from a processing example
3
- # http://vormplus.be/weging/an-introduction-to-processing/
4
- #
5
- Shoes.app width: 420, height: 420, resizable: false do
6
- stage, wide, sw, basesize, step = 0, 3, 1.0, 600, 60
7
- stroke white(100)
8
- nofill
9
-
10
- animate 40 do |i|
11
- stage = rand(1...8) if i % 40 == 0
12
- if wide.abs < 0.1
13
- if stage == 6
14
- wide = -0.1
15
- else
16
- wide = 0.1
17
- end
18
- end
19
- rotation = -(Shoes::HALF_PI / wide)
20
- clear do
21
- background gray(240)
22
- 10.times do |i|
23
- strokewidth sw * i
24
- size = (basesize + step * i) / 3
25
- top = (self.height - size) / 2
26
- left = (self.width - size) / 2
27
- arc top, left,
28
- size, size,
29
- rotation * i,
30
- rotation * i + Shoes::TWO_PI - Shoes::HALF_PI
31
- end
32
- end
33
-
34
- case stage
35
- when 1; wide -= 0.1
36
- when 2; wide += 0.1
37
- when 3; basesize -= 1
38
- when 4; basesize += 2
39
- when 5; sw += 0.1
40
- when 6; sw = [sw - 0.1, 0.1].max
41
- when 7; step += 2
42
- else step -= 1
43
- end
44
- end
45
- end