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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 08e16f84f0f5aedb1b4afd1e43078ec07e5f4315
4
- data.tar.gz: a06c5995fa6e9da58233d68134f1d26c49ec6545
3
+ metadata.gz: de1f38e041662e3951fc08a199e406f775c3393a
4
+ data.tar.gz: 0bef6659dc38ff498f2efd6fd8d81ceb0383ce71
5
5
  SHA512:
6
- metadata.gz: 15f4e0dbb1911cb52e6ef7e85977878a04810577970f92f2ca259b06bc3f2ef8cdb4f4e667e371130d0f65ceda99e11bf3e7515ac1792d7f7f1541978ade7297
7
- data.tar.gz: e94f85dfedf7cbde8ed5769cd60f6eb8667c5d34baeb05feae40152ff0efae66fac363a1b870f9bc6fe1dde0befe2f1d65fa19b45fae140d3e37d5bb11d2d355
6
+ metadata.gz: e1198cb4c12b92d0a730a4f169f29dd044c01c86865ac41bd404538990052155823f1ebf092a0e03655315756cf82bc2c4145e4e67078b0b58c6739149484942
7
+ data.tar.gz: 765e084047bd46ea513252c3575c262a73c8bf9775bc3a859756482ec3e81f9a24f1d48d6b6df176ee587f37f3f8614edf2fb460cefbad9c66f2a48f5be0c6d5
@@ -83,19 +83,51 @@ module Smalruby
83
83
 
84
84
  # ( )度回転する
85
85
  def rotate(angle)
86
- radian = angle * Math::PI / 180
87
- x, y = @vector[:x], @vector[:y]
88
- @vector[:x] = x * Math.cos(radian) - y * Math.sin(radian)
89
- @vector[:y] = x * Math.sin(radian) + y * Math.cos(radian)
90
- self.angle = (self.angle + angle) % 360
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(message)
98
- lines = message.to_s.lines.map { |l| l.scan(/.{1,10}/) }.flatten
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 音
@@ -1,8 +1,8 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
3
  module Smalruby
4
- # シーンを表現するクラス
5
- class Scene < Canvas
4
+ # ステージを表現するクラス
5
+ class Stage < Canvas
6
6
  def initialize(options = {})
7
7
  defaults = {
8
8
  color: 'black'
@@ -1,5 +1,5 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
3
  module Smalruby
4
- VERSION = '0.0.9'
4
+ VERSION = '0.0.10'
5
5
  end
data/lib/smalruby.rb CHANGED
@@ -16,7 +16,7 @@ module Smalruby
16
16
 
17
17
  autoload :Console
18
18
  autoload :Canvas
19
- autoload :Scene
19
+ autoload :Stage
20
20
  autoload :Hardware
21
21
 
22
22
  module_function
data/samples/cat.rb ADDED
@@ -0,0 +1,8 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'smalruby'
3
+
4
+ cat1 = Character.new(costume: 'cat1.png', x: 300, y: 200)
5
+
6
+ cat1.on(:click) do
7
+ say(message: 'こんにちは')
8
+ end
@@ -10,9 +10,9 @@ require 'smalruby'
10
10
 
11
11
  init_hardware
12
12
 
13
- scene1 = Scene.new(color: 'white')
13
+ stage1 = Stage.new(color: 'white')
14
14
 
15
- scene1.on(:start) do
15
+ stage1.on(:start) do
16
16
  draw_font(string: DESCRIPTION, color: 'black')
17
17
 
18
18
  loop do
@@ -11,9 +11,9 @@ require 'smalruby'
11
11
 
12
12
  init_hardware
13
13
 
14
- scene1 = Scene.new(color: 'white')
14
+ stage1 = Stage.new(color: 'white')
15
15
 
16
- scene1.on(:start) do
16
+ stage1.on(:start) do
17
17
  draw_font(string: DESCRIPTION, color: 'black')
18
18
 
19
19
  loop do
@@ -11,9 +11,9 @@ require 'smalruby'
11
11
 
12
12
  init_hardware
13
13
 
14
- scene1 = Scene.new(color: 'white')
14
+ stage1 = Stage.new(color: 'white')
15
15
 
16
- scene1.on(:start) do
16
+ stage1.on(:start) do
17
17
  draw_font(string: DESCRIPTION, color: 'black')
18
18
 
19
19
  loop do
@@ -4,9 +4,9 @@ require 'smalruby'
4
4
 
5
5
  init_hardware
6
6
 
7
- scene1 = Scene.new(color: 'white')
7
+ stage1 = Stage.new(color: 'white')
8
8
 
9
- scene1.on(:sensor_change, 'A0') do |value|
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.9
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-08 00:00:00.000000000 Z
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/scene.rb
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