dxruby_rp5 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6d389ace1e68ca99ad2743e9ce4f516a4eaccbde
4
- data.tar.gz: 1fbd680b020f016b9c8c9c5607a5254c8591621b
3
+ metadata.gz: b9c490773a29a58b52f489b9b893e33cb3c4d6ba
4
+ data.tar.gz: 03ea8c62a61f80d00fa5a0159b31e101452ecf75
5
5
  SHA512:
6
- metadata.gz: c1d7a85aa78a4acc95f533f2b9ef5d9039f2efade25d87c4fede7c8adb113bef4d3b9cda47288a1a3a596403c42bfa5019191b6b02e995d89931cd3a5c57924b
7
- data.tar.gz: ff8e31a5cfc899517cbb54a32efba7a5362038326a0bfb003a3c45f9caa2327ea9a5858946f07a9f3d8948d9a4fae411f5937f3e5f536c59ae5c27110e9e1e19
6
+ metadata.gz: 2a6046643c99531feb44b81a097cdabb75f764868fa793855bf0c618f1bf8194651a26c72f4c8261bf126000ef689f25ef95f869b2f7530cfe1447dd5f26f9d6
7
+ data.tar.gz: 3556a91f3361ff116d0b01bfda9b96a2810c6fb1186fcb9605afb674f812f29730146cb4667001ce73878621d26ba8b0f9f11362fb56a0babc32e608b906ecdf
@@ -243,4 +243,9 @@ if RUBY_ENGINE == "jruby"
243
243
  require_relative 'dxruby_rp5/sound'
244
244
  require_relative 'dxruby_rp5/sound_effect'
245
245
  require_relative 'dxruby_rp5/render_target'
246
+
247
+ Processing::App.sketch_class.class_eval do
248
+ load_library :minim
249
+ import 'ddf.minim'
250
+ end
246
251
  end
@@ -87,6 +87,37 @@ module DXRubyRP5
87
87
  return c[0..max] == _color
88
88
  end
89
89
 
90
+ def line(x1, y1, x2, y2, _color)
91
+ _color = to_rp5_color(_color)
92
+ draw_on_image(_color, false) do |pg|
93
+ pg.line(x1, y1, x2, y2)
94
+ end
95
+ end
96
+
97
+ def box(x1, y1, x2, y2, _color)
98
+ rect(x1, y1, x2, y2, _color)
99
+ end
100
+
101
+ def box_fill(x1, y1, x2, y2, _color)
102
+ rect(x1, y1, x2, y2, _color, true)
103
+ end
104
+
105
+ def circle(x, y, r, _color)
106
+ ellipse(x, y, 2*r, 2*r, _color)
107
+ end
108
+
109
+ def circle_fill(x, y, r, _color)
110
+ ellipse(x, y, 2*r, 2*r, _color, true)
111
+ end
112
+
113
+ def triangle(x1, y1, x2, y2, x3, y3, _color)
114
+ _triangle(x1, y1, x2, y2, x3, y3, _color)
115
+ end
116
+
117
+ def triangle_fill(x1, y1, x2, y2, x3, y3, _color)
118
+ _triangle(x1, y1, x2, y2, x3, y3, _color, true)
119
+ end
120
+
90
121
  def slice(x, y, width, height)
91
122
  image = self.class.new(0, 0)
92
123
  s = $app.create_image(width, height, Processing::App::ARGB)
@@ -113,6 +144,9 @@ module DXRubyRP5
113
144
  alias_method :load_to_array, :load_tiles
114
145
  alias_method :loadToArray, :load_to_array
115
146
  end
147
+ alias_method :boxFill, :box_fill
148
+ alias_method :circleFill, :circle_fill
149
+ alias_method :triangleFill, :triangle_fill
116
150
  alias_method :setColorKey, :set_color_key
117
151
  alias_method :sliceTiles, :slice_tiles
118
152
  alias_method :slice_to_array, :slice_tiles
@@ -143,5 +177,55 @@ module DXRubyRP5
143
177
  def blue(rgb)
144
178
  return rgb & 0xFF
145
179
  end
180
+
181
+ # TODO: simplify
182
+ def draw_on_image(rp5_color, fill)
183
+ w, h = @_surface.width, @_surface.height
184
+ pg = $app.create_graphics(w, h)
185
+ pg.begin_draw
186
+ pg.image(@_surface, 0, 0)
187
+ pg.push_matrix
188
+ if fill
189
+ pg.no_stroke
190
+ pg.fill(*rp5_color)
191
+ calibration = 0
192
+ else
193
+ # processingの仕様でstrokeでは描画する図形の右端・下端の外側に
194
+ # 線を引くため、指定した幅と高さに収まるよう、線の太さ(-1)分の
195
+ # 補正値をかける
196
+ pg.stroke(*rp5_color)
197
+ pg.no_fill
198
+ calibration = -1
199
+ end
200
+ yield(pg, calibration)
201
+ pg.pop_matrix
202
+ pg.end_draw
203
+ @_surface.copy(pg, 0, 0, w, h, 0, 0, w, h)
204
+ return self
205
+ end
206
+
207
+ def rect(x1, y1, x2, y2, _color, fill=false)
208
+ _color = to_rp5_color(_color)
209
+ rect_w = x2 - x1
210
+ rect_h = y2 - y1
211
+ draw_on_image(_color, fill) do |pg, c|
212
+ pg.rect(x1, y1, rect_w + c, rect_h + c)
213
+ end
214
+ end
215
+
216
+ def ellipse(x, y, width, heigth, _color, fill=false)
217
+ _color = to_rp5_color(_color)
218
+ draw_on_image(_color, fill) do |pg, c|
219
+ pg.ellipse(x, y, width + c, height + c)
220
+ end
221
+ end
222
+
223
+ def _triangle(x1, y1, x2, y2, x3, y3, _color, fill=false)
224
+ _color = to_rp5_color(_color)
225
+ draw_on_image(_color, fill) do |pg, c|
226
+ # TODO: use calibration
227
+ pg.triangle(x1, y1, x2, y2, x3, y3)
228
+ end
229
+ end
146
230
  end
147
231
  end
@@ -21,11 +21,12 @@ module DXRubyRP5
21
21
  else
22
22
  cond = lambda { |key| rp5_key_press?(key) }
23
23
  end
24
+ pad_val = rp5_pad_slider_value(:x)
24
25
 
25
- if cond.call(Processing::App::LEFT)
26
+ if cond.call(Processing::App::LEFT) || pad_val < 0
26
27
  res -= 1
27
28
  end
28
- if cond.call(Processing::App::RIGHT)
29
+ if cond.call(Processing::App::RIGHT) || pad_val > 0
29
30
  res += 1
30
31
  end
31
32
  return res
@@ -39,11 +40,12 @@ module DXRubyRP5
39
40
  else
40
41
  cond = lambda { |key| rp5_key_press?(key) }
41
42
  end
43
+ pad_val = rp5_pad_slider_value(:y)
42
44
 
43
- if cond.call(Processing::App::UP)
45
+ if cond.call(Processing::App::UP) || pad_val < 0
44
46
  res -= 1
45
47
  end
46
- if cond.call(Processing::App::DOWN)
48
+ if cond.call(Processing::App::DOWN) || pad_val > 0
47
49
  res += 1
48
50
  end
49
51
  return res
@@ -74,22 +76,22 @@ module DXRubyRP5
74
76
  end
75
77
 
76
78
  def mouse_down?(button)
77
- if @pressed_buttons
78
- return @pressed_buttons.include?(button)
79
+ if @pressed_mbuttons
80
+ return @pressed_mbuttons.include?(button)
79
81
  else
80
82
  return rp5_mouse_down?(button)
81
83
  end
82
84
  end
83
85
 
84
86
  def mouse_push?(button)
85
- if @pushed_buttons
86
- return @pushed_buttons.include?(button)
87
+ if @pushed_mbuttons
88
+ return @pushed_mbuttons.include?(button)
87
89
  else
88
90
  return rp5_mouse_down?(button)
89
91
  end
90
92
  end
91
93
 
92
- # TODO: support joystick
94
+ # TODO: support pad_number
93
95
  def pad_down?(button_code, pad_number = 0)
94
96
  if button_code == P_BUTTON0 && key_down?(K_Z) ||
95
97
  button_code == P_BUTTON1 && key_down?(K_X) ||
@@ -97,13 +99,14 @@ module DXRubyRP5
97
99
  button_code == P_LEFT && key_down?(K_LEFT) ||
98
100
  button_code == P_RIGHT && key_down?(K_RIGHT) ||
99
101
  button_code == P_UP && key_down?(K_UP) ||
100
- button_code == P_DOWN && key_down?(K_DOWN)
102
+ button_code == P_DOWN && key_down?(K_DOWN) ||
103
+ rp5_pad_pressed?(button_code)
101
104
  return true
102
105
  end
103
106
  return false
104
107
  end
105
108
 
106
- # TODO: support joystick
109
+ # TODO: support pad_number
107
110
  def pad_push?(button_code, pad_number = 0)
108
111
  if button_code == P_BUTTON0 && key_push?(K_Z) ||
109
112
  button_code == P_BUTTON1 && key_push?(K_X) ||
@@ -111,7 +114,8 @@ module DXRubyRP5
111
114
  button_code == P_LEFT && key_push?(K_LEFT) ||
112
115
  button_code == P_RIGHT && key_push?(K_RIGHT) ||
113
116
  button_code == P_UP && key_push?(K_UP) ||
114
- button_code == P_DOWN && key_push?(K_DOWN)
117
+ button_code == P_DOWN && key_push?(K_DOWN) ||
118
+ rp5_pad_pushed?(button_code)
115
119
  return true
116
120
  end
117
121
  return false
@@ -223,6 +227,21 @@ module DXRubyRP5
223
227
  return rp5_button == pressed_button
224
228
  end
225
229
 
230
+ def rp5_pad_slider_value(dir)
231
+ return 0 if !@pad_sliders
232
+ @pad_sliders[dir].value
233
+ end
234
+
235
+ def rp5_pad_pushed?(button_code)
236
+ @pushed_pbuttons ||= []
237
+ @pushed_pbuttons.include?(button_code)
238
+ end
239
+
240
+ def rp5_pad_pressed?(button_code)
241
+ @pressed_pbuttons ||= []
242
+ @pressed_pbuttons.include?(button_code)
243
+ end
244
+
226
245
  def to_rp5_key(key_code)
227
246
  return RP5_KEY_TABLE[key_code]
228
247
  end
@@ -274,27 +293,27 @@ module DXRubyRP5
274
293
  end
275
294
 
276
295
  def mouse_pressed(button)
277
- @pressed_buttons ||= []
296
+ @pressed_mbuttons ||= []
278
297
  rp5_button = JAVA_RP5_MBUTTON_TABLE[button]
279
298
  dbutton = to_dxruby_button(rp5_button)
280
- @pressed_buttons << dbutton
299
+ @pressed_mbuttons << dbutton
281
300
  end
282
301
 
283
302
  def mouse_pushed(button)
284
- @pushed_buttons ||= []
285
- @checked_buttons ||= []
303
+ @pushed_mbuttons ||= []
304
+ @checked_mbuttons ||= []
286
305
  rp5_button = JAVA_RP5_MBUTTON_TABLE[button]
287
306
  dbutton = to_dxruby_button(rp5_button)
288
- return if @checked_buttons.include?(dbutton)
289
- @pushed_buttons << dbutton
307
+ return if @checked_mbuttons.include?(dbutton)
308
+ @pushed_mbuttons << dbutton
290
309
  end
291
310
 
292
311
  def mouse_released(button)
293
- return if @pressed_buttons.nil?
312
+ return if @pressed_mbuttons.nil?
294
313
  rp5_button = JAVA_RP5_MBUTTON_TABLE[button]
295
314
  dbutton = to_dxruby_button(rp5_button)
296
- @pressed_buttons.delete(dbutton)
297
- @checked_buttons.delete(dbutton)
315
+ @pressed_mbuttons.delete(dbutton)
316
+ @checked_mbuttons.delete(dbutton)
298
317
  end
299
318
 
300
319
  def handle_key_events
@@ -310,10 +329,133 @@ module DXRubyRP5
310
329
  @checked_keys -= @pressed_keys
311
330
  end
312
331
 
313
- return if @pushed_buttons.nil?
314
- @checked_buttons = (@checked_buttons || @pushed_buttons)
315
- @pushed_buttons.clear
332
+ return if @pushed_mbuttons.nil?
333
+ @checked_mbuttons = (@checked_mbuttons || @pushed_mbuttons)
334
+ @pushed_mbuttons.clear
335
+ end
336
+
337
+ PSLIDER_DIRS = {
338
+ x: [DXRubyRP5.const_get(:P_RIGHT),
339
+ DXRubyRP5.const_get(:P_LEFT)],
340
+ y: [DXRubyRP5.const_get(:P_DOWN),
341
+ DXRubyRP5.const_get(:P_UP)],
342
+ }
343
+
344
+ def handle_pad_events
345
+ return if @pad_sliders.nil? || @pad_buttons.nil?
346
+ @pad_buttons.each do |key, button|
347
+ if button.pressed
348
+ pbutton_pressed(key)
349
+ else
350
+ pbutton_released(key)
351
+ end
352
+ end
353
+
354
+ @pad_sliders.each do |symbol, slider|
355
+ val = slider.value
356
+ if val > 0
357
+ pbutton_pressed(PSLIDER_DIRS[symbol][0])
358
+ elsif val < 0
359
+ pbutton_pressed(PSLIDER_DIRS[symbol][1])
360
+ else
361
+ pbutton_released(PSLIDER_DIRS[symbol][0])
362
+ pbutton_released(PSLIDER_DIRS[symbol][1])
363
+ end
364
+ end
365
+ end
366
+
367
+ def pbutton_pressed(key)
368
+ if @pushed_pbuttons.include?(key)
369
+ @pushed_pbuttons.delete(key)
370
+ else
371
+ if !@pressed_pbuttons.include?(key)
372
+ @pushed_pbuttons << key
373
+ @pressed_pbuttons << key
374
+ end
375
+ end
376
+ end
377
+
378
+ def pbutton_released(key)
379
+ @pushed_pbuttons.delete(key)
380
+ @pressed_pbuttons.delete(key)
381
+ end
382
+
383
+ def load_gcp_native_libraries
384
+ sketch_class = Processing::App.sketch_class
385
+ lib_loader = sketch_class.class_variable_get(:@@library_loader)
386
+ gcp_library_path =
387
+ lib_loader.send(:get_library_directory_path, "GameControlPlus")
388
+ java.lang.System.setProperty("java.library.path", gcp_library_path)
389
+ loader = java.lang.Class.for_name("java.lang.ClassLoader")
390
+ field = loader.get_declared_field("sys_paths")
391
+ if field
392
+ field.accessible = true
393
+ loader = java.lang.Class.for_name("java.lang.System").get_class_loader
394
+ field.set(loader, nil)
395
+ end
396
+ end
397
+
398
+ def setup_pad_input(device)
399
+ @pad_buttons = {}
400
+ @pad_sliders = {}
401
+ dummy_slider = Object.new
402
+ dummy_slider.instance_eval {|obj| def value; 0; end }
403
+ dummy_button = Object.new
404
+ dummy_button.instance_eval {|obj| def pressed; false; end }
405
+
406
+ # get sliders
407
+ [:x, :y].each do |name|
408
+ if device
409
+ device.get_number_of_sliders.times do |i|
410
+ slider = device.get_slider(i)
411
+ key = slider.name.to_sym
412
+ @pad_sliders[name] = slider if key == name
413
+ end
414
+ end
415
+ @pad_sliders[name] ||= dummy_slider
416
+ end
417
+
418
+ # get buttons
419
+ (0..15).each do |idx|
420
+ key = DXRubyRP5.const_get("P_BUTTON#{idx}")
421
+ begin
422
+ button = device ? device.get_button(idx) : dummy_button
423
+ rescue Java::JavaLang::IndexOutOfBoundsException => e
424
+ button = dummy_button
425
+ end
426
+ @pad_buttons[key] = button
427
+ end
428
+ @pushed_pbuttons = []
429
+ @pressed_pbuttons = []
430
+ end
431
+ end
432
+
433
+ # for gamepad/joystick
434
+ begin
435
+ device = nil
436
+ Processing::App.sketch_class.class_eval do
437
+ load_library :GameControlPlus
438
+ end
439
+ rescue LoadError => e
440
+ puts "WARN: Couldn't load library for gamepad/joystick"
441
+ puts "If you want to use gamepad or joystick, " \
442
+ "add 'GameControlPlus' library via PDE."
443
+ else
444
+ import "org.gamecontrolplus.ControlIO"
445
+ load_gcp_native_libraries
446
+ begin
447
+ list = ControlIO.get_instance($app).get_devices
448
+ device_types = [
449
+ Java::NetJavaGamesInput::Controller::Type::STICK,
450
+ Java::NetJavaGamesInput::Controller::Type::FINGERSTICK,
451
+ Java::NetJavaGamesInput::Controller::Type::GAMEPAD,
452
+ ].map(&:to_string)
453
+ device = list.find {|dev| device_types.include?(dev.get_type_name) }
454
+ device.open if device
455
+ rescue Java::JavaLang::NullPointerException
456
+ # cannot get devices when running spec
316
457
  end
317
458
  end
459
+ setup_pad_input(device)
318
460
  end
319
461
  end
@@ -4,7 +4,7 @@ module DXRubyRP5
4
4
  attr_reader :bgcolor
5
5
  attr_reader :_surface
6
6
 
7
- def initialize(width, height, _bgcolor = [0, 0, 0, 0])
7
+ def initialize(width, height, _bgcolor = [0, 255, 255, 255])
8
8
  _bgcolor = to_rp5_color(_bgcolor)
9
9
  @bgcolor = $app.color(*_bgcolor)
10
10
  @_surface = $app.create_graphics(width, height)
@@ -47,6 +47,41 @@ module DXRubyRP5
47
47
  @queue << draw_task
48
48
  end
49
49
 
50
+ def draw_font(x, y, string, font, hash = {})
51
+ if string.empty?
52
+ return
53
+ end
54
+ if hash[:color]
55
+ color = $app.color(*hash[:color])
56
+ else
57
+ color = $app.color(255)
58
+ end
59
+
60
+ proc = lambda do
61
+ @_surface.push_matrix
62
+ @_surface.text_size(font.size)
63
+ @_surface.text_font(font.native)
64
+ # DXRubyでは文字の配置指定はできないため、都度text_alignを指定
65
+ # せず固定で良いかもしれない
66
+ @_surface.text_align(Processing::App::LEFT, Processing::App::TOP)
67
+ @_surface.fill(color)
68
+ string.lines.each.with_index do |line, i|
69
+ line.chomp!
70
+ if line.empty?
71
+ next
72
+ end
73
+ @_surface.text(string, x, y)
74
+ end
75
+ @_surface.pop_matrix
76
+ end
77
+
78
+ draw_task = {
79
+ :proc => proc,
80
+ :z => hash[:z] || 0,
81
+ }
82
+ @queue << draw_task
83
+ end
84
+
50
85
  def draw_tile(basex, basey, map, image_arr, startx, starty, sizex, sizey, z = 0)
51
86
  image_arr = image_arr.flatten
52
87
  first_img = image_arr[0]
@@ -88,6 +123,9 @@ module DXRubyRP5
88
123
  end
89
124
  end
90
125
 
126
+ alias_method :drawFont, :draw_font
127
+ alias_method :drawTile, :draw_tile
128
+
91
129
  private
92
130
 
93
131
  def to_dxr_color(c)
@@ -1,10 +1,23 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  module DXRubyRP5
3
3
  class Sound
4
+ class << self
5
+ private
6
+
7
+ def minim
8
+ @minim ||= Java::DdfMinim::Minim.new($app)
9
+ end
10
+ end
11
+
4
12
  def initialize(filename)
13
+ @_sound = self.class.send(:minim).load_file(filename)
5
14
  end
6
15
 
7
16
  def play
17
+ # TODO: loop
18
+ @_sound.play
19
+ @_sound.rewind
20
+ return self
8
21
  end
9
22
 
10
23
  def set_volume(volume, time = 0)
@@ -1,4 +1,4 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  module DXRubyRP5
3
- VERSION = "0.0.3"
3
+ VERSION = "0.0.4"
4
4
  end
@@ -29,6 +29,14 @@ module DXRubyRP5
29
29
  $app.frame.set_title(val)
30
30
  end
31
31
 
32
+ def fps
33
+ $app.frame_rate
34
+ end
35
+
36
+ def fps=(val)
37
+ $app.frame_rate(val)
38
+ end
39
+
32
40
  def get_load
33
41
  # TODO:
34
42
  return 0
@@ -40,6 +48,7 @@ module DXRubyRP5
40
48
  block.call
41
49
  Window.send(:exec_draw_tasks)
42
50
  Input.send(:handle_key_events)
51
+ Input.send(:handle_pad_events)
43
52
  end
44
53
 
45
54
  Processing::App.sketch_class.class_eval { define_method(:draw, proc) }
@@ -100,8 +109,12 @@ module DXRubyRP5
100
109
  end
101
110
 
102
111
  proc = lambda do
112
+ $app.push_matrix
103
113
  $app.text_size(font.size)
104
114
  $app.text_font(font.native)
115
+ # DXRubyでは文字の配置指定はできないため、都度text_alignを指定
116
+ # せず固定で良いかもしれない
117
+ $app.text_align(Processing::App::LEFT, Processing::App::TOP)
105
118
  $app.fill(color)
106
119
  string.lines.each.with_index do |line, i|
107
120
  line.chomp!
@@ -110,6 +123,7 @@ module DXRubyRP5
110
123
  end
111
124
  $app.text(string, x, y)
112
125
  end
126
+ $app.pop_matrix
113
127
  end
114
128
 
115
129
  if @use_window_loop
@@ -118,6 +118,24 @@ describe DXRubyRP5::Image, '画像を表すクラス' do
118
118
  end
119
119
  end
120
120
 
121
+ # Sketch#run しないと内部で使用している #create_graphics がエラーにな
122
+ # るためテストできない
123
+ # TODO: テスト方法を見出す
124
+ describe '#line' do
125
+ let(:image) { described_class.new(2, 2) }
126
+ let(:color) { [255, 255, 255] }
127
+
128
+ subject { image.line(x1, y1, x2, y2, color) }
129
+ end
130
+
131
+ # 以下、同上
132
+ describe '#box' do; end
133
+ describe '#box_fill' do; end
134
+ describe '#circle' do; end
135
+ describe '#circle_fill' do; end
136
+ describe '#triangle' do; end
137
+ describe '#triangle_fill' do; end
138
+
121
139
  describe '#slice' do
122
140
  let(:image) { described_class.load(fixture_path('image.png')) }
123
141
 
@@ -63,7 +63,7 @@ describe DXRubyRP5::RenderTarget do
63
63
  context '色の指定をしない場合' do
64
64
  subject { described_class.new(width, height) }
65
65
 
66
- its(:bgcolor) { should eq([0, 0, 0, 0]) }
66
+ its(:bgcolor) { should eq([0, 255, 255, 255]) }
67
67
  end
68
68
 
69
69
  context '色の指定を RGB でする場合' do
@@ -4,15 +4,20 @@ require 'spec_helper'
4
4
  describe DXRubyRP5::Sound, '音を表すクラス' do
5
5
  describe '.new' do
6
6
  shared_context '.new' do
7
- subject { described_class.new(fixture_path(filename)) }
7
+ before(:each) do
8
+ m = Java::DdfMinim::Minim.new($app)
9
+ Java::DdfMinim::Minim.should_receive(:new).with($app).once.and_return(m)
10
+ end
11
+
12
+ subject { described_class.new(path) }
8
13
 
9
14
  it '呼び出すことができる' do
10
- subject
15
+ expect { subject }.to_not raise_error
11
16
  end
12
17
  end
13
18
 
14
19
  context 'WAVE形式のファイルの場合' do
15
- let(:filename) { 'sound.wav' }
20
+ let(:path) { fixture_path('sound.wav') }
16
21
 
17
22
  include_context '.new'
18
23
  end
@@ -25,26 +30,26 @@ describe DXRubyRP5::Sound, '音を表すクラス' do
25
30
  end
26
31
 
27
32
  describe '#play' do
28
- context 'WAVE形式のファイルの場合' do
29
- let(:path) { fixture_path('sound.wav') }
30
- let(:sound) { described_class.new(path) }
33
+ shared_context '#play' do
34
+ let(:sound) do
35
+ sound = described_class.new(path)
36
+ audio_player = sound.instance_variable_get(:@_sound)
37
+ audio_player.should_receive(:play).once
38
+ audio_player.should_receive(:rewind).once
39
+ sound
40
+ end
31
41
 
32
42
  subject { sound.play }
33
43
 
34
- it '呼び出すことができる' do
35
- subject
36
- end
44
+ it { should eq(sound) }
45
+ end
46
+
47
+ context 'WAVE形式のファイルの場合' do
48
+ let(:path) { fixture_path('sound.wav') }
37
49
  end
38
50
 
39
51
  # context 'MIDI形式のファイルの場合' do
40
52
  # let(:path) { fixture_path('bgm.mid') }
41
- # let(:sound) { DXRubySDL::Sound.new(path) }
42
- #
43
- # subject { sound.play }
44
- #
45
- # it '呼び出すことができる' do
46
- # subject
47
- # end
48
53
  # end
49
54
  end
50
55
  end
@@ -1,7 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
3
- require 'dxruby'
4
- require 'dxruby_rp5'
3
+ require 'ruby-processing'
5
4
 
6
5
  # redefine Processing::App#initialize so that dose not run sketch.
7
6
  class Processing::App
@@ -41,3 +40,6 @@ sketch_path = File.expand_path('fixtures/test_sketch.rb', File.dirname(__FILE__)
41
40
  require sketch_path
42
41
 
43
42
  Processing::App.const_set(:SKETCH_PATH, sketch_path)
43
+
44
+ require 'dxruby'
45
+ require 'dxruby_rp5'
metadata CHANGED
@@ -1,59 +1,59 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dxruby_rp5
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yuki Morohoshi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-24 00:00:00.000000000 Z
11
+ date: 2014-06-24 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: ruby-processing
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '2.4'
48
48
  type: :runtime
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: '2.4'
55
- description: '`dxruby-rp5` is a ruby library for 2D graphics and game. `dxruby-rp5`
56
- uses `ruby-processing` and has API same as DXRuby.'
55
+ description: "`dxruby-rp5` is a ruby library for 2D graphics and game. `dxruby-rp5`
56
+ uses `ruby-processing` and has API same as DXRuby."
57
57
  email:
58
58
  - hoshi.sanou@gmail.com
59
59
  executables:
@@ -61,8 +61,8 @@ executables:
61
61
  extensions: []
62
62
  extra_rdoc_files: []
63
63
  files:
64
- - .gitignore
65
- - .rspec
64
+ - ".gitignore"
65
+ - ".rspec"
66
66
  - Gemfile
67
67
  - LICENSE.txt
68
68
  - README.md
@@ -623,17 +623,17 @@ require_paths:
623
623
  - lib
624
624
  required_ruby_version: !ruby/object:Gem::Requirement
625
625
  requirements:
626
- - - '>='
626
+ - - ">="
627
627
  - !ruby/object:Gem::Version
628
628
  version: '0'
629
629
  required_rubygems_version: !ruby/object:Gem::Requirement
630
630
  requirements:
631
- - - '>='
631
+ - - ">="
632
632
  - !ruby/object:Gem::Version
633
633
  version: '0'
634
634
  requirements: []
635
635
  rubyforge_project:
636
- rubygems_version: 2.0.7
636
+ rubygems_version: 2.2.2
637
637
  signing_key:
638
638
  specification_version: 4
639
639
  summary: 2D graphics and game library