smalruby 0.1.1-x86-mingw32 → 0.1.2-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 might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b5c901b60e685ae7c19761cd508dfe594ee3b85f
4
- data.tar.gz: 97525fa3c33e1bc7a1f8683932580cabf9273b0e
3
+ metadata.gz: 5d4ec449019b1e028e6ccaf477c20686cb7df8d1
4
+ data.tar.gz: 97424d8c19c1ff8082b08ae7530ec60dac16bfde
5
5
  SHA512:
6
- metadata.gz: 09aea517a57d82aa6e45d120fe2174b8181af703980ad1961bcef5d850b1a957e5a7f5d3045ba38444a2f42ae0919569b9b9b60a0a453ab1aa913d5f82c21441
7
- data.tar.gz: fd3a9e698fbdd31b225bd0340577c4dbdcb01f5bc9e8a12320bf43a95c5f2a49acbfa61347b6d75476ef426db0fe63cf6c7259e4dcf139cbf09168d503130015
6
+ metadata.gz: 87dcea92d065219e69007fed09eac2da801d0393c59e992c3d79d971f7fe0ce3ff2bc6d918eda9f6d34d0a23a6f815dac6ae1e4a4508533f91593799cbca437d
7
+ data.tar.gz: 699be7d82891b6a359c92ef42e88995e1bf4bdecdd6b03b4d51429dff241832b05a101612d4be66712b03be1f22b80ed95a403fa2d8c310c7a7ff3fabaf33c86
data/Rakefile CHANGED
@@ -47,21 +47,25 @@ task :build do
47
47
  ENV['GEM_PLATFORM'] = 'linux'
48
48
  Rake::Task['gem:build'].invoke
49
49
 
50
- ENV['GEM_PLATFORM'] = 'x86-mingw32'
51
- Rake::Task['gem:build'].reenable
52
- Rake::Task['gem:build'].invoke
50
+ require 'smalruby/version'
51
+ Bundler.with_clean_env do
52
+ ENV['GEM_PLATFORM'] = 'x86-mingw32'
53
+ dest = "smalruby-#{Smalruby::VERSION}-#{ENV['GEM_PLATFORM']}.gem"
54
+ sh "gem build smalruby.gemspec && mv #{dest} pkg/"
55
+ end
53
56
  end
54
57
 
55
58
  task :release do
56
59
  ENV['GEM_PLATFORM'] = 'linux'
57
60
  Rake::Task['gem:release'].invoke
58
61
 
59
- ENV['GEM_PLATFORM'] = 'x86-mingw32'
60
- Rake::Task['gem:release'].reenable
61
- Rake::Task['gem:build'].reenable
62
- Rake::Task['gem:release'].invoke
63
-
64
62
  require 'smalruby/version'
63
+ Bundler.with_clean_env do
64
+ ENV['GEM_PLATFORM'] = 'x86-mingw32'
65
+ dest = "smalruby-#{Smalruby::VERSION}-#{ENV['GEM_PLATFORM']}.gem"
66
+ sh "gem build smalruby.gemspec && mv #{dest} pkg/ && gem push pkg/#{dest}"
67
+ end
68
+
65
69
  next_version = Smalruby::VERSION.split('.').tap { |versions|
66
70
  versions[-1] = (versions[-1].to_i + 1).to_s
67
71
  }.join('.')
@@ -411,6 +411,11 @@ module Smalruby
411
411
  Hardware.create_hardware(Hardware::SmalrubotV3)
412
412
  end
413
413
 
414
+ # create or get Hardware::Studuino instance
415
+ def studuino
416
+ Hardware.create_hardware(Hardware::Studuino)
417
+ end
418
+
414
419
  # @!endgroup
415
420
 
416
421
  def draw
File without changes
@@ -0,0 +1,95 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'smalruby/hardware'
3
+
4
+ module Smalruby
5
+ module Hardware
6
+ # Studuino class
7
+ class Studuino
8
+ include Smalrubot::Board::Studuino
9
+
10
+ def initialize(_)
11
+ world.board.init_dc_motor_port(PORT_M1, 0)
12
+ world.board.init_dc_motor_port(PORT_M2, 0)
13
+
14
+ world.board.init_sensor_port(PORT_A0, PIDIRPHOTOREFLECTOR)
15
+ end
16
+
17
+ # @!method forward(sec: nil)
18
+ # forward
19
+ #
20
+ # @param [Float] time of forwarding
21
+
22
+ # @!method backward(sec: nil)
23
+ # backward
24
+ #
25
+ # @param [Float] time of backwarding
26
+
27
+ # @!method turn_left(sec: nil)
28
+ # turn left
29
+ #
30
+ # @param [Float] time of turning left
31
+
32
+ # @!method turn_right(sec: nil)
33
+ # turn right
34
+ #
35
+ # @param [Float] time of turning right
36
+
37
+ # @!method stop(sec: nil)
38
+ # stop
39
+ #
40
+ # @param [Float] time of stopping
41
+ %i(forward backward turn_left turn_right stop).each do |direction|
42
+ define_method(direction) do |sec: nil|
43
+ run(direction, sec: sec)
44
+ end
45
+ end
46
+
47
+ def ir_photoreflector_value
48
+ world.board.get_ir_photoreflector_value(0).to_i
49
+ end
50
+
51
+ private
52
+
53
+ def run(direction, sec: nil)
54
+ case direction
55
+ when :forward
56
+ world.board.dc_motor_power(PORT_M1, 255)
57
+ world.board.dc_motor_power(PORT_M2, 255)
58
+ world.board.dc_motor_control(PORT_M1, NORMAL)
59
+ world.board.dc_motor_control(PORT_M2, NORMAL)
60
+ when :backward
61
+ world.board.dc_motor_power(PORT_M1, 255)
62
+ world.board.dc_motor_power(PORT_M2, 255)
63
+ world.board.dc_motor_control(PORT_M1, REVERSE)
64
+ world.board.dc_motor_control(PORT_M2, REVERSE)
65
+ when :turn_left
66
+ world.board.dc_motor_power(PORT_M1, 255)
67
+ world.board.dc_motor_power(PORT_M2, 255)
68
+ world.board.dc_motor_control(PORT_M1, REVERSE)
69
+ world.board.dc_motor_control(PORT_M2, NORMAL)
70
+ when :turn_right
71
+ world.board.dc_motor_power(PORT_M1, 255)
72
+ world.board.dc_motor_power(PORT_M2, 255)
73
+ world.board.dc_motor_control(PORT_M1, NORMAL)
74
+ world.board.dc_motor_control(PORT_M2, REVERSE)
75
+ when :stop
76
+ _stop
77
+ end
78
+
79
+ if (sec = sec.to_f) > 0
80
+ sleep(sec)
81
+ if direction != :stop
82
+ _stop
83
+ end
84
+ end
85
+ end
86
+
87
+ def _stop
88
+ world.board.dc_motor_power(PORT_M1, 255)
89
+ world.board.dc_motor_power(PORT_M2, 255)
90
+ world.board.dc_motor_control(PORT_M1, COAST)
91
+ world.board.dc_motor_control(PORT_M2, COAST)
92
+ end
93
+ end
94
+ end
95
+ end
@@ -21,6 +21,7 @@ module Smalruby
21
21
  autoload :Sensor
22
22
 
23
23
  autoload :SmalrubotV3
24
+ autoload :Studuino
24
25
 
25
26
  module_function
26
27
 
@@ -34,7 +35,7 @@ module Smalruby
34
35
 
35
36
  defaults = {
36
37
  device: nil,
37
- baud: 115_200,
38
+ baud: 19_200,
38
39
  }
39
40
  opt = Util.process_options(options, defaults)
40
41
 
@@ -1,5 +1,5 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
3
  module Smalruby
4
- VERSION = '0.1.1'
4
+ VERSION = '0.1.2'
5
5
  end
@@ -0,0 +1,121 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ DESCRIPTION = <<EOS
4
+ Studuinoを操作します
5
+ EOS
6
+
7
+ require 'smalruby'
8
+
9
+ init_hardware
10
+
11
+ stage1 = Stage.new(color: 'white')
12
+
13
+ stage1.on(:start) do
14
+ fill(color: 'white')
15
+ draw_font(string: DESCRIPTION, color: 'black')
16
+
17
+ stage1.studuino
18
+
19
+ loop do
20
+ if Input.key_down?(K_UP)
21
+ fill(color: 'white')
22
+ draw_font(string: '進む', color: 'black')
23
+
24
+ studuino.forward
25
+
26
+ await until !Input.key_down?(K_UP)
27
+
28
+ fill(color: 'white')
29
+
30
+ studuino.stop
31
+ end
32
+
33
+ if Input.key_down?(K_DOWN)
34
+ fill(color: 'white')
35
+ draw_font(string: 'バックする', color: 'black')
36
+
37
+ studuino.backward
38
+
39
+ await until !Input.key_down?(K_DOWN)
40
+
41
+ fill(color: 'white')
42
+
43
+ studuino.stop
44
+ end
45
+
46
+ if Input.key_down?(K_LEFT)
47
+ fill(color: 'white')
48
+ draw_font(string: '左に旋回する', color: 'black')
49
+
50
+ studuino.turn_left
51
+
52
+ await until !Input.key_down?(K_LEFT)
53
+
54
+ fill(color: 'white')
55
+
56
+ studuino.stop
57
+ end
58
+
59
+ if Input.key_down?(K_RIGHT)
60
+ fill(color: 'white')
61
+ draw_font(string: '右に旋回する', color: 'black')
62
+
63
+ studuino.turn_right
64
+
65
+ await until !Input.key_down?(K_RIGHT)
66
+
67
+ fill(color: 'white')
68
+
69
+ studuino.stop
70
+ end
71
+
72
+ if Input.key_down?(K_B)
73
+ until !Input.key_down?(K_B)
74
+ fill(color: 'white')
75
+ draw_font(string: "ライントレーサーの情報: #{studuino.ir_photoreflector_value}",
76
+ color: 'black')
77
+ await
78
+ end
79
+ fill(color: 'white')
80
+ end
81
+ end
82
+ end
83
+
84
+ stage1.on(:key_push, K_A) do
85
+ loop do
86
+ fill(color: 'white')
87
+ draw_font(string: '自動運転', color: 'black')
88
+
89
+ studuino.forward
90
+
91
+ loop do
92
+ if studuino.ir_photoreflector_value < 500
93
+ fill(color: 'white')
94
+ draw_font(string: '前方障害物発見!', color: 'black')
95
+
96
+ studuino.backward
97
+ sleep(0.25)
98
+ if rand(2) == 1
99
+ studuino.turn_left
100
+ sleep(0.1)
101
+ else
102
+ studuino.turn_left
103
+ sleep(0.1)
104
+ end
105
+ break
106
+ end
107
+
108
+ if Input.key_down?(K_Y)
109
+ fill(color: 'white')
110
+ break
111
+ end
112
+ end
113
+ studuino.stop
114
+ sleep(0.1)
115
+
116
+ if Input.key_down?(K_Y)
117
+ fill(color: 'white')
118
+ break
119
+ end
120
+ end
121
+ end
data/smalruby.gemspec CHANGED
@@ -42,5 +42,5 @@ Gem::Specification.new do |spec|
42
42
  else
43
43
  spec.add_runtime_dependency 'dxruby_sdl', '~> 0.0.12'
44
44
  end
45
- spec.add_runtime_dependency 'smalrubot', '~> 0.0.2'
45
+ spec.add_runtime_dependency 'smalrubot', '~> 0.0.3'
46
46
  end
metadata CHANGED
@@ -1,181 +1,181 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smalruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: x86-mingw32
6
6
  authors:
7
7
  - Kouji Takao
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-24 00:00:00.000000000 Z
11
+ date: 2015-01-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.3'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.3'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: yard
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: redcarpet
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '>='
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - '>='
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: coveralls
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - '>='
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - '>='
94
+ - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: travis-lint
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - '>='
101
+ - - ">="
102
102
  - !ruby/object:Gem::Version
103
103
  version: '0'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - '>='
108
+ - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: rubocop
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - ~>
115
+ - - "~>"
116
116
  - !ruby/object:Gem::Version
117
117
  version: '0.16'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - ~>
122
+ - - "~>"
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0.16'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: guard-rspec
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - '>='
129
+ - - ">="
130
130
  - !ruby/object:Gem::Version
131
131
  version: '0'
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - '>='
136
+ - - ">="
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: guard-rubocop
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
- - - '>='
143
+ - - ">="
144
144
  - !ruby/object:Gem::Version
145
145
  version: '0'
146
146
  type: :development
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
- - - '>='
150
+ - - ">="
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0'
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: mime-types
155
155
  requirement: !ruby/object:Gem::Requirement
156
156
  requirements:
157
- - - ~>
157
+ - - "~>"
158
158
  - !ruby/object:Gem::Version
159
159
  version: '1.6'
160
160
  type: :runtime
161
161
  prerelease: false
162
162
  version_requirements: !ruby/object:Gem::Requirement
163
163
  requirements:
164
- - - ~>
164
+ - - "~>"
165
165
  - !ruby/object:Gem::Version
166
166
  version: '1.6'
167
167
  - !ruby/object:Gem::Dependency
168
168
  name: activesupport
169
169
  requirement: !ruby/object:Gem::Requirement
170
170
  requirements:
171
- - - '>='
171
+ - - ">="
172
172
  - !ruby/object:Gem::Version
173
173
  version: '0'
174
174
  type: :runtime
175
175
  prerelease: false
176
176
  version_requirements: !ruby/object:Gem::Requirement
177
177
  requirements:
178
- - - '>='
178
+ - - ">="
179
179
  - !ruby/object:Gem::Version
180
180
  version: '0'
181
181
  - !ruby/object:Gem::Dependency
@@ -196,16 +196,16 @@ dependencies:
196
196
  name: smalrubot
197
197
  requirement: !ruby/object:Gem::Requirement
198
198
  requirements:
199
- - - ~>
199
+ - - "~>"
200
200
  - !ruby/object:Gem::Version
201
- version: 0.0.2
201
+ version: 0.0.3
202
202
  type: :runtime
203
203
  prerelease: false
204
204
  version_requirements: !ruby/object:Gem::Requirement
205
205
  requirements:
206
- - - ~>
206
+ - - "~>"
207
207
  - !ruby/object:Gem::Version
208
- version: 0.0.2
208
+ version: 0.0.3
209
209
  description: smalruby is a 2D game development library. This is part of "Smalruby"
210
210
  project that is a learning ruby programming environment for kids.
211
211
  email:
@@ -214,10 +214,10 @@ executables: []
214
214
  extensions: []
215
215
  extra_rdoc_files: []
216
216
  files:
217
- - .gitignore
218
- - .rspec
219
- - .rubocop.yml
220
- - .travis.yml
217
+ - ".gitignore"
218
+ - ".rspec"
219
+ - ".rubocop.yml"
220
+ - ".travis.yml"
221
221
  - Gemfile
222
222
  - LEGAL
223
223
  - LICENSE
@@ -266,6 +266,7 @@ files:
266
266
  - lib/smalruby/hardware/sensor.rb
267
267
  - lib/smalruby/hardware/servo.rb
268
268
  - lib/smalruby/hardware/smalrubot_v3.rb
269
+ - lib/smalruby/hardware/studuino.rb
269
270
  - lib/smalruby/hardware/two_wheel_drive_car.rb
270
271
  - lib/smalruby/stage.rb
271
272
  - lib/smalruby/util.rb
@@ -278,6 +279,7 @@ files:
278
279
  - samples/cat.rb
279
280
  - samples/check_hardware_motor_driver.rb
280
281
  - samples/check_hardware_smalrubot_v3.rb
282
+ - samples/check_hardware_studuino.rb
281
283
  - samples/console.rb
282
284
  - samples/costume.rb
283
285
  - samples/costumes.rb
@@ -311,17 +313,17 @@ require_paths:
311
313
  - lib
312
314
  required_ruby_version: !ruby/object:Gem::Requirement
313
315
  requirements:
314
- - - '>='
316
+ - - ">="
315
317
  - !ruby/object:Gem::Version
316
318
  version: '0'
317
319
  required_rubygems_version: !ruby/object:Gem::Requirement
318
320
  requirements:
319
- - - '>='
321
+ - - ">="
320
322
  - !ruby/object:Gem::Version
321
323
  version: '0'
322
324
  requirements: []
323
325
  rubyforge_project:
324
- rubygems_version: 2.0.14
326
+ rubygems_version: 2.2.2
325
327
  signing_key:
326
328
  specification_version: 4
327
329
  summary: 2D game development library for kids.