smalruby 0.0.9-x86-mingw32 → 0.0.10-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 +4 -4
- data/lib/smalruby/character.rb +43 -7
- data/lib/smalruby/{scene.rb → stage.rb} +2 -2
- data/lib/smalruby/version.rb +1 -1
- data/lib/smalruby.rb +1 -1
- data/samples/cat.rb +8 -0
- data/samples/hardware_led.rb +2 -2
- data/samples/hardware_rgb_led_anode.rb +2 -2
- data/samples/hardware_rgb_led_cathode.rb +2 -2
- data/samples/hardware_sensor.rb +2 -2
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: de1f38e041662e3951fc08a199e406f775c3393a
|
4
|
+
data.tar.gz: 0bef6659dc38ff498f2efd6fd8d81ceb0383ce71
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e1198cb4c12b92d0a730a4f169f29dd044c01c86865ac41bd404538990052155823f1ebf092a0e03655315756cf82bc2c4145e4e67078b0b58c6739149484942
|
7
|
+
data.tar.gz: 765e084047bd46ea513252c3575c262a73c8bf9775bc3a859756482ec3e81f9a24f1d48d6b6df176ee587f37f3f8614edf2fb460cefbad9c66f2a48f5be0c6d5
|
data/lib/smalruby/character.rb
CHANGED
@@ -83,19 +83,51 @@ module Smalruby
|
|
83
83
|
|
84
84
|
# ( )度回転する
|
85
85
|
def rotate(angle)
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
86
|
+
self.angle += angle
|
87
|
+
end
|
88
|
+
|
89
|
+
# ( )度に向ける
|
90
|
+
def angle=(val)
|
91
|
+
val %= 360
|
92
|
+
radian = val * Math::PI / 180
|
93
|
+
@vector[:x] = self.scale_x * Math.cos(radian)
|
94
|
+
@vector[:y] = self.scale_x * Math.sin(radian)
|
95
|
+
super(val)
|
96
|
+
end
|
97
|
+
|
98
|
+
# ( )に向ける
|
99
|
+
def point_towards(target)
|
100
|
+
if target == :mouse
|
101
|
+
tx = Input.mouse_pos_x
|
102
|
+
ty = Input.mouse_pos_y
|
103
|
+
else
|
104
|
+
tx = target.x
|
105
|
+
ty = target.y
|
106
|
+
end
|
107
|
+
dx = tx - x
|
108
|
+
dy = ty - y
|
109
|
+
self.angle = Math.atan2(dy, dx) * 180 / Math::PI
|
91
110
|
end
|
92
111
|
|
93
112
|
# @!endgroup
|
94
113
|
|
95
114
|
# @!group 見た目
|
96
115
|
|
97
|
-
def say(
|
98
|
-
|
116
|
+
def say(options = {})
|
117
|
+
defaults = {
|
118
|
+
message: '',
|
119
|
+
second: 0,
|
120
|
+
}
|
121
|
+
opts = process_optional_arguments(options, defaults)
|
122
|
+
|
123
|
+
if @balloon
|
124
|
+
@balloon.vanish
|
125
|
+
@balloon = nil
|
126
|
+
end
|
127
|
+
|
128
|
+
return if opts[:message].empty?
|
129
|
+
|
130
|
+
lines = opts[:message].to_s.lines.map { |l| l.scan(/.{1,10}/) }.flatten
|
99
131
|
font = new_font(16)
|
100
132
|
width = lines.map { |l| font.get_width(l) }.max
|
101
133
|
height = lines.length * (font.size + 1)
|
@@ -135,6 +167,10 @@ module Smalruby
|
|
135
167
|
self.y < 0 || self.y >= (Window.height - image.height)
|
136
168
|
end
|
137
169
|
|
170
|
+
def hit?(other)
|
171
|
+
check([other]).length > 0
|
172
|
+
end
|
173
|
+
|
138
174
|
# @!endgroup
|
139
175
|
|
140
176
|
# @!group 音
|
data/lib/smalruby/version.rb
CHANGED
data/lib/smalruby.rb
CHANGED
data/samples/cat.rb
ADDED
data/samples/hardware_led.rb
CHANGED
data/samples/hardware_sensor.rb
CHANGED
@@ -4,9 +4,9 @@ require 'smalruby'
|
|
4
4
|
|
5
5
|
init_hardware
|
6
6
|
|
7
|
-
|
7
|
+
stage1 = Stage.new(color: 'white')
|
8
8
|
|
9
|
-
|
9
|
+
stage1.on(:sensor_change, 'A0') do |value|
|
10
10
|
v = sensor('A0').value
|
11
11
|
if 0 <= v && v <= 255
|
12
12
|
fill(color: 'red')
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smalruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.10
|
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: 2014-02-
|
11
|
+
date: 2014-02-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -258,13 +258,14 @@ files:
|
|
258
258
|
- lib/smalruby/hardware/rgb_led_anode.rb
|
259
259
|
- lib/smalruby/hardware/rgb_led_cathode.rb
|
260
260
|
- lib/smalruby/hardware/sensor.rb
|
261
|
-
- lib/smalruby/
|
261
|
+
- lib/smalruby/stage.rb
|
262
262
|
- lib/smalruby/util.rb
|
263
263
|
- lib/smalruby/version.rb
|
264
264
|
- lib/smalruby/world.rb
|
265
265
|
- samples/.rubocop.yml
|
266
266
|
- samples/canvas.rb
|
267
267
|
- samples/car.rb
|
268
|
+
- samples/cat.rb
|
268
269
|
- samples/console.rb
|
269
270
|
- samples/costume.rb
|
270
271
|
- samples/extra_car.png
|