smalruby-editor 0.0.12-x86-mingw32 → 0.1.0-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of smalruby-editor might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.rubocop.yml +5 -0
- data/.travis.yml +2 -0
- data/LEGAL +32 -0
- data/Rakefile +1 -1
- data/app/assets/demos/default.xml +126 -0
- data/app/assets/demos/rgb_led_anode.xml +83 -0
- data/app/assets/images/favicon.ico +0 -0
- data/app/assets/javascripts/application.js +18 -1
- data/app/assets/javascripts/block_mode.js.coffee.erb +10 -0
- data/app/assets/javascripts/blocks/blockly.js.coffee.erb +34 -0
- data/app/assets/javascripts/blocks/character.js.coffee.erb +76 -0
- data/app/assets/javascripts/blocks/control.js.coffee.erb +180 -0
- data/app/assets/javascripts/blocks/data.js.coffee.erb +6 -0
- data/app/assets/javascripts/blocks/etc.js.coffee.erb +6 -0
- data/app/assets/javascripts/blocks/events.js.coffee.erb +82 -0
- data/app/assets/javascripts/blocks/hardware.js.coffee.erb +313 -0
- data/app/assets/javascripts/blocks/looks.js.coffee.erb +163 -0
- data/app/assets/javascripts/blocks/motion.js.coffee.erb +297 -0
- data/app/assets/javascripts/blocks/operators.js.coffee.erb +279 -0
- data/app/assets/javascripts/blocks/pen.js.coffee.erb +6 -0
- data/app/assets/javascripts/blocks/ruby.js.coffee.erb +74 -0
- data/app/assets/javascripts/blocks/sensing.js.coffee.erb +241 -0
- data/app/assets/javascripts/blocks/sound.js.coffee.erb +75 -0
- data/{public/favicon.ico → app/assets/javascripts/collections/.keep} +0 -0
- data/app/assets/javascripts/collections/character_set.js.coffee +12 -0
- data/app/assets/javascripts/generators/ruby.js.coffee.erb +188 -0
- data/app/assets/javascripts/models/.keep +0 -0
- data/app/assets/javascripts/models/character.js.coffee +66 -0
- data/app/assets/javascripts/models/scene.js.coffee +5 -0
- data/app/assets/javascripts/models/source_code.js.coffee +64 -0
- data/app/assets/javascripts/routers/.keep +0 -0
- data/app/assets/javascripts/ruby_mode.js.coffee.erb +12 -0
- data/app/assets/javascripts/smalruby.js.coffee +97 -0
- data/app/assets/javascripts/views/.keep +0 -0
- data/app/assets/javascripts/views/character_modal_view.js.coffee +148 -0
- data/app/assets/javascripts/views/character_selector_view.js.coffee +109 -0
- data/app/assets/javascripts/views/main_menu_view.js.coffee +264 -0
- data/app/assets/stylesheets/editor.css.scss +318 -2
- data/app/assets/stylesheets/toolbox.css.scss.erb +62 -0
- data/app/assets/templates/.keep +0 -0
- data/app/controllers/application_controller.rb +19 -0
- data/app/controllers/editor_controller.rb +4 -0
- data/app/controllers/source_codes_controller.rb +8 -2
- data/app/helpers/application_helper.rb +1 -0
- data/app/helpers/editor_helper.rb +46 -0
- data/app/models/source_code.rb +49 -6
- data/app/views/editor/_block_tab.html.haml +53 -0
- data/app/views/editor/_character_modal.html.haml +53 -0
- data/app/views/editor/_toolbox.html.haml +384 -0
- data/app/views/editor/demo.html.erb +16 -0
- data/app/views/editor/index.html.haml +60 -0
- data/app/views/layouts/application.html.erb +7 -0
- data/config/application.rb +1 -0
- data/config/initializers/teaspoon.rb +79 -0
- data/config/routes.rb +4 -0
- data/lib/smalruby_editor/version.rb +1 -1
- data/lib/tasks/gem.rake +7 -4
- data/lib/tasks/release.rake +43 -0
- data/public/apple-touch-icon.png +0 -0
- data/public/blockly/media/1x1.gif +0 -0
- data/public/blockly/media/click.mp3 +0 -0
- data/public/blockly/media/click.ogg +0 -0
- data/public/blockly/media/click.wav +0 -0
- data/public/blockly/media/delete.mp3 +0 -0
- data/public/blockly/media/delete.ogg +0 -0
- data/public/blockly/media/delete.wav +0 -0
- data/public/blockly/media/handclosed.cur +0 -0
- data/public/blockly/media/handopen.cur +0 -0
- data/public/blockly/media/quote0.png +0 -0
- data/public/blockly/media/quote1.png +0 -0
- data/public/blockly/media/trashbody.png +0 -0
- data/public/blockly/media/trashlid.png +0 -0
- data/public/blockly/media/tree.png +0 -0
- data/public/browserconfig.xml +1 -0
- data/public/large.png +0 -0
- data/public/smalruby/assets/ball1.png +0 -0
- data/public/smalruby/assets/ball2.png +0 -0
- data/public/smalruby/assets/ball3.png +0 -0
- data/public/smalruby/assets/ball4.png +0 -0
- data/public/smalruby/assets/ball5.png +0 -0
- data/public/smalruby/assets/ball6.png +0 -0
- data/public/smalruby/assets/car1.png +0 -0
- data/public/smalruby/assets/car2.png +0 -0
- data/public/smalruby/assets/car3.png +0 -0
- data/public/smalruby/assets/car4.png +0 -0
- data/public/smalruby/assets/cat1.png +0 -0
- data/public/smalruby/assets/cat2.png +0 -0
- data/public/smalruby/assets/cat3.png +0 -0
- data/public/smalruby/assets/frog1.png +0 -0
- data/public/smalruby/assets/piano_do.wav +0 -0
- data/public/smalruby/assets/piano_do_2.wav +0 -0
- data/public/smalruby/assets/piano_fa.wav +0 -0
- data/public/smalruby/assets/piano_mi.wav +0 -0
- data/public/smalruby/assets/piano_ra.wav +0 -0
- data/public/smalruby/assets/piano_re.wav +0 -0
- data/public/smalruby/assets/piano_si.wav +0 -0
- data/public/smalruby/assets/piano_so.wav +0 -0
- data/public/square.png +0 -0
- data/public/tiny.png +0 -0
- data/public/wide.png +0 -0
- data/smalruby-editor.gemspec +4 -0
- data/spec/acceptance/block_mode/blocks/character/new.feature +136 -0
- data/spec/acceptance/block_mode/blocks/control/await.feature +20 -0
- data/spec/acceptance/block_mode/blocks/control/await_until.feature +39 -0
- data/spec/acceptance/block_mode/blocks/control/break.feature +20 -0
- data/spec/acceptance/block_mode/blocks/control/if.feature +68 -0
- data/spec/acceptance/block_mode/blocks/control/if_else.feature +78 -0
- data/spec/acceptance/block_mode/blocks/control/loop.feature +45 -0
- data/spec/acceptance/block_mode/blocks/control/next.feature +20 -0
- data/spec/acceptance/block_mode/blocks/control/redo.feature +20 -0
- data/spec/acceptance/block_mode/blocks/control/sleep.feature +41 -0
- data/spec/acceptance/block_mode/blocks/control/times.feature +72 -0
- data/spec/acceptance/block_mode/blocks/control/until.feature +68 -0
- data/spec/acceptance/block_mode/blocks/events/on_click.feature +75 -0
- data/spec/acceptance/block_mode/blocks/events/on_hit.feature +83 -0
- data/spec/acceptance/block_mode/blocks/events/on_key_push_or_down.feature +171 -0
- data/spec/acceptance/block_mode/blocks/events/on_start.feature +75 -0
- data/spec/acceptance/block_mode/blocks/hardware/init_hardware.feature +44 -0
- data/spec/acceptance/block_mode/blocks/hardware/led_off.feature +75 -0
- data/spec/acceptance/block_mode/blocks/hardware/led_on.feature +75 -0
- data/spec/acceptance/block_mode/blocks/hardware/on_sensor_change.feature +81 -0
- data/spec/acceptance/block_mode/blocks/hardware/rgb_led_off.feature +81 -0
- data/spec/acceptance/block_mode/blocks/hardware/rgb_led_on.feature +87 -0
- data/spec/acceptance/block_mode/blocks/hardware/sensor_value.feature +100 -0
- data/spec/acceptance/block_mode/blocks/looks/hide.feature +69 -0
- data/spec/acceptance/block_mode/blocks/looks/say.feature +106 -0
- data/spec/acceptance/block_mode/blocks/looks/show.feature +69 -0
- data/spec/acceptance/block_mode/blocks/looks/vanish.feature +69 -0
- data/spec/acceptance/block_mode/blocks/motion/change_x_by.feature +81 -0
- data/spec/acceptance/block_mode/blocks/motion/change_y_by.feature +81 -0
- data/spec/acceptance/block_mode/blocks/motion/move.feature +81 -0
- data/spec/acceptance/block_mode/blocks/motion/reach_wall.feature +98 -0
- data/spec/acceptance/block_mode/blocks/motion/rotate_left.feature +81 -0
- data/spec/acceptance/block_mode/blocks/motion/rotate_right.feature +81 -0
- data/spec/acceptance/block_mode/blocks/motion/self_angle.feature +92 -0
- data/spec/acceptance/block_mode/blocks/motion/self_x.feature +92 -0
- data/spec/acceptance/block_mode/blocks/motion/self_y.feature +92 -0
- data/spec/acceptance/block_mode/blocks/motion/set_angle.feature +81 -0
- data/spec/acceptance/block_mode/blocks/motion/set_x.feature +81 -0
- data/spec/acceptance/block_mode/blocks/motion/set_x_y.feature +95 -0
- data/spec/acceptance/block_mode/blocks/motion/set_y.feature +81 -0
- data/spec/acceptance/block_mode/blocks/motion/turn.feature +69 -0
- data/spec/acceptance/block_mode/blocks/motion/turn_if_reach_wall.feature +69 -0
- data/spec/acceptance/block_mode/blocks/sensing/character_property.feature +114 -0
- data/spec/acceptance/block_mode/blocks/sensing/hit.feature +110 -0
- data/spec/acceptance/block_mode/blocks/sensing/input_key_push_or_down.feature +91 -0
- data/spec/acceptance/block_mode/blocks/sensing/input_mouse_pos_x.feature +39 -0
- data/spec/acceptance/block_mode/blocks/sensing/input_mouse_pos_y.feature +39 -0
- data/spec/acceptance/block_mode/blocks/sensing/input_mouse_push_or_down.feature +91 -0
- data/spec/acceptance/block_mode/blocks/sensing/time_now.feature +43 -0
- data/spec/acceptance/block_mode/blocks/sound/play.feature +81 -0
- data/spec/acceptance/block_mode/demo.feature +49 -0
- data/spec/acceptance/{text_editor → ruby_mode}/base.feature +11 -2
- data/spec/acceptance/{standalone → ruby_mode}/check.feature +8 -9
- data/spec/acceptance/ruby_mode/download.feature +33 -0
- data/spec/acceptance/{text_editor → ruby_mode}/load.feature +13 -13
- data/spec/acceptance/standalone/run.feature +17 -0
- data/spec/acceptance/standalone/save.feature +6 -6
- data/spec/helpers/editor_helper_spec.rb +110 -10
- data/spec/javascripts/collections/character_set_spec.coffee +41 -0
- data/spec/javascripts/models/character_spec.coffee +146 -0
- data/spec/javascripts/models/scene_spec.coffee +15 -0
- data/spec/javascripts/spec_helper.js +29 -0
- data/spec/spec_helper.rb +3 -8
- data/spec/steps/block_mode_steps.rb +37 -0
- data/spec/steps/global_variable.rb +30 -6
- data/spec/steps/text_editor_steps.rb +20 -2
- data/spec/teaspoon_env.rb +46 -0
- data/vendor/assets/javascripts/blockly/blockly_compressed.js +992 -0
- data/vendor/assets/javascripts/blockly/blocks_compressed.js +129 -0
- data/vendor/assets/javascripts/blockly/msg/js/ja.js +377 -0
- data/vendor/assets/javascripts/jquery.blockUI.js +619 -0
- metadata +290 -23
- data/app/assets/javascripts/editor.js.coffee.erb +0 -137
- data/app/views/editor/index.html.erb +0 -22
- data/spec/acceptance/text_editor/check.feature +0 -29
- data/spec/acceptance/text_editor/save.feature +0 -34
- data/spec/support/assets.rb +0 -18
@@ -0,0 +1,163 @@
|
|
1
|
+
# 「見た目」ジャンル
|
2
|
+
|
3
|
+
<%
|
4
|
+
category = 'looks'
|
5
|
+
color = 264
|
6
|
+
%>
|
7
|
+
|
8
|
+
# [ ]と( )秒言う
|
9
|
+
# [ ]と言う
|
10
|
+
# [ ]と( )秒考える
|
11
|
+
# [ ]と考える
|
12
|
+
<%
|
13
|
+
[
|
14
|
+
['say', '言う'],
|
15
|
+
['think', '考える'],
|
16
|
+
].each do |method, label_suffix|
|
17
|
+
%>
|
18
|
+
|
19
|
+
<% n = "#{category}_#{method}_second" %>
|
20
|
+
Blockly.Blocks['<%= n %>'] =
|
21
|
+
init: ()->
|
22
|
+
@setHelpUrl('')
|
23
|
+
@setColour(<%= color %>)
|
24
|
+
@interpolateMsg('%1と%2秒<%= label_suffix %>',
|
25
|
+
['TEXT', null, Blockly.ALIGN_RIGHT],
|
26
|
+
['SEC', ['Number'], Blockly.ALIGN_RIGHT],
|
27
|
+
Blockly.ALIGN_RIGHT)
|
28
|
+
@setInputsInline(true)
|
29
|
+
@setPreviousStatement(true)
|
30
|
+
@setNextStatement(true)
|
31
|
+
@setTooltip('')
|
32
|
+
|
33
|
+
Blockly.Ruby['<%= n %>'] = (block) ->
|
34
|
+
sec = Blockly.Ruby.valueToCode(@, 'SEC', Blockly.Ruby.ORDER_NONE) || '0'
|
35
|
+
text = Blockly.Ruby.valueToCode(@, 'TEXT', Blockly.Ruby.ORDER_NONE) || Blockly.Ruby.quote_('')
|
36
|
+
Blockly.Ruby.characterMethodCall_('<%= method %>', "message: #{text}, second: #{sec}")
|
37
|
+
|
38
|
+
<% n = "#{category}_#{method}" %>
|
39
|
+
Blockly.Blocks['<%= n %>'] =
|
40
|
+
init: ()->
|
41
|
+
@setHelpUrl('')
|
42
|
+
@setColour(<%= color %>)
|
43
|
+
@interpolateMsg('%1と<%= label_suffix %>',
|
44
|
+
['TEXT', null, Blockly.ALIGN_RIGHT],
|
45
|
+
Blockly.ALIGN_RIGHT)
|
46
|
+
@setInputsInline(true)
|
47
|
+
@setPreviousStatement(true)
|
48
|
+
@setNextStatement(true)
|
49
|
+
@setTooltip('')
|
50
|
+
|
51
|
+
Blockly.Ruby['<%= n %>'] = (block) ->
|
52
|
+
text = Blockly.Ruby.valueToCode(@, 'TEXT', Blockly.Ruby.ORDER_NONE) || Blockly.Ruby.quote_('')
|
53
|
+
Blockly.Ruby.characterMethodCall_('<%= method %>', "message: #{text}")
|
54
|
+
<% end %>
|
55
|
+
|
56
|
+
# 表示する
|
57
|
+
# 隠す
|
58
|
+
<%
|
59
|
+
[
|
60
|
+
['show', '表示する', 'true'],
|
61
|
+
['hide', '隠す', 'false'],
|
62
|
+
].each do |suffix, label, val|
|
63
|
+
n = "#{category}_#{suffix}"
|
64
|
+
%>
|
65
|
+
|
66
|
+
Blockly.Blocks['<%= n %>'] =
|
67
|
+
init: ()->
|
68
|
+
@setHelpUrl('')
|
69
|
+
@setColour(<%= color %>)
|
70
|
+
@appendDummyInput().appendField('<%= label %>')
|
71
|
+
@setPreviousStatement(true)
|
72
|
+
@setNextStatement(true)
|
73
|
+
@setTooltip('')
|
74
|
+
|
75
|
+
Blockly.Ruby['<%= n %>'] = (block) ->
|
76
|
+
Blockly.Ruby.characterSetVariable_('visible', '<%= val %>')
|
77
|
+
<% end %>
|
78
|
+
|
79
|
+
# 消滅する
|
80
|
+
<% n = "#{category}_vanish" %>
|
81
|
+
Blockly.Blocks['<%= n %>'] =
|
82
|
+
init: ()->
|
83
|
+
@setHelpUrl('')
|
84
|
+
@setColour(<%= color %>)
|
85
|
+
@appendDummyInput().appendField('消滅する')
|
86
|
+
@setPreviousStatement(true)
|
87
|
+
@setNextStatement(true)
|
88
|
+
@setTooltip('')
|
89
|
+
|
90
|
+
Blockly.Ruby['<%= n %>'] = (block) ->
|
91
|
+
Blockly.Ruby.characterMethodCall_('vanish')
|
92
|
+
|
93
|
+
# 大きさを( )%ずつ変える
|
94
|
+
# 大きさを( )%にする
|
95
|
+
<%
|
96
|
+
[
|
97
|
+
['change_scale_by', 'ずつ変える', '+='],
|
98
|
+
['set_scale', 'にする', '='],
|
99
|
+
].each do |suffix, label_suffix, operator|
|
100
|
+
n = "#{category}_#{suffix}"
|
101
|
+
%>
|
102
|
+
|
103
|
+
Blockly.Blocks['<%= n %>'] =
|
104
|
+
init: ()->
|
105
|
+
@setHelpUrl('')
|
106
|
+
@setColour(<%= color %>)
|
107
|
+
@interpolateMsg('大きさを%1%<%= label_suffix %>',
|
108
|
+
['SCALE', ['Number'], Blockly.ALIGN_RIGHT],
|
109
|
+
Blockly.ALIGN_RIGHT)
|
110
|
+
@setInputsInline(true)
|
111
|
+
@setPreviousStatement(true)
|
112
|
+
@setNextStatement(true)
|
113
|
+
@setTooltip('')
|
114
|
+
|
115
|
+
Blockly.Ruby['<%= n %>'] = (block) ->
|
116
|
+
scale = Blockly.Ruby.valueToCode(@, 'SCALE', Blockly.Ruby.ORDER_NONE) || '0'
|
117
|
+
scale = parseInt(scale) / 100
|
118
|
+
"self.scale <%= operator %> #{scale}\n"
|
119
|
+
<% end %>
|
120
|
+
|
121
|
+
# 変数:大きさ
|
122
|
+
<% n = "#{category}_self_scale" %>
|
123
|
+
Blockly.Blocks['<%= n %>'] =
|
124
|
+
init: ()->
|
125
|
+
@setHelpUrl('')
|
126
|
+
@setColour(<%= color %>)
|
127
|
+
@appendDummyInput().
|
128
|
+
appendField('大きさ')
|
129
|
+
@setOutput(true, 'Number')
|
130
|
+
@setTooltip('')
|
131
|
+
|
132
|
+
Blockly.Ruby['<%= n %>'] = (block) ->
|
133
|
+
['scale', Blockly.Ruby.ORDER_ATOMIC]
|
134
|
+
|
135
|
+
# [▼プリセット画像]
|
136
|
+
<% n = "#{category}_preset_images" %>
|
137
|
+
Blockly.Blocks['<%= n %>'] =
|
138
|
+
init: ()->
|
139
|
+
images = [
|
140
|
+
['車1', 'car1.png'],
|
141
|
+
['車2', 'car2.png'],
|
142
|
+
['車3', 'car3.png'],
|
143
|
+
['車4', 'car4.png'],
|
144
|
+
['ボール1', 'ball1.png'],
|
145
|
+
['ボール2', 'ball2.png'],
|
146
|
+
['ボール3', 'ball3.png'],
|
147
|
+
['ボール4', 'ball4.png'],
|
148
|
+
['ボール5', 'ball5.png'],
|
149
|
+
['ボール6', 'ball6.png'],
|
150
|
+
['猫1', 'cat1.png'],
|
151
|
+
['猫2', 'cat2.png'],
|
152
|
+
['猫3', 'cat3.png'],
|
153
|
+
['かえる1', 'frog1.png'],
|
154
|
+
]
|
155
|
+
@setHelpUrl('')
|
156
|
+
@setColour(<%= color %>)
|
157
|
+
@appendDummyInput().appendField(new Blockly.FieldDropdown(images), 'NAME')
|
158
|
+
@setOutput(true, 'String')
|
159
|
+
@setTooltip('')
|
160
|
+
|
161
|
+
Blockly.Ruby['<%= n %>'] = (block) ->
|
162
|
+
code = Blockly.Ruby.quote_(@getFieldValue('NAME'))
|
163
|
+
[code, Blockly.Ruby.ORDER_ATOMIC]
|
@@ -0,0 +1,297 @@
|
|
1
|
+
# 「動き」ジャンル
|
2
|
+
|
3
|
+
<%
|
4
|
+
category = 'motion'
|
5
|
+
color = 225
|
6
|
+
%>
|
7
|
+
|
8
|
+
# ( )歩動かす
|
9
|
+
<% n = "#{category}_move" %>
|
10
|
+
Blockly.Blocks['<%= n %>'] =
|
11
|
+
init: ()->
|
12
|
+
@setHelpUrl('')
|
13
|
+
@setColour(<%= color %>)
|
14
|
+
@interpolateMsg('%1歩動かす',
|
15
|
+
['STEP', ['Number'], Blockly.ALIGN_RIGHT],
|
16
|
+
Blockly.ALIGN_RIGHT)
|
17
|
+
@setInputsInline(true)
|
18
|
+
@setPreviousStatement(true)
|
19
|
+
@setNextStatement(true)
|
20
|
+
@setTooltip('')
|
21
|
+
|
22
|
+
Blockly.Ruby['<%= n %>'] = (block) ->
|
23
|
+
arg = Blockly.Ruby.valueToCode(@, 'STEP', Blockly.Ruby.ORDER_NONE) || '0'
|
24
|
+
Blockly.Ruby.characterMethodCall_('move', "#{arg}")
|
25
|
+
|
26
|
+
# 時計回りに( )度回す
|
27
|
+
# 半時計回りに( )度回す
|
28
|
+
<%
|
29
|
+
[
|
30
|
+
['right', '', ''],
|
31
|
+
['left', '半', '-'],
|
32
|
+
].each do |suffix, label_prefix, sign|
|
33
|
+
n = "#{category}_rotate_#{suffix}"
|
34
|
+
%>
|
35
|
+
|
36
|
+
Blockly.Blocks['<%= n %>'] =
|
37
|
+
init: ()->
|
38
|
+
@setHelpUrl('')
|
39
|
+
@setColour(<%= color %>)
|
40
|
+
@interpolateMsg('<%= label_prefix %>時計回りに%1度回す',
|
41
|
+
['ANGLE', ['Number'], Blockly.ALIGN_RIGHT],
|
42
|
+
Blockly.ALIGN_RIGHT)
|
43
|
+
@setInputsInline(true)
|
44
|
+
@setPreviousStatement(true)
|
45
|
+
@setNextStatement(true)
|
46
|
+
@setTooltip('')
|
47
|
+
|
48
|
+
Blockly.Ruby['<%= n %>'] = (block) ->
|
49
|
+
arg = Blockly.Ruby.valueToCode(@, 'ANGLE', Blockly.Ruby.ORDER_NONE) || '0'
|
50
|
+
Blockly.Ruby.characterMethodCall_('rotate', "<%= sign %>#{arg}")
|
51
|
+
<% end %>
|
52
|
+
|
53
|
+
# ( )度に向ける
|
54
|
+
<% n = "#{category}_set_angle" %>
|
55
|
+
Blockly.Blocks['<%= n %>'] =
|
56
|
+
init: ()->
|
57
|
+
@setHelpUrl('')
|
58
|
+
@setColour(<%= color %>)
|
59
|
+
@interpolateMsg('%1度に向ける',
|
60
|
+
['ANGLE', ['Number'], Blockly.ALIGN_RIGHT],
|
61
|
+
Blockly.ALIGN_RIGHT)
|
62
|
+
@setInputsInline(true)
|
63
|
+
@setPreviousStatement(true)
|
64
|
+
@setNextStatement(true)
|
65
|
+
@setTooltip('')
|
66
|
+
|
67
|
+
Blockly.Ruby['<%= n %>'] = (block) ->
|
68
|
+
angle = Blockly.Ruby.valueToCode(@, 'ANGLE', Blockly.Ruby.ORDER_NONE) || '0'
|
69
|
+
Blockly.Ruby.characterSetVariable_('angle', angle)
|
70
|
+
|
71
|
+
# マウスポインターへ向ける
|
72
|
+
<% n = "#{category}_point_towards_mouse" %>
|
73
|
+
Blockly.Blocks['<%= n %>'] =
|
74
|
+
init: ()->
|
75
|
+
@setHelpUrl('')
|
76
|
+
@setColour(<%= color %>)
|
77
|
+
@appendDummyInput()
|
78
|
+
.appendField('マウスポインターへ向ける')
|
79
|
+
@setPreviousStatement(true)
|
80
|
+
@setNextStatement(true)
|
81
|
+
@setTooltip('')
|
82
|
+
|
83
|
+
Blockly.Ruby['<%= n %>'] = (block) ->
|
84
|
+
"#{Blockly.Ruby.rn()}point_towards(:mouse)\n"
|
85
|
+
|
86
|
+
# [▼]へ向ける
|
87
|
+
<% n = "#{category}_point_towards_character" %>
|
88
|
+
Blockly.Blocks['<%= n %>'] =
|
89
|
+
init: ()->
|
90
|
+
@setHelpUrl('')
|
91
|
+
@setColour(<%= color %>)
|
92
|
+
@appendDummyInput()
|
93
|
+
.appendField(new Blockly.FieldVariable('char1'), 'VAR')
|
94
|
+
.appendField('へ向ける')
|
95
|
+
@setPreviousStatement(true)
|
96
|
+
@setNextStatement(true)
|
97
|
+
@setTooltip('')
|
98
|
+
|
99
|
+
Blockly.Ruby['<%= n %>'] = (block) ->
|
100
|
+
char = Blockly.Ruby.variableDB_.getName(block.getFieldValue('VAR'), Blockly.Variables.NAME_TYPE)
|
101
|
+
Blockly.Ruby.characterMethodCall_('point_towards', char)
|
102
|
+
|
103
|
+
# x座標を( )、y座標を( )にする
|
104
|
+
<% n = "#{category}_set_x_y" %>
|
105
|
+
Blockly.Blocks['<%= n %>'] =
|
106
|
+
init: ()->
|
107
|
+
@setHelpUrl('')
|
108
|
+
@setColour(<%= color %>)
|
109
|
+
@appendDummyInput().appendField('X座標を')
|
110
|
+
@appendValueInput('X').setCheck('Number')
|
111
|
+
@appendDummyInput().appendField('、Y座標を')
|
112
|
+
@appendValueInput('Y').setCheck('Number')
|
113
|
+
@appendDummyInput().appendField('にする')
|
114
|
+
@setInputsInline(true)
|
115
|
+
@setPreviousStatement(true)
|
116
|
+
@setNextStatement(true)
|
117
|
+
@setTooltip('')
|
118
|
+
|
119
|
+
Blockly.Ruby['<%= n %>'] = (block) ->
|
120
|
+
x = Blockly.Ruby.valueToCode(@, 'X', Blockly.Ruby.ORDER_NONE) || '0'
|
121
|
+
y = Blockly.Ruby.valueToCode(@, 'Y', Blockly.Ruby.ORDER_NONE) || '0'
|
122
|
+
Blockly.Ruby.characterSetVariable_('x', x) +
|
123
|
+
Blockly.Ruby.characterSetVariable_('y', y)
|
124
|
+
|
125
|
+
# マウスポインターへ行く
|
126
|
+
<% n = "#{category}_go_to_mouse" %>
|
127
|
+
Blockly.Blocks['<%= n %>'] =
|
128
|
+
init: ()->
|
129
|
+
@setHelpUrl('')
|
130
|
+
@setColour(<%= color %>)
|
131
|
+
@appendDummyInput()
|
132
|
+
.appendField('マウスポインターへ行く')
|
133
|
+
@setPreviousStatement(true)
|
134
|
+
@setNextStatement(true)
|
135
|
+
@setTooltip('')
|
136
|
+
|
137
|
+
Blockly.Ruby['<%= n %>'] = (block) ->
|
138
|
+
"#{Blockly.Ruby.rn()}go_to(:mouse)\n"
|
139
|
+
|
140
|
+
# [▼]へ行く
|
141
|
+
# <% n = "#{category}_go_to_character" %>
|
142
|
+
Blockly.Blocks['<%= n %>'] =
|
143
|
+
init: ()->
|
144
|
+
@setHelpUrl('')
|
145
|
+
@setColour(<%= color %>)
|
146
|
+
@appendDummyInput()
|
147
|
+
.appendField(new Blockly.FieldVariable('char1'), 'VAR')
|
148
|
+
.appendField('へ行く')
|
149
|
+
@setPreviousStatement(true)
|
150
|
+
@setNextStatement(true)
|
151
|
+
@setTooltip('')
|
152
|
+
|
153
|
+
Blockly.Ruby['<%= n %>'] = (block) ->
|
154
|
+
var0 = Blockly.Ruby.variableDB_.getName(block.getFieldValue('VAR'), Blockly.Variables.NAME_TYPE)
|
155
|
+
"#{Blockly.Ruby.rn()}go_to(#{var0})\n"
|
156
|
+
|
157
|
+
# ( )秒でx座標を( )、y座標を( )に変える
|
158
|
+
<% n = "#{category}_glide_to_x_y" %>
|
159
|
+
Blockly.Blocks['<%= n %>'] =
|
160
|
+
init: ()->
|
161
|
+
@setHelpUrl('')
|
162
|
+
@setColour(<%= color %>)
|
163
|
+
@interpolateMsg('%1秒でx座標を%2、y座標を%3に変える',
|
164
|
+
['SEC', ['Number'], Blockly.ALIGN_RIGHT],
|
165
|
+
['X', ['Number'], Blockly.ALIGN_RIGHT],
|
166
|
+
['Y', ['Number'], Blockly.ALIGN_RIGHT],
|
167
|
+
Blockly.ALIGN_RIGHT)
|
168
|
+
@setInputsInline(true)
|
169
|
+
@setPreviousStatement(true)
|
170
|
+
@setNextStatement(true)
|
171
|
+
@setTooltip('')
|
172
|
+
|
173
|
+
Blockly.Ruby['<%= n %>'] = (block) ->
|
174
|
+
sec = Blockly.Ruby.valueToCode(@, 'SEC', Blockly.Ruby.ORDER_NONE) || '0'
|
175
|
+
x = Blockly.Ruby.valueToCode(@, 'X', Blockly.Ruby.ORDER_NONE) || '0'
|
176
|
+
y = Blockly.Ruby.valueToCode(@, 'Y', Blockly.Ruby.ORDER_NONE) || '0'
|
177
|
+
"#{Blockly.Ruby.rn()}glide_to(second: #{sec}, x: #{x}, y: #{y})\n"
|
178
|
+
|
179
|
+
# x座標を( )ずつ変える
|
180
|
+
# x座標を( )にする
|
181
|
+
# y座標を( )ずつ変える
|
182
|
+
# y座標を( )にする
|
183
|
+
<%
|
184
|
+
[
|
185
|
+
['change_x_by', 'X', 'ずつ変える', '+='],
|
186
|
+
['set_x', 'X', 'にする', '='],
|
187
|
+
['change_y_by', 'Y', 'ずつ変える', '+='],
|
188
|
+
['set_y', 'Y', 'にする', '='],
|
189
|
+
].each do |suffix, name, label_suffix, operator|
|
190
|
+
n = "#{category}_#{suffix}"
|
191
|
+
%>
|
192
|
+
|
193
|
+
Blockly.Blocks['<%= n %>'] =
|
194
|
+
init: ()->
|
195
|
+
@setHelpUrl('')
|
196
|
+
@setColour(<%= color %>)
|
197
|
+
@interpolateMsg('<%= name.downcase %>座標を%1<%= label_suffix %>',
|
198
|
+
['<%= name %>', ['Number'], Blockly.ALIGN_RIGHT],
|
199
|
+
Blockly.ALIGN_RIGHT)
|
200
|
+
@setInputsInline(true)
|
201
|
+
@setPreviousStatement(true)
|
202
|
+
@setNextStatement(true)
|
203
|
+
@setTooltip('')
|
204
|
+
|
205
|
+
Blockly.Ruby['<%= n %>'] = (block) ->
|
206
|
+
<%= name.downcase %> = Blockly.Ruby.valueToCode(@, '<%= name %>', Blockly.Ruby.ORDER_NONE) || '0'
|
207
|
+
Blockly.Ruby.characterSetVariable_('<%= name.downcase %>', <%= name.downcase %>, '<%= operator %>')
|
208
|
+
<% end %>
|
209
|
+
|
210
|
+
# もし端に着いたら、跳ね返る
|
211
|
+
<% n = "#{category}_turn_if_reach_wall" %>
|
212
|
+
Blockly.Blocks['<%= n %>'] =
|
213
|
+
init: ()->
|
214
|
+
@setHelpUrl('')
|
215
|
+
@setColour(<%= color %>)
|
216
|
+
@appendDummyInput().appendField('もし端に着いたら、跳ね返る')
|
217
|
+
@setPreviousStatement(true)
|
218
|
+
@setNextStatement(true)
|
219
|
+
@setTooltip('')
|
220
|
+
|
221
|
+
Blockly.Ruby['<%= n %>'] = (block) ->
|
222
|
+
Blockly.Ruby.characterMethodCall_('turn_if_reach_wall')
|
223
|
+
|
224
|
+
# 条件:端に着いた
|
225
|
+
<% n = "#{category}_reach_wall" %>
|
226
|
+
Blockly.Blocks['<%= n %>'] =
|
227
|
+
init: ()->
|
228
|
+
@setHelpUrl('')
|
229
|
+
@setColour(<%= color %>)
|
230
|
+
@appendDummyInput().appendField('端に着いた')
|
231
|
+
@setOutput(true, 'Boolean')
|
232
|
+
@setTooltip('')
|
233
|
+
|
234
|
+
Blockly.Ruby['<%= n %>'] = (block) ->
|
235
|
+
Blockly.Ruby.characterMethodCallInput_('reach_wall?')
|
236
|
+
|
237
|
+
# 跳ね返る
|
238
|
+
<% n = "#{category}_turn" %>
|
239
|
+
Blockly.Blocks['<%= n %>'] =
|
240
|
+
init: ()->
|
241
|
+
@setHelpUrl('')
|
242
|
+
@setColour(<%= color %>)
|
243
|
+
@appendDummyInput().appendField('跳ね返る')
|
244
|
+
@setPreviousStatement(true)
|
245
|
+
@setNextStatement(true)
|
246
|
+
@setTooltip('')
|
247
|
+
|
248
|
+
Blockly.Ruby['<%= n %>'] = (block) ->
|
249
|
+
Blockly.Ruby.characterMethodCall_('turn')
|
250
|
+
|
251
|
+
# 回転方法を[▼]にする
|
252
|
+
<% n = "#{category}_set_rotation_style" %>
|
253
|
+
Blockly.Blocks['<%= n %>'] =
|
254
|
+
init: ()->
|
255
|
+
dropdown = [
|
256
|
+
['左右のみ', 'left_right'],
|
257
|
+
['回転しない', 'none'],
|
258
|
+
['自由に回転', 'free'],
|
259
|
+
]
|
260
|
+
|
261
|
+
@setHelpUrl('')
|
262
|
+
@setColour(<%= color %>)
|
263
|
+
@appendDummyInput()
|
264
|
+
.appendField('回転方法を')
|
265
|
+
.appendField(new Blockly.FieldDropdown(dropdown), 'STYLE')
|
266
|
+
.appendField('にする')
|
267
|
+
@setPreviousStatement(true)
|
268
|
+
@setNextStatement(true)
|
269
|
+
@setTooltip('')
|
270
|
+
|
271
|
+
Blockly.Ruby['<%= n %>'] = (block) ->
|
272
|
+
style = @getFieldValue('STYLE')
|
273
|
+
"#{Blockly.Ruby.rn({ dropSelf: false })}rotation_style = :#{style}\n"
|
274
|
+
|
275
|
+
# 変数:x座標
|
276
|
+
# 変数:y座標
|
277
|
+
# 変数:向き
|
278
|
+
<%
|
279
|
+
[
|
280
|
+
['x', 'x座標'],
|
281
|
+
['y', 'y座標'],
|
282
|
+
['angle', '向き'],
|
283
|
+
].each do |method, label|
|
284
|
+
n = "#{category}_self_#{method}"
|
285
|
+
%>
|
286
|
+
|
287
|
+
Blockly.Blocks['<%= n %>'] =
|
288
|
+
init: ()->
|
289
|
+
@setHelpUrl('')
|
290
|
+
@setColour(<%= color %>)
|
291
|
+
@appendDummyInput().appendField('<%= label %>')
|
292
|
+
@setOutput(true, 'Number')
|
293
|
+
@setTooltip('')
|
294
|
+
|
295
|
+
Blockly.Ruby['<%= n %>'] = (block) ->
|
296
|
+
Blockly.Ruby.characterMethodCallInput_('<%= method %>')
|
297
|
+
<% end %>
|