purple_shoes 0.0.101
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +56 -0
- data/VERSION +1 -0
- data/bin/pshoes +23 -0
- data/bin/pshoes.bat +2 -0
- data/lib/plugins/video.rb +88 -0
- data/lib/purple_shoes.rb +51 -0
- data/lib/shoes/anim.rb +47 -0
- data/lib/shoes/app.rb +688 -0
- data/lib/shoes/basic.rb +254 -0
- data/lib/shoes/colors.rb +149 -0
- data/lib/shoes/download.rb +26 -0
- data/lib/shoes/help.rb +473 -0
- data/lib/shoes/helper_methods.rb +295 -0
- data/lib/shoes/main.rb +96 -0
- data/lib/shoes/manual.rb +6 -0
- data/lib/shoes/ruby.rb +61 -0
- data/lib/shoes/slot.rb +104 -0
- data/lib/shoes/style.rb +41 -0
- data/lib/shoes/text.rb +46 -0
- data/lib/shoes/url.rb +14 -0
- data/lib/shoes/widget.rb +23 -0
- data/samples/class-book.yaml +387 -0
- data/samples/cy.png +0 -0
- data/samples/loogink.png +0 -0
- data/samples/potato_chopping/1258_s001.gif +0 -0
- data/samples/potato_chopping/1258_s002.gif +0 -0
- data/samples/potato_chopping/1258_s003.gif +0 -0
- data/samples/potato_chopping/1258_s004.gif +0 -0
- data/samples/potato_chopping/1258_s005.gif +0 -0
- data/samples/potato_chopping/1258_s006.gif +0 -0
- data/samples/potato_chopping/1258_s007.gif +0 -0
- data/samples/potato_chopping/1258_s008.gif +0 -0
- data/samples/potato_chopping/1258_s009.gif +0 -0
- data/samples/potato_chopping/1258_s010.gif +0 -0
- data/samples/potato_chopping/1258_s011.gif +0 -0
- data/samples/potato_chopping/1258_s012.gif +0 -0
- data/samples/potato_chopping/1258_s013.gif +0 -0
- data/samples/potato_chopping/1258_s014.gif +0 -0
- data/samples/potato_chopping/1258_s015.gif +0 -0
- data/samples/potato_chopping/1258_s016.gif +0 -0
- data/samples/potato_chopping/1258_s017.gif +0 -0
- data/samples/potato_chopping/1258_s018.gif +0 -0
- data/samples/potato_chopping/1258_s019.gif +0 -0
- data/samples/potato_chopping/1258_s020.gif +0 -0
- data/samples/potato_chopping/1258_s021.gif +0 -0
- data/samples/potato_chopping/1258_s022.gif +0 -0
- data/samples/potato_chopping/1258_s023.gif +0 -0
- data/samples/potato_chopping/1258_s024.gif +0 -0
- data/samples/potato_chopping/1258_s025.gif +0 -0
- data/samples/potato_chopping/1258_s026.gif +0 -0
- data/samples/potato_chopping/1258_s027.gif +0 -0
- data/samples/potato_chopping/1258_s028.gif +0 -0
- data/samples/potato_chopping/1258_s029.gif +0 -0
- data/samples/potato_chopping/1258_s030.gif +0 -0
- data/samples/potato_chopping/1258_s031.gif +0 -0
- data/samples/potato_chopping/1258_s032.gif +0 -0
- data/samples/potato_chopping/1258_s033.gif +0 -0
- data/samples/potato_chopping/1258_s034.gif +0 -0
- data/samples/potato_chopping/1258_s035.gif +0 -0
- data/samples/potato_chopping/1258_s036.gif +0 -0
- data/samples/potato_chopping/1258_s037.gif +0 -0
- data/samples/potato_chopping/1258_s038.gif +0 -0
- data/samples/potato_chopping/1258_s039.gif +0 -0
- data/samples/potato_chopping/1258_s040.gif +0 -0
- data/samples/potato_chopping/1258_s041.gif +0 -0
- data/samples/potato_chopping/1258_s042.gif +0 -0
- data/samples/potato_chopping/1258_s043.gif +0 -0
- data/samples/potato_chopping/1258_s044.gif +0 -0
- data/samples/potato_chopping/1258_s045.gif +0 -0
- data/samples/potato_chopping/1258_s046.gif +0 -0
- data/samples/potato_chopping/1258_s047.gif +0 -0
- data/samples/potato_chopping/1258_s048.gif +0 -0
- data/samples/potato_chopping/1258_s049.gif +0 -0
- data/samples/potato_chopping/1258_s050.gif +0 -0
- data/samples/potato_chopping/1258_s051.gif +0 -0
- data/samples/potato_chopping/1258_s052.gif +0 -0
- data/samples/potato_chopping/1258_s053.gif +0 -0
- data/samples/potato_chopping/1258_s054.gif +0 -0
- data/samples/potato_chopping/1258_s055.gif +0 -0
- data/samples/potato_chopping/1258_s056.gif +0 -0
- data/samples/potato_chopping/1258_s057.gif +0 -0
- data/samples/potato_chopping/1258_s058.gif +0 -0
- data/samples/potato_chopping/1258_s059.gif +0 -0
- data/samples/sample1.rb +30 -0
- data/samples/sample10.rb +11 -0
- data/samples/sample11.rb +12 -0
- data/samples/sample12.rb +22 -0
- data/samples/sample13.rb +15 -0
- data/samples/sample14.rb +75 -0
- data/samples/sample15.rb +20 -0
- data/samples/sample16.rb +12 -0
- data/samples/sample17.rb +12 -0
- data/samples/sample18.rb +24 -0
- data/samples/sample19.rb +39 -0
- data/samples/sample2.rb +16 -0
- data/samples/sample20.rb +26 -0
- data/samples/sample21.rb +7 -0
- data/samples/sample22.rb +13 -0
- data/samples/sample23.rb +10 -0
- data/samples/sample24.rb +22 -0
- data/samples/sample25.rb +22 -0
- data/samples/sample27.rb +19 -0
- data/samples/sample28.rb +64 -0
- data/samples/sample29.rb +12 -0
- data/samples/sample3.rb +10 -0
- data/samples/sample30.rb +30 -0
- data/samples/sample31.rb +24 -0
- data/samples/sample34.rb +29 -0
- data/samples/sample35.rb +33 -0
- data/samples/sample36.rb +48 -0
- data/samples/sample37.rb +10 -0
- data/samples/sample38.rb +14 -0
- data/samples/sample4.rb +9 -0
- data/samples/sample40.rb +19 -0
- data/samples/sample42.rb +15 -0
- data/samples/sample43.rb +26 -0
- data/samples/sample44.rb +57 -0
- data/samples/sample45.rb +12 -0
- data/samples/sample46.rb +35 -0
- data/samples/sample47.rb +20 -0
- data/samples/sample48.rb +33 -0
- data/samples/sample49.rb +33 -0
- data/samples/sample5.rb +8 -0
- data/samples/sample50.rb +326 -0
- data/samples/sample58.rb +19 -0
- data/samples/sample6.rb +11 -0
- data/samples/sample7.rb +5 -0
- data/samples/sample8.rb +9 -0
- data/samples/sample9.rb +12 -0
- data/samples/sample99.rb +4 -0
- data/samples/sounds/102719__sarge4267__explosion.mp3 +0 -0
- data/samples/sounds/145622__andybrannan__train-fog-horn-long-wyomming.aiff +0 -0
- data/samples/sounds/46492__phreaksaccount__shields1.ogg +0 -0
- data/samples/sounds/61847__simon-rue__boink-v3.wav +0 -0
- data/snapshots/sample1.png +0 -0
- data/snapshots/sample10.png +0 -0
- data/snapshots/sample11.png +0 -0
- data/snapshots/sample12.png +0 -0
- data/snapshots/sample13.png +0 -0
- data/snapshots/sample14.png +0 -0
- data/snapshots/sample15.png +0 -0
- data/snapshots/sample16.png +0 -0
- data/snapshots/sample17.png +0 -0
- data/snapshots/sample18.png +0 -0
- data/snapshots/sample19.png +0 -0
- data/snapshots/sample2.png +0 -0
- data/snapshots/sample20.png +0 -0
- data/snapshots/sample21.png +0 -0
- data/snapshots/sample22.png +0 -0
- data/snapshots/sample23.png +0 -0
- data/snapshots/sample24.png +0 -0
- data/snapshots/sample25.png +0 -0
- data/snapshots/sample27.png +0 -0
- data/snapshots/sample28.png +0 -0
- data/snapshots/sample29.png +0 -0
- data/snapshots/sample3-osx.png +0 -0
- data/snapshots/sample3.png +0 -0
- data/snapshots/sample30.png +0 -0
- data/snapshots/sample31.png +0 -0
- data/snapshots/sample33.png +0 -0
- data/snapshots/sample34.png +0 -0
- data/snapshots/sample35.png +0 -0
- data/snapshots/sample36.png +0 -0
- data/snapshots/sample37.png +0 -0
- data/snapshots/sample38.png +0 -0
- data/snapshots/sample4.png +0 -0
- data/snapshots/sample40.png +0 -0
- data/snapshots/sample42.png +0 -0
- data/snapshots/sample43.png +0 -0
- data/snapshots/sample44-linux.png +0 -0
- data/snapshots/sample44.png +0 -0
- data/snapshots/sample45.png +0 -0
- data/snapshots/sample46.png +0 -0
- data/snapshots/sample47.png +0 -0
- data/snapshots/sample48.png +0 -0
- data/snapshots/sample49.png +0 -0
- data/snapshots/sample5.png +0 -0
- data/snapshots/sample50.png +0 -0
- data/snapshots/sample58.png +0 -0
- data/snapshots/sample6.png +0 -0
- data/snapshots/sample7.png +0 -0
- data/snapshots/sample8.png +0 -0
- data/snapshots/sample9.png +0 -0
- data/snapshots/sample99.png +0 -0
- data/static/code_highlighter.js +188 -0
- data/static/code_highlighter_ruby.js +26 -0
- data/static/man-editor-notepad.png +0 -0
- data/static/man-editor-osx.png +0 -0
- data/static/man-ele-background.png +0 -0
- data/static/man-ele-border.png +0 -0
- data/static/man-ele-button.png +0 -0
- data/static/man-ele-check.png +0 -0
- data/static/man-ele-editbox.png +0 -0
- data/static/man-ele-editline.png +0 -0
- data/static/man-ele-image.png +0 -0
- data/static/man-ele-listbox.png +0 -0
- data/static/man-ele-progress.png +0 -0
- data/static/man-ele-radio.png +0 -0
- data/static/man-ele-shape.png +0 -0
- data/static/man-ele-textblock.png +0 -0
- data/static/man-ele-video.png +0 -0
- data/static/man-shot1.png +0 -0
- data/static/manual-en.txt +3969 -0
- data/static/manual-ja.txt +3882 -0
- data/static/manual.css +184 -0
- data/static/purple_shoes-icon.png +0 -0
- data/static/rshoes-icon.png +0 -0
- data/static/shoes-manual-apps.png +0 -0
- data/static/sound_jars/jl1.0.1.jar +0 -0
- data/static/sound_jars/jogg-0.0.7.jar +0 -0
- data/static/sound_jars/jorbis-0.0.15.jar +0 -0
- data/static/sound_jars/mp3spi1.9.5.jar +0 -0
- data/static/sound_jars/tritonus_share.jar +0 -0
- data/static/sound_jars/vorbisspi1.0.3.jar +0 -0
- metadata +271 -0
data/samples/cy.png
ADDED
Binary file
|
data/samples/loogink.png
ADDED
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/samples/sample1.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'purple_shoes'
|
2
|
+
|
3
|
+
xspeed, yspeed = 10, 6
|
4
|
+
xdir, ydir = 1, 1
|
5
|
+
|
6
|
+
Shoes.app width: 300, height: 300 do
|
7
|
+
a = nil
|
8
|
+
button('pause'){a.pause}
|
9
|
+
button('stop'){a.stop}
|
10
|
+
img = image File.join(DIR, '../static/purple_shoes-icon.png') do
|
11
|
+
alert "You're soooo quick!"
|
12
|
+
end
|
13
|
+
|
14
|
+
x, y = 150, 150
|
15
|
+
size = [128, 128]
|
16
|
+
pause = 0
|
17
|
+
|
18
|
+
a = animate(24, false) do |n|
|
19
|
+
unless pause == n
|
20
|
+
x += xspeed * xdir
|
21
|
+
y += yspeed * ydir
|
22
|
+
|
23
|
+
xdir *= -1 if x > 300 - size[0] or x < 0
|
24
|
+
ydir *= -1 if y > 300 - size[1] or y < 0
|
25
|
+
|
26
|
+
img.move x.to_i, y.to_i
|
27
|
+
end
|
28
|
+
pause = n
|
29
|
+
end
|
30
|
+
end
|
data/samples/sample10.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'purple_shoes'
|
2
|
+
|
3
|
+
Shoes.app width: 300, height: 300 do
|
4
|
+
|
5
|
+
flow do
|
6
|
+
10.times do |i|
|
7
|
+
flow(width: 0.5, height: 30){background forestgreen.push(0.1*(i+1)); para 'green'}
|
8
|
+
flow(width: 0.5, height: 30){background orangered.push(1.0 - 0.1*i); para 'shoes'}
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
data/samples/sample11.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# Same snippet as http://shoes.heroku.com/manual/Events.html#motion{|left,top|...}
|
2
|
+
|
3
|
+
require 'purple_shoes'
|
4
|
+
|
5
|
+
Shoes.app width: 200, height: 200 do
|
6
|
+
background black
|
7
|
+
fill white
|
8
|
+
@circ = oval 0, 0, 100, 100
|
9
|
+
motion do |top, left|
|
10
|
+
@circ.move top - 50, left - 50
|
11
|
+
end
|
12
|
+
end
|
data/samples/sample12.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'purple_shoes'
|
2
|
+
|
3
|
+
Shoes.app width: 300, height: 300 do
|
4
|
+
background cadetblue
|
5
|
+
r = rect 100, 10, 100, fill: red, strokewidth: 5, curve: 10, stroke: pink do
|
6
|
+
alert 'Yay!'
|
7
|
+
end
|
8
|
+
o = oval 100, 110, 100, 100, fill: green, strokewidth: 10, stroke: white
|
9
|
+
para 'Purple Shoes!!', left: 100, top: 70
|
10
|
+
|
11
|
+
size = COLORS.keys.size
|
12
|
+
j = 0
|
13
|
+
a = animate 1, false do |i|
|
14
|
+
unless j == i
|
15
|
+
r.style fill: send(COLORS.keys[rand size]), stroke: send(COLORS.keys[rand size])
|
16
|
+
o.style fill: send(COLORS.keys[rand size]), stroke: send(COLORS.keys[rand size])
|
17
|
+
j = i
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
button('pause'){a.pause}
|
22
|
+
end
|
data/samples/sample13.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'purple_shoes'
|
2
|
+
|
3
|
+
# The same as sample60.rb on Shoes Tutorial Note
|
4
|
+
Shoes.app :width => 300, :height => 300 do
|
5
|
+
i = 45
|
6
|
+
button 'new'do
|
7
|
+
i += 5
|
8
|
+
box = rand(2) == 0 ? rect(i, i, 20) : oval(i, i, 10)
|
9
|
+
box.style :fill => send(COLORS.keys[rand(COLORS.keys.size)])
|
10
|
+
@flag = false
|
11
|
+
box.click{@flag = true; @box = box}
|
12
|
+
box.release{@flag = false}
|
13
|
+
end
|
14
|
+
motion{|left, top| @box.move(left-10, top-10) if @flag}
|
15
|
+
end
|
data/samples/sample14.rb
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
# This is from http://github.com/shoes/shoes-contrib/blob/master/animation/flowers.rb
|
2
|
+
# Edited a little bit for Purple Shoes by ashbb
|
3
|
+
#
|
4
|
+
###############################################
|
5
|
+
#
|
6
|
+
# This is from juixe "Running with Shoes - 2D Examples"
|
7
|
+
# http://juixe.com/techknow/index.php/2007/10/19/running-with-shoes-2d-examples/
|
8
|
+
#
|
9
|
+
# This is an animation of two concentric sets of circles moving in different
|
10
|
+
# directions. As the circles move they change size and color.
|
11
|
+
#
|
12
|
+
|
13
|
+
require 'purple_shoes'
|
14
|
+
|
15
|
+
degree = 0
|
16
|
+
color = 0
|
17
|
+
size = 0
|
18
|
+
|
19
|
+
Shoes.app :width => 537, :height => 500 do
|
20
|
+
background rgb(1.0, 0.5, 1.0, 1.0)
|
21
|
+
# Convert degrees to radians
|
22
|
+
def to_radians(deg)
|
23
|
+
deg * Math::PI / 180
|
24
|
+
end
|
25
|
+
|
26
|
+
red_circles, blue_circles = [], []
|
27
|
+
|
28
|
+
mx, my = (500/2).to_i, (537/2).to_i
|
29
|
+
animate(36) do
|
30
|
+
#clear do
|
31
|
+
# Manage color
|
32
|
+
nostroke
|
33
|
+
#background rgb(1.0, 0.5, 1.0, 1.0)
|
34
|
+
# Update some variables
|
35
|
+
degree += 1
|
36
|
+
size += 1
|
37
|
+
degree = 0 if(degree >= 360)
|
38
|
+
size = 0 if(size >= 100)
|
39
|
+
color = 0.0 if(color >= 1.0)
|
40
|
+
color += 0.05 if(degree % 10 == 0)
|
41
|
+
|
42
|
+
# Draw inner circle
|
43
|
+
fill red.push(color)
|
44
|
+
10.times do |i|
|
45
|
+
current_size = 100 + size
|
46
|
+
d = to_radians(i * 60 + degree)
|
47
|
+
rx = Math::cos(d) * 100
|
48
|
+
ry = Math::sin(d) * 100
|
49
|
+
center_x = -current_size/2 + rx + mx
|
50
|
+
center_y = -current_size/2 + ry + my
|
51
|
+
unless red_circles.size == 10
|
52
|
+
red_circles << oval(center_x, center_y, current_size, current_size)
|
53
|
+
else
|
54
|
+
red_circles[i].style left: center_x, top: center_y, width: current_size, height: current_size, fill: fill
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
# Draw outer circle
|
59
|
+
fill blue.push(color)
|
60
|
+
20.times do |i|
|
61
|
+
current_size = 50 + size
|
62
|
+
d = to_radians(i * 30 - degree)
|
63
|
+
rx = Math::cos(d) * 150
|
64
|
+
ry = Math::sin(d) * 150
|
65
|
+
center_x = -current_size/2 + rx + mx
|
66
|
+
center_y = -current_size/2 + ry + my
|
67
|
+
unless blue_circles.size == 20
|
68
|
+
blue_circles << oval(center_x, center_y, current_size, current_size)
|
69
|
+
else
|
70
|
+
blue_circles[i].style left: center_x, top: center_y, width: current_size, height: current_size, fill: fill
|
71
|
+
end
|
72
|
+
end
|
73
|
+
#end
|
74
|
+
end
|
75
|
+
end
|
data/samples/sample15.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'purple_shoes'
|
2
|
+
|
3
|
+
TEXT =<<EOS
|
4
|
+
Lorem ipsum dolor sit amet, consectetur adipisicing elit, \
|
5
|
+
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
|
6
|
+
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris \
|
7
|
+
nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in \
|
8
|
+
reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
|
9
|
+
Excepteur sint occaecat cupidatat non proident, sunt in \
|
10
|
+
culpa qui officia deserunt mollit anim id est laborum.
|
11
|
+
EOS
|
12
|
+
|
13
|
+
NL = "\n\n"
|
14
|
+
|
15
|
+
Shoes.app do
|
16
|
+
lines = TEXT.split("\n")
|
17
|
+
para lines[0], NL
|
18
|
+
para lines[1], NL, justify: true
|
19
|
+
para lines[2], NL, leading: 0
|
20
|
+
end
|
data/samples/sample16.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# Same snippet as http://shoes-tutorial-note.heroku.com/html/00402_No.1_para.html
|
2
|
+
|
3
|
+
require 'purple_shoes'
|
4
|
+
|
5
|
+
Shoes.app :width => 240, :height => 95 do
|
6
|
+
para 'Testing, test, test. ',
|
7
|
+
strong('Breadsticks. '),
|
8
|
+
em('Breadsticks. '),
|
9
|
+
code('Breadsticks. '),
|
10
|
+
strong(ins('EVEN BETTER.')),
|
11
|
+
sub('fine!')
|
12
|
+
end
|
data/samples/sample17.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# Add new method bg and fg to sample17
|
2
|
+
|
3
|
+
require 'purple_shoes'
|
4
|
+
|
5
|
+
Shoes.app :width => 240, :height => 95 do
|
6
|
+
para 'Testing, test, test. ',
|
7
|
+
strong('Breadsticks. '),
|
8
|
+
em('Breadsticks. '),
|
9
|
+
code('Breadsticks. '),
|
10
|
+
bg(fg(strong(ins('EVEN BETTER.')), white), rgb(255, 0, 192)),
|
11
|
+
sub('fine!')
|
12
|
+
end
|
data/samples/sample18.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'purple_shoes'
|
2
|
+
|
3
|
+
Shoes.app width: 700, height: 600 do
|
4
|
+
title "Shoes is a ", link("tiny"){alert "Cool!"}, " graphics toolkit. "
|
5
|
+
|
6
|
+
flow width: 0.4 do
|
7
|
+
image File.join(DIR, '../static/purple_shoes-icon.png') do
|
8
|
+
alert "You're soooo quick!"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
flow width: 0.6 do
|
13
|
+
tagline "It's simple and straightforward. ",
|
14
|
+
link("Shoes "){alert "Yay!"},
|
15
|
+
"was born to be easy! ",
|
16
|
+
link("Shoes "){alert "Yay!"},
|
17
|
+
"was born to be easy! ",
|
18
|
+
link("Shoes "){alert "Yay!"},
|
19
|
+
"was born to be easy! ",
|
20
|
+
"Really, it was made for absolute beginners. "
|
21
|
+
end
|
22
|
+
|
23
|
+
subtitle link(strong em("There's ", fg(bg("really ", "really ", yellow), red), "nothing to it. ")){alert "Have fun!"}
|
24
|
+
end
|
data/samples/sample19.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# almost the same code as sample58 on (Red) Shoes Tutorial Note:
|
2
|
+
# http://shoes-tutorial-note.heroku.com/html/00704_Assignment_4_Pong_in_Shoes.html
|
3
|
+
require 'purple_shoes'
|
4
|
+
|
5
|
+
Shoes.app width: 400, height: 400 do
|
6
|
+
vx, vy = 3, 4
|
7
|
+
|
8
|
+
nostroke
|
9
|
+
@ball = oval 0, 0, 20, 20, :fill => forestgreen
|
10
|
+
@comp = rect 0, 0, 75, 4, :curve => 3
|
11
|
+
@you = rect 0, 396, 75, 4, :curve => 3
|
12
|
+
|
13
|
+
@anim = animate 32 do
|
14
|
+
nx, ny = @ball.left + vx.to_i, @ball.top + vy.to_i
|
15
|
+
|
16
|
+
if @ball.top + 20 < 0 or @ball.top > 400
|
17
|
+
title 'GAME OVER', left: 70, top: 140
|
18
|
+
para @ball.top < 0 ? " You win!" : "Computer wins", left: 140, top: 200
|
19
|
+
@anim.stop
|
20
|
+
end
|
21
|
+
|
22
|
+
vx = -vx if nx + 20 > 400 or nx < 0
|
23
|
+
|
24
|
+
if ny + 20 > 400 and nx + 20 > @you.left and nx < @you.left + 75
|
25
|
+
vy = -vy * 1.2
|
26
|
+
vx = (nx - @you.left - (75 / 2)) * 0.25
|
27
|
+
end
|
28
|
+
|
29
|
+
if ny < 0 and nx + 20 > @comp.left and nx < @comp.left + 75
|
30
|
+
vy = -vy * 1.2
|
31
|
+
vx = (nx - @comp.left - (75 / 2)) * 0.25
|
32
|
+
end
|
33
|
+
|
34
|
+
@ball.move nx, ny
|
35
|
+
@you.left = mouse[1] - (75 / 2)
|
36
|
+
@comp.left += 10 if @comp.left + 75 < @ball.left
|
37
|
+
@comp.left -= 10 if @ball.left + 20 < @comp.left
|
38
|
+
end
|
39
|
+
end
|
data/samples/sample2.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'purple_shoes'
|
2
|
+
|
3
|
+
Shoes.app title: 'Purple Shoes New Logo Icon!', width: 310, height: 420 do
|
4
|
+
stack do
|
5
|
+
path = File.join(DIR, '../static/purple_shoes-icon.png')
|
6
|
+
image path
|
7
|
+
flow do
|
8
|
+
image path
|
9
|
+
image path
|
10
|
+
end
|
11
|
+
stack do
|
12
|
+
image path
|
13
|
+
para ' ' * 20, 'Powered by JRuby and SWT!'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|