dxruby_sdl 0.0.13 → 0.0.14

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: a91ed61adae612429a4bd3b331a09f4b419b35ce
4
- data.tar.gz: 47cd99f97f46036c2f0a4ae7db7f827ccb04d48e
3
+ metadata.gz: abfa04925d04461b51b1c1d3bb737e31f785e766
4
+ data.tar.gz: e4c5e19a4272e8928f49ad42abb8bb06ef3cef35
5
5
  SHA512:
6
- metadata.gz: c6b23bb0f90551079f3967ed39a681a0709a3c9153dbcfb31ec2ece77cf038f029e1ba9d72092e69fe00b79e3a659f136c3efef057d16027735a1e6be3c48f1f
7
- data.tar.gz: a580c1e53bf13b832b503e17236a2b4ebe25fcf002079a271d0c38ce235df48e09a039ca9e3de6616c3d9a833d5ffe1ca49642da10781d08e743d49826935aa2
6
+ metadata.gz: d9630462d2db0faec4efa96f40a739f5c509465ee731dd6a90c2eaae57b546560528a2d776b086d9c3e1b3a38ab5d2d67c8c029dfe351095187e5b9b0dfb10f7
7
+ data.tar.gz: 3f01412b02aa5a3b90ee807fbd2f2d5448e4a7b03e6dda3974cafe82d3a60203f56d5389f02707dfb6a5232cd3a7ef76b53708d6140fe35aaec9a2ea3b4ec28e
@@ -9,4 +9,4 @@ env:
9
9
  before_install:
10
10
  - sudo apt-get update -qq
11
11
  - sudo apt-get install -qq libsdl1.2-dev libsdl-image1.2-dev libsdl-mixer1.2-dev timidity libsdl-ttf2.0-dev libsdl-sge-dev fonts-horai-umefont fonts-ipafont
12
-
12
+ - gem update bundler
data/README.md CHANGED
@@ -19,23 +19,41 @@ Current API compatibility status: http://dxruby-apis.herokuapp.com/en/
19
19
 
20
20
  (1) SDL
21
21
 
22
+ with MacPorts.
23
+
22
24
  ```
23
- (if you use MacPorts.)
24
25
  $ sudo port install libsdl libsdl_image libsdl_mixer libsdl_sound libsdl_ttf
25
26
  ```
26
27
 
28
+ with Homebrew
29
+
30
+ # update homebrew
31
+ $ brew update
32
+ $ brew upgrade
33
+ $ brew doctor
34
+
35
+ # install sdl etc.
36
+ $ brew install sdl
37
+ $ brew install sdl_image
38
+ $ brew install sdl_mixer
39
+ $ brew install sdl_ttf
40
+
27
41
  (2) SGE
28
42
 
43
+ $ curl -O http://www.digitalfanatics.org/cal/sge/files/sge030809.tar.gz
44
+ $ tar xvzf sge030809.tar.gz
45
+ $ cd sge030809
46
+ $ curl https://gist.github.com/steved555/963525/raw/7b638e4100f9dd1a9d00560b98ea2ddd4375b2b0/sge_030809_freetype.patch | patch
47
+ $ curl https://gist.github.com/steved555/963524/raw/c03396e1fb8bb87e9f4ba92597d087f730c6c48b/sge_030809_cmap.patch | patch
48
+ $ curl https://gist.github.com/steved555/963522/raw/5b277a0a6b08a1c077fbe2c96eead4ef1d761856/sge-030809-build.patch | patch
49
+ $ sed -i -e 's/-soname/-install_name/g' Makefile
50
+ $ make
51
+ $ sudo make install
52
+
53
+ with Homebrew
54
+
29
55
  ```
30
- $ curl -O http://www.digitalfanatics.org/cal/sge/files/sge030809.tar.gz
31
- $ tar xvzf sge030809.tar.gz
32
- $ cd sge030809
33
- $ curl https://gist.github.com/steved555/963525/raw/7b638e4100f9dd1a9d00560b98ea2ddd4375b2b0/sge_030809_freetype.patch | patch
34
- $ curl https://gist.github.com/steved555/963524/raw/c03396e1fb8bb87e9f4ba92597d087f730c6c48b/sge_030809_cmap.patch | patch
35
- $ curl https://gist.github.com/steved555/963522/raw/5b277a0a6b08a1c077fbe2c96eead4ef1d761856/sge-030809-build.patch | patch
36
- $ sed -i -e 's/-soname/-install_name/g' Makefile
37
- $ make
38
- $ sudo make install
56
+ $ brew install https://gist.githubusercontent.com/ymmtmdk/5b15f2b06aef5549eb5a/raw/ebf4c9758b1f772f0f6073e7b2bdbb5e9665ee74/libsge.rb
39
57
  ```
40
58
 
41
59
  (3) MS PGohic (DXRuby's default font)
@@ -19,8 +19,10 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ['lib']
20
20
 
21
21
  spec.add_development_dependency 'bundler', '~> 1.3'
22
- spec.add_development_dependency 'rake'
22
+ spec.add_development_dependency 'rake', '~> 10.4'
23
23
  spec.add_development_dependency 'rspec', '~> 2.14'
24
+ spec.add_development_dependency 'rspec-its'
25
+ spec.add_development_dependency 'rspec-collection_matchers'
24
26
  spec.add_development_dependency 'coveralls'
25
27
  spec.add_development_dependency 'travis-lint'
26
28
  spec.add_development_dependency 'rubocop', '0.15.0'
@@ -223,5 +223,6 @@ require 'dxruby_sdl/input'
223
223
  require 'dxruby_sdl/sound'
224
224
  require 'dxruby_sdl/sound_effect'
225
225
  require 'dxruby_sdl/sprite'
226
+ require 'dxruby_sdl/render_target'
226
227
 
227
228
  SDL.init(SDL::INIT_EVERYTHING)
@@ -39,6 +39,12 @@ module DXRubySDL
39
39
  @_surface =
40
40
  SDL::Surface.new(SDL::SWSURFACE, width, height, Window.send(:screen))
41
41
  @_surface.fill_rect(0, 0, width, height, @color)
42
+
43
+ # TODO: a値が0の時にしか対応していない。
44
+ # 1から254の値に対応すること
45
+ if color[3] == 0
46
+ set_color_key(@color[0..2])
47
+ end
42
48
  end
43
49
 
44
50
  def width
@@ -51,7 +57,6 @@ module DXRubySDL
51
57
 
52
58
  def set_color_key(color)
53
59
  @_surface.set_color_key(SDL::SRCCOLORKEY | SDL::RLEACCEL, color)
54
- @_surface = @_surface.display_format_alpha
55
60
  end
56
61
 
57
62
  def compare(x, y, color)
@@ -114,6 +119,10 @@ module DXRubySDL
114
119
  return self
115
120
  end
116
121
 
122
+ def draw(x, y, image, x1 = 0, y1 = 0, width = image.width, height = image.height)
123
+ SDL.blitSurface(image._surface, x1, y1, width, height, self._surface, x, y)
124
+ end
125
+
117
126
  def draw_font(x, y, string, font, color = [255, 255, 255])
118
127
  if string.empty?
119
128
  return
@@ -0,0 +1,25 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ require 'forwardable'
4
+
5
+ module DXRubySDL
6
+ class RenderTarget
7
+ extend Forwardable
8
+
9
+ attr_reader :_surface
10
+
11
+ def initialize(width, height, color)
12
+ @image = Image.new(width, height, color)
13
+ @_surface = @image._surface
14
+ end
15
+
16
+ def_delegators :@image, :draw
17
+
18
+ def draw_font(x, y, string, font, option = {})
19
+ color = option[:color] || [255, 255, 255]
20
+ @image.draw_font(x, y, string, font, color)
21
+ end
22
+
23
+ alias_method :drawFont, :draw_font
24
+ end
25
+ end
@@ -6,6 +6,17 @@ module DXRubySDL
6
6
  class Sound
7
7
  extend Forwardable
8
8
 
9
+ module Common
10
+ MAX_DXRUBY_VOLUME = 255
11
+ private_constant :MAX_DXRUBY_VOLUME
12
+ MAX_SDL_VOLUME = 128
13
+ private_constant :MAX_SDL_VOLUME
14
+
15
+ def dxruby_volume_to_sdl_volume(volume)
16
+ (volume * MAX_SDL_VOLUME.to_f / MAX_DXRUBY_VOLUME).round
17
+ end
18
+ end
19
+
9
20
  @sdl_mixer_openend = false
10
21
 
11
22
  def initialize(filename)
@@ -21,13 +32,15 @@ module DXRubySDL
21
32
  end
22
33
  end
23
34
 
24
- def_delegators :@sound, :play, :set_volume
35
+ def_delegators :@sound, :play, :set_volume, :stop
25
36
 
26
37
  alias_method :setVolume, :set_volume
27
38
 
28
39
  private
29
40
 
30
41
  class Music
42
+ include Common
43
+
31
44
  def initialize(filename)
32
45
  @music = SDL::Mixer::Music.load(filename)
33
46
  end
@@ -37,12 +50,20 @@ module DXRubySDL
37
50
  end
38
51
 
39
52
  def set_volume(volume, time = 0)
40
- raise NotImplementedError, 'Sound#set_volume(volume, time) with MIDI'
53
+ if time > 0
54
+ raise NotImplementedError, 'Sound#set_volume(volume, time != 0)'
55
+ end
56
+ @music.set_volume_music(dxruby_volume_to_sdl_volume(volume))
57
+ end
58
+
59
+ def stop
60
+ SDL::Mixer.halt_music
41
61
  end
42
62
  end
43
63
  private_constant :Music
44
64
 
45
65
  class Wave
66
+ include Common
46
67
  extend Forwardable
47
68
 
48
69
  def initialize(filename)
@@ -63,7 +84,11 @@ module DXRubySDL
63
84
  if time > 0
64
85
  raise NotImplementedError, 'Sound#set_volume(volume, time != 0)'
65
86
  end
66
- @wave.set_volume(volume)
87
+ @wave.set_volume(dxruby_volume_to_sdl_volume(volume))
88
+ end
89
+
90
+ def stop
91
+ SDL::Mixer.halt(@last_played_channel)
67
92
  end
68
93
  end
69
94
  private_constant :Wave
@@ -1,5 +1,5 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
3
  module DXRubySDL
4
- VERSION = '0.0.13'
4
+ VERSION = '0.0.14'
5
5
  end
@@ -74,6 +74,16 @@ module DXRubySDL
74
74
  screen.put(image._surface, x, y)
75
75
  end
76
76
 
77
+ def draw_scale(x, y, image, scalex, scaley, centerx = nil, centery = nil, z = 0)
78
+ opt = {
79
+ scale_x: scalex,
80
+ scale_y: scaley,
81
+ center_x: centerx,
82
+ center_y: centery,
83
+ }
84
+ draw_ex(x, y, image, opt)
85
+ end
86
+
77
87
  def draw_ex(x, y, image, hash = {})
78
88
  if hash[:z] && hash[:z] != 0
79
89
  raise NotImplementedError, 'Window.draw_ex(x, y, image, z: != 0)'
@@ -145,6 +155,7 @@ end run
145
155
  attr_writer :height
146
156
  attr_writer :scale
147
157
 
158
+ alias_method :drawScale, :draw_scale
148
159
  alias_method :drawEx, :draw_ex
149
160
  alias_method :drawFont, :draw_font
150
161
  alias_method :openFilename, :open_filename
@@ -196,6 +196,43 @@ describe DXRubySDL::Image, '画像を表すクラス' do
196
196
  end
197
197
  end
198
198
 
199
+ shared_context 'Source and Destination Images' do
200
+ let(:source_image) { DXRubySDL::Image.new(640, 480) }
201
+ let(:dest_image) { DXRubySDL::Image.new(640, 480) }
202
+ end
203
+
204
+ describe '#draw' do
205
+ context 'nothing argumet' do
206
+ include_context 'Source and Destination Images'
207
+
208
+ subject { source_image.draw(0, 0, dest_image) }
209
+
210
+ before do
211
+ allow(SDL).to receive(:blitSurface)
212
+ subject
213
+ end
214
+
215
+ describe SDL do
216
+ it { expect(SDL).to have_received(:blitSurface).with( dest_image._surface, 0, 0, dest_image.width, dest_image.height, source_image._surface, 0, 0).once }
217
+ end
218
+ end
219
+
220
+ context 'Specify argument' do
221
+ include_context 'Source and Destination Images'
222
+
223
+ subject { source_image.draw(0, 0, dest_image, 100, 200, 300, 400) }
224
+
225
+ before do
226
+ allow(SDL).to receive(:blitSurface)
227
+ subject
228
+ end
229
+
230
+ describe SDL do
231
+ it { expect(SDL).to have_received(:blitSurface).with(dest_image._surface, 100, 200, 300, 400, source_image._surface, 0, 0).once }
232
+ end
233
+ end
234
+ end
235
+
199
236
  shared_context '#draw_font' do
200
237
  let!(:font) { DXRubySDL::Font.new(32) }
201
238
  let(:args) { [0, 0, 'やあ', font] }
@@ -157,17 +157,17 @@ describe DXRubySDL::Input,
157
157
  j
158
158
  }
159
159
 
160
- it { should be_true }
160
+ it { should be true }
161
161
  end
162
162
 
163
163
  context "#{_key}キーが押されている場合" do
164
164
  let(:_keys) { [SDL::Key.const_get(_key)] }
165
165
 
166
- it { should be_true }
166
+ it { should be true }
167
167
  end
168
168
 
169
169
  context 'ボタンやキーが押されていない場合' do
170
- it { should be_false }
170
+ it { should be false }
171
171
  end
172
172
  end
173
173
  end
@@ -195,11 +195,11 @@ describe DXRubySDL::Input,
195
195
  context "#{_key}キーが押されている場合" do
196
196
  let(:_keys) { [SDL::Key.const_get(_key)] }
197
197
 
198
- it { should be_true }
198
+ it { should be true }
199
199
  end
200
200
 
201
201
  context 'ボタンやキーが押されていない場合' do
202
- it { should be_false }
202
+ it { should be false }
203
203
  end
204
204
  end
205
205
  end
@@ -258,17 +258,17 @@ describe DXRubySDL::Input,
258
258
  j
259
259
  }
260
260
 
261
- it { should be_true }
261
+ it { should be true }
262
262
  end
263
263
 
264
264
  context "#{_key}キーが押されている場合" do
265
265
  let(:_keys) { [SDL::Key.const_get(_key)] }
266
266
 
267
- it { should be_true }
267
+ it { should be true }
268
268
  end
269
269
 
270
270
  context 'ボタンやキーが押されていない場合' do
271
- it { should be_false }
271
+ it { should be false }
272
272
  end
273
273
  end
274
274
  end
@@ -296,11 +296,11 @@ describe DXRubySDL::Input,
296
296
  context "#{_key}キーが押されている場合" do
297
297
  let(:_keys) { [SDL::Key.const_get(_key)] }
298
298
 
299
- it { should be_true }
299
+ it { should be true }
300
300
  end
301
301
 
302
302
  context 'ボタンやキーが押されていない場合' do
303
- it { should be_false }
303
+ it { should be false }
304
304
  end
305
305
  end
306
306
  end
@@ -364,7 +364,7 @@ describe DXRubySDL::Input,
364
364
  let(:_keys) { [SDL::Key::ESCAPE] }
365
365
  let(:key_code) { DXRubySDL::K_ESCAPE }
366
366
 
367
- it { should be_true }
367
+ it { should be true }
368
368
  end
369
369
  end
370
370
 
@@ -391,7 +391,7 @@ describe DXRubySDL::Input,
391
391
  let(:_keys) { [SDL::Key::ESCAPE] }
392
392
  let(:key_code) { DXRubySDL::K_ESCAPE }
393
393
 
394
- it { should be_true }
394
+ it { should be true }
395
395
 
396
396
  context 'キーが押しっぱなしの場合' do
397
397
  before do
@@ -399,7 +399,7 @@ describe DXRubySDL::Input,
399
399
  down_keys.add(key_code)
400
400
  end
401
401
 
402
- it { should be_false }
402
+ it { should be false }
403
403
  end
404
404
 
405
405
  context 'キーが押しっぱなしだが、' \
@@ -410,11 +410,11 @@ describe DXRubySDL::Input,
410
410
  i = 0
411
411
  DXRubySDL::Window.loop do
412
412
  if first
413
- expect(described_class.send(method, key_code)).to be_true
413
+ expect(described_class.send(method, key_code)).to be true
414
414
  first = false
415
415
  else
416
416
  if i.even?
417
- expect(described_class.send(method, key_code)).to be_false
417
+ expect(described_class.send(method, key_code)).to be false
418
418
  end
419
419
  end
420
420
  i += 1
@@ -453,19 +453,19 @@ describe DXRubySDL::Input,
453
453
  describe 'マウスの左ボタン(M_LBUTTON)を指定する' do
454
454
  let(:button) { DXRubySDL::M_LBUTTON }
455
455
 
456
- it { should be_true }
456
+ it { should be true }
457
457
  end
458
458
 
459
459
  describe 'マウスの中ボタン(M_MBUTTON)を指定する' do
460
460
  let(:button) { DXRubySDL::M_MBUTTON }
461
461
 
462
- it { should be_false }
462
+ it { should be false }
463
463
  end
464
464
 
465
465
  describe 'マウスの右ボタン(M_RBUTTON)を指定する' do
466
466
  let(:button) { DXRubySDL::M_RBUTTON }
467
467
 
468
- it { should be_false }
468
+ it { should be false }
469
469
  end
470
470
  end
471
471
 
@@ -478,19 +478,19 @@ describe DXRubySDL::Input,
478
478
  describe 'マウスの左ボタン(M_LBUTTON)を指定する' do
479
479
  let(:button) { DXRubySDL::M_LBUTTON }
480
480
 
481
- it { should be_false }
481
+ it { should be false }
482
482
  end
483
483
 
484
484
  describe 'マウスの中ボタン(M_MBUTTON)を指定する' do
485
485
  let(:button) { DXRubySDL::M_MBUTTON }
486
486
 
487
- it { should be_true }
487
+ it { should be true }
488
488
  end
489
489
 
490
490
  describe 'マウスの右ボタン(M_RBUTTON)を指定する' do
491
491
  let(:button) { DXRubySDL::M_RBUTTON }
492
492
 
493
- it { should be_false }
493
+ it { should be false }
494
494
  end
495
495
  end
496
496
 
@@ -503,19 +503,19 @@ describe DXRubySDL::Input,
503
503
  describe 'マウスの左ボタン(M_LBUTTON)を指定する' do
504
504
  let(:button) { DXRubySDL::M_LBUTTON }
505
505
 
506
- it { should be_false }
506
+ it { should be false }
507
507
  end
508
508
 
509
509
  describe 'マウスの中ボタン(M_MBUTTON)を指定する' do
510
510
  let(:button) { DXRubySDL::M_MBUTTON }
511
511
 
512
- it { should be_false }
512
+ it { should be false }
513
513
  end
514
514
 
515
515
  describe 'マウスの右ボタン(M_RBUTTON)を指定する' do
516
516
  let(:button) { DXRubySDL::M_RBUTTON }
517
517
 
518
- it { should be_true }
518
+ it { should be true }
519
519
  end
520
520
  end
521
521
  end
@@ -550,19 +550,19 @@ describe DXRubySDL::Input,
550
550
  describe 'マウスの左ボタン(M_LBUTTON)を指定する' do
551
551
  let(:button) { DXRubySDL::M_LBUTTON }
552
552
 
553
- it { should be_true }
553
+ it { should be true }
554
554
  end
555
555
 
556
556
  describe 'マウスの中ボタン(M_MBUTTON)を指定する' do
557
557
  let(:button) { DXRubySDL::M_MBUTTON }
558
558
 
559
- it { should be_false }
559
+ it { should be false }
560
560
  end
561
561
 
562
562
  describe 'マウスの右ボタン(M_RBUTTON)を指定する' do
563
563
  let(:button) { DXRubySDL::M_RBUTTON }
564
564
 
565
- it { should be_false }
565
+ it { should be false }
566
566
  end
567
567
  end
568
568
 
@@ -575,19 +575,19 @@ describe DXRubySDL::Input,
575
575
  describe 'マウスの左ボタン(M_LBUTTON)を指定する' do
576
576
  let(:button) { DXRubySDL::M_LBUTTON }
577
577
 
578
- it { should be_false }
578
+ it { should be false }
579
579
  end
580
580
 
581
581
  describe 'マウスの中ボタン(M_MBUTTON)を指定する' do
582
582
  let(:button) { DXRubySDL::M_MBUTTON }
583
583
 
584
- it { should be_true }
584
+ it { should be true }
585
585
  end
586
586
 
587
587
  describe 'マウスの右ボタン(M_RBUTTON)を指定する' do
588
588
  let(:button) { DXRubySDL::M_RBUTTON }
589
589
 
590
- it { should be_false }
590
+ it { should be false }
591
591
  end
592
592
  end
593
593
 
@@ -600,19 +600,19 @@ describe DXRubySDL::Input,
600
600
  describe 'マウスの左ボタン(M_LBUTTON)を指定する' do
601
601
  let(:button) { DXRubySDL::M_LBUTTON }
602
602
 
603
- it { should be_false }
603
+ it { should be false }
604
604
  end
605
605
 
606
606
  describe 'マウスの中ボタン(M_MBUTTON)を指定する' do
607
607
  let(:button) { DXRubySDL::M_MBUTTON }
608
608
 
609
- it { should be_false }
609
+ it { should be false }
610
610
  end
611
611
 
612
612
  describe 'マウスの右ボタン(M_RBUTTON)を指定する' do
613
613
  let(:button) { DXRubySDL::M_RBUTTON }
614
614
 
615
- it { should be_true }
615
+ it { should be true }
616
616
  end
617
617
  end
618
618
  end
@@ -632,19 +632,19 @@ describe DXRubySDL::Input,
632
632
  describe 'マウスの左ボタン(M_LBUTTON)を指定する' do
633
633
  let(:button) { DXRubySDL::M_LBUTTON }
634
634
 
635
- it { should be_false }
635
+ it { should be false }
636
636
  end
637
637
 
638
638
  describe 'マウスの中ボタン(M_MBUTTON)を指定する' do
639
639
  let(:button) { DXRubySDL::M_MBUTTON }
640
640
 
641
- it { should be_false }
641
+ it { should be false }
642
642
  end
643
643
 
644
644
  describe 'マウスの右ボタン(M_RBUTTON)を指定する' do
645
645
  let(:button) { DXRubySDL::M_RBUTTON }
646
646
 
647
- it { should be_false }
647
+ it { should be false }
648
648
  end
649
649
  end
650
650
 
@@ -657,19 +657,19 @@ describe DXRubySDL::Input,
657
657
  describe 'マウスの左ボタン(M_LBUTTON)を指定する' do
658
658
  let(:button) { DXRubySDL::M_LBUTTON }
659
659
 
660
- it { should be_false }
660
+ it { should be false }
661
661
  end
662
662
 
663
663
  describe 'マウスの中ボタン(M_MBUTTON)を指定する' do
664
664
  let(:button) { DXRubySDL::M_MBUTTON }
665
665
 
666
- it { should be_false }
666
+ it { should be false }
667
667
  end
668
668
 
669
669
  describe 'マウスの右ボタン(M_RBUTTON)を指定する' do
670
670
  let(:button) { DXRubySDL::M_RBUTTON }
671
671
 
672
- it { should be_false }
672
+ it { should be false }
673
673
  end
674
674
  end
675
675
 
@@ -682,19 +682,19 @@ describe DXRubySDL::Input,
682
682
  describe 'マウスの左ボタン(M_LBUTTON)を指定する' do
683
683
  let(:button) { DXRubySDL::M_LBUTTON }
684
684
 
685
- it { should be_false }
685
+ it { should be false }
686
686
  end
687
687
 
688
688
  describe 'マウスの中ボタン(M_MBUTTON)を指定する' do
689
689
  let(:button) { DXRubySDL::M_MBUTTON }
690
690
 
691
- it { should be_false }
691
+ it { should be false }
692
692
  end
693
693
 
694
694
  describe 'マウスの右ボタン(M_RBUTTON)を指定する' do
695
695
  let(:button) { DXRubySDL::M_RBUTTON }
696
696
 
697
- it { should be_false }
697
+ it { should be false }
698
698
  end
699
699
  end
700
700
  end
@@ -2,6 +2,16 @@
2
2
  require 'spec_helper'
3
3
 
4
4
  describe DXRubySDL::Sound, '音を表すクラス' do
5
+ shared_context 'WAVE file', wave: true do
6
+ let(:path) { fixture_path('sound.wav') }
7
+ let(:sound) { DXRubySDL::Sound.new(path) }
8
+ end
9
+
10
+ shared_context 'MIDI file', midi: true do
11
+ let(:path) { fixture_path('bgm.mid') }
12
+ let(:sound) { DXRubySDL::Sound.new(path) }
13
+ end
14
+
5
15
  describe '.new' do
6
16
  shared_context '.new' do
7
17
  subject { DXRubySDL::Sound.new(fixture_path(filename)) }
@@ -25,10 +35,7 @@ describe DXRubySDL::Sound, '音を表すクラス' do
25
35
  end
26
36
 
27
37
  describe '#play' do
28
- context 'WAVE形式のファイルの場合' do
29
- let(:path) { fixture_path('sound.wav') }
30
- let(:sound) { DXRubySDL::Sound.new(path) }
31
-
38
+ context 'WAVE file', wave: true do
32
39
  subject { sound.play }
33
40
 
34
41
  it 'SDL::Mixer.play_channelを呼び出す' do
@@ -62,10 +69,7 @@ describe DXRubySDL::Sound, '音を表すクラス' do
62
69
  end
63
70
  end
64
71
 
65
- context 'MIDI形式のファイルの場合' do
66
- let(:path) { fixture_path('bgm.mid') }
67
- let(:sound) { DXRubySDL::Sound.new(path) }
68
-
72
+ context 'MIDI file', midi: true do
69
73
  subject { sound.play }
70
74
 
71
75
  it 'SDL::Mixer.play_musicを呼び出す' do
@@ -76,4 +80,40 @@ describe DXRubySDL::Sound, '音を表すクラス' do
76
80
  end
77
81
  end
78
82
  end
83
+
84
+ describe '#stop' do
85
+ context 'WAVE file', wave: true do
86
+ let(:path) { fixture_path('sound.wav') }
87
+ let(:sound) { DXRubySDL::Sound.new(path) }
88
+
89
+ subject { sound.stop }
90
+
91
+ before do
92
+ allow(SDL::Mixer).to receive(:halt)
93
+ sound.play
94
+ subject
95
+ end
96
+
97
+ describe SDL::Mixer do
98
+ it { expect(SDL::Mixer).to have_received(:halt).with(0).once }
99
+ end
100
+ end
101
+
102
+ context 'MIDI file', midi: true do
103
+ let(:path) { fixture_path('bgm.mid') }
104
+ let(:sound) { DXRubySDL::Sound.new(path) }
105
+
106
+ subject { sound.stop }
107
+
108
+ before do
109
+ allow(SDL::Mixer).to receive(:halt_music)
110
+ sound.play
111
+ subject
112
+ end
113
+
114
+ describe SDL::Mixer do
115
+ it { expect(SDL::Mixer).to have_received(:halt_music).with(no_args).once }
116
+ end
117
+ end
118
+ end
79
119
  end
@@ -47,9 +47,9 @@ describe DXRubySDL::Sprite, 'ゲームのキャラを扱う場合の基本とな
47
47
  shared_examples 'return' do |val|
48
48
  describe '戻り値' do
49
49
  if val
50
- it { should be_true }
50
+ it { should be true }
51
51
  else
52
- it { should be_false }
52
+ it { should be false }
53
53
  end
54
54
  end
55
55
  end
@@ -541,7 +541,7 @@ describe DXRubySDL::Sprite, 'ゲームのキャラを扱う場合の基本とな
541
541
  subject { sprite }
542
542
 
543
543
  context '呼び出す前' do
544
- its(:vanished?) { should be_false }
544
+ its(:vanished?) { should be false }
545
545
  end
546
546
 
547
547
  context '呼び出した後' do
@@ -549,7 +549,7 @@ describe DXRubySDL::Sprite, 'ゲームのキャラを扱う場合の基本とな
549
549
  sprite.vanish
550
550
  end
551
551
 
552
- its(:vanished?) { should be_true }
552
+ its(:vanished?) { should be true }
553
553
  end
554
554
  end
555
555
  end
@@ -558,13 +558,13 @@ describe DXRubySDL::Sprite, 'ゲームのキャラを扱う場合の基本とな
558
558
  subject { sprite.vanished? }
559
559
 
560
560
  context 'Spriteが有効な場合' do
561
- it { should be_false }
561
+ it { should be false }
562
562
  end
563
563
 
564
564
  context 'vanishを呼び出してSpriteを無効化している場合' do
565
565
  before { sprite.vanish }
566
566
 
567
- it { should be_true }
567
+ it { should be true }
568
568
  end
569
569
  end
570
570
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dxruby_sdl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.13
4
+ version: 0.0.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kouji Takao
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-15 00:00:00.000000000 Z
11
+ date: 2016-03-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -28,16 +28,16 @@ dependencies:
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: '10.4'
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
- version: '0'
40
+ version: '10.4'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -52,6 +52,34 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '2.14'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec-its
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec-collection_matchers
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
55
83
  - !ruby/object:Gem::Dependency
56
84
  name: coveralls
57
85
  requirement: !ruby/object:Gem::Requirement
@@ -176,6 +204,7 @@ files:
176
204
  - lib/dxruby_sdl/font.rb
177
205
  - lib/dxruby_sdl/image.rb
178
206
  - lib/dxruby_sdl/input.rb
207
+ - lib/dxruby_sdl/render_target.rb
179
208
  - lib/dxruby_sdl/sound.rb
180
209
  - lib/dxruby_sdl/sound_effect.rb
181
210
  - lib/dxruby_sdl/sprite.rb