rubysketch 0.5.18 → 0.5.20
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog.md +10 -0
- data/VERSION +1 -1
- data/lib/rubysketch/all.rb +1 -0
- data/lib/rubysketch/context.rb +11 -0
- data/lib/rubysketch/sound.rb +57 -0
- data/lib/rubysketch/sprite.rb +13 -13
- data/rubysketch.gemspec +3 -3
- data/test/test_sound.rb +33 -0
- metadata +11 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: de696798b30cb2b3545e2b2c44aeda9ca5df2658e7026392f20ba9cf9bf85570
|
4
|
+
data.tar.gz: a7a93a821db3bb44dac6c656d23ae246f696b09ce4d2b2c2eacd797d44664659
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4c4f5662bd7ad50e429dc5de1e91de19fe73be52de3f48addefa6b67007218f9dd9bad033603cf89a2bf08b092d8b424116abc0cb8a1ac4e0d6a9428b7eaa124
|
7
|
+
data.tar.gz: 4b2e98ed91f9eff96170fcd79f1bfac8323c341e7c10ffa65f060be7d04645f8bf41502608dc2d7914f5a5a968f6ec4a9959db5af57cd2217d862468e1ad01b2
|
data/ChangeLog.md
CHANGED
@@ -1,6 +1,16 @@
|
|
1
1
|
# rubysketch ChangeLog
|
2
2
|
|
3
3
|
|
4
|
+
## [v0.5.20] - 2023-07-09
|
5
|
+
|
6
|
+
- fix that calling mousePressed() without block removes mousePressed block
|
7
|
+
|
8
|
+
|
9
|
+
## [v0.5.19] - 2023-06-27
|
10
|
+
|
11
|
+
- add loadSound() and RubySketch::Sound class
|
12
|
+
|
13
|
+
|
4
14
|
## [v0.5.18] - 2023-06-22
|
5
15
|
|
6
16
|
- Update dependencies
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.20
|
data/lib/rubysketch/all.rb
CHANGED
data/lib/rubysketch/context.rb
CHANGED
@@ -4,6 +4,7 @@ module RubySketch
|
|
4
4
|
class Context < Processing::Context
|
5
5
|
|
6
6
|
Sprite = RubySketch::Sprite
|
7
|
+
Sound = RubySketch::Sound
|
7
8
|
|
8
9
|
# @private
|
9
10
|
def initialize(window)
|
@@ -112,6 +113,16 @@ module RubySketch
|
|
112
113
|
end
|
113
114
|
end
|
114
115
|
|
116
|
+
# Loads sound file.
|
117
|
+
#
|
118
|
+
# @param [String] path path for sound file
|
119
|
+
#
|
120
|
+
# @return [Sound] sound object
|
121
|
+
#
|
122
|
+
def loadSound(path)
|
123
|
+
Sound.load path
|
124
|
+
end
|
125
|
+
|
115
126
|
# Sets gravity for the physics engine.
|
116
127
|
#
|
117
128
|
# @overload gravity(vec)
|
@@ -0,0 +1,57 @@
|
|
1
|
+
module RubySketch
|
2
|
+
|
3
|
+
|
4
|
+
# Sound object.
|
5
|
+
#
|
6
|
+
class Sound
|
7
|
+
|
8
|
+
# @private
|
9
|
+
def initialize(sound)
|
10
|
+
@sound = sound
|
11
|
+
@players = []
|
12
|
+
end
|
13
|
+
|
14
|
+
# Play sound.
|
15
|
+
#
|
16
|
+
# @param [Numeric] gain volume for playing sound
|
17
|
+
#
|
18
|
+
# @return [nil] nil
|
19
|
+
#
|
20
|
+
def play(gain: 1.0)
|
21
|
+
clean_stopped_players
|
22
|
+
@players.push @sound.play(gain: gain)
|
23
|
+
nil
|
24
|
+
end
|
25
|
+
|
26
|
+
# Stop playing sounds.
|
27
|
+
#
|
28
|
+
# @return [nil] nil
|
29
|
+
#
|
30
|
+
def stop()
|
31
|
+
@players.each &:stop
|
32
|
+
@players.clear
|
33
|
+
nil
|
34
|
+
end
|
35
|
+
|
36
|
+
# Load a sound file.
|
37
|
+
#
|
38
|
+
# @param [String] path file path
|
39
|
+
#
|
40
|
+
# @return [Sound] sound object
|
41
|
+
#
|
42
|
+
def self.load(path)
|
43
|
+
f = Beeps::FileIn.new path
|
44
|
+
self.new Beeps::Sound.new(f, f.seconds, nchannels: f.nchannels)
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
|
49
|
+
# @private
|
50
|
+
def clean_stopped_players()
|
51
|
+
@players.delete_if {|p| not p.playing?}
|
52
|
+
end
|
53
|
+
|
54
|
+
end# Sound
|
55
|
+
|
56
|
+
|
57
|
+
end# RubySketch
|
data/lib/rubysketch/sprite.rb
CHANGED
@@ -699,7 +699,7 @@ module RubySketch
|
|
699
699
|
# @return [nil] nil
|
700
700
|
#
|
701
701
|
def update(&block)
|
702
|
-
@view__.update = block
|
702
|
+
@view__.update = block if block
|
703
703
|
nil
|
704
704
|
end
|
705
705
|
|
@@ -715,7 +715,7 @@ module RubySketch
|
|
715
715
|
# @return [nil] nil
|
716
716
|
#
|
717
717
|
def draw(&block)
|
718
|
-
@drawBlock__ = block
|
718
|
+
@drawBlock__ = block if block
|
719
719
|
nil
|
720
720
|
end
|
721
721
|
|
@@ -729,7 +729,7 @@ module RubySketch
|
|
729
729
|
# @return [Boolean] is any mouse button pressed or not
|
730
730
|
#
|
731
731
|
def mousePressed(&block)
|
732
|
-
@view__.mousePressed = block
|
732
|
+
@view__.mousePressed = block if block
|
733
733
|
@view__.mousePressed?
|
734
734
|
end
|
735
735
|
|
@@ -743,7 +743,7 @@ module RubySketch
|
|
743
743
|
# @return [nil] nil
|
744
744
|
#
|
745
745
|
def mouseReleased(&block)
|
746
|
-
@view__.mouseReleased = block
|
746
|
+
@view__.mouseReleased = block if block
|
747
747
|
nil
|
748
748
|
end
|
749
749
|
|
@@ -757,7 +757,7 @@ module RubySketch
|
|
757
757
|
# @return [nil] nil
|
758
758
|
#
|
759
759
|
def mouseMoved(&block)
|
760
|
-
@view__.mouseMoved = block
|
760
|
+
@view__.mouseMoved = block if block
|
761
761
|
nil
|
762
762
|
end
|
763
763
|
|
@@ -771,7 +771,7 @@ module RubySketch
|
|
771
771
|
# @return [nil] nil
|
772
772
|
#
|
773
773
|
def mouseDragged(&block)
|
774
|
-
@view__.mouseDragged = block
|
774
|
+
@view__.mouseDragged = block if block
|
775
775
|
nil
|
776
776
|
end
|
777
777
|
|
@@ -785,7 +785,7 @@ module RubySketch
|
|
785
785
|
# @return [nil] nil
|
786
786
|
#
|
787
787
|
def mouseClicked(&block)
|
788
|
-
@view__.mouseClicked = block
|
788
|
+
@view__.mouseClicked = block if block
|
789
789
|
nil
|
790
790
|
end
|
791
791
|
|
@@ -799,7 +799,7 @@ module RubySketch
|
|
799
799
|
# @return [nil] nil
|
800
800
|
#
|
801
801
|
def touchStarted(&block)
|
802
|
-
@view__.touchStarted = block
|
802
|
+
@view__.touchStarted = block if block
|
803
803
|
nil
|
804
804
|
end
|
805
805
|
|
@@ -813,7 +813,7 @@ module RubySketch
|
|
813
813
|
# @return [nil] nil
|
814
814
|
#
|
815
815
|
def touchEnded(&block)
|
816
|
-
@view__.touchEnded = block
|
816
|
+
@view__.touchEnded = block if block
|
817
817
|
nil
|
818
818
|
end
|
819
819
|
|
@@ -827,7 +827,7 @@ module RubySketch
|
|
827
827
|
# @return [nil] nil
|
828
828
|
#
|
829
829
|
def touchMoved(&block)
|
830
|
-
@view__.touchMoved = block
|
830
|
+
@view__.touchMoved = block if block
|
831
831
|
nil
|
832
832
|
end
|
833
833
|
|
@@ -841,7 +841,7 @@ module RubySketch
|
|
841
841
|
# @return [nil] nil
|
842
842
|
#
|
843
843
|
def contact(&block)
|
844
|
-
@view__.contact = block
|
844
|
+
@view__.contact = block if block
|
845
845
|
end
|
846
846
|
|
847
847
|
# Defines contact? block.
|
@@ -854,7 +854,7 @@ module RubySketch
|
|
854
854
|
# @return [nil] nil
|
855
855
|
#
|
856
856
|
def contact?(&block)
|
857
|
-
@view__.will_contact = block
|
857
|
+
@view__.will_contact = block if block
|
858
858
|
end
|
859
859
|
|
860
860
|
# @private
|
@@ -978,7 +978,7 @@ module RubySketch
|
|
978
978
|
if !mousePressed? || pointer.id == @pointer&.id
|
979
979
|
@pointerPrev, @pointer = @pointer, pointer.dup
|
980
980
|
end
|
981
|
-
@touches = event.map {|p| Touch.new(p.id, *p.pos.to_a)}
|
981
|
+
@touches = event.map {|p| Processing::Touch.new(p.id, *p.pos.to_a)}
|
982
982
|
end
|
983
983
|
|
984
984
|
def updatePointersPressedAndReleased(event, pressed)
|
data/rubysketch.gemspec
CHANGED
@@ -27,10 +27,10 @@ Gem::Specification.new do |s|
|
|
27
27
|
|
28
28
|
s.add_runtime_dependency 'xot', '~> 0.1.39'
|
29
29
|
s.add_runtime_dependency 'rucy', '~> 0.1.39'
|
30
|
-
s.add_runtime_dependency 'beeps', '~> 0.1.
|
30
|
+
s.add_runtime_dependency 'beeps', '~> 0.1.41'
|
31
31
|
s.add_runtime_dependency 'rays', '~> 0.1.43'
|
32
|
-
s.add_runtime_dependency 'reflexion', '~> 0.1.
|
33
|
-
s.add_runtime_dependency 'processing', '~> 0.5.
|
32
|
+
s.add_runtime_dependency 'reflexion', '~> 0.1.47'
|
33
|
+
s.add_runtime_dependency 'processing', '~> 0.5.21'
|
34
34
|
|
35
35
|
s.add_development_dependency 'rake'
|
36
36
|
s.add_development_dependency 'test-unit'
|
data/test/test_sound.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
|
4
|
+
require_relative 'helper'
|
5
|
+
|
6
|
+
|
7
|
+
class TestSound < Test::Unit::TestCase
|
8
|
+
|
9
|
+
RS = RubySketch
|
10
|
+
B = Beeps
|
11
|
+
|
12
|
+
PATH = 'test.wav'
|
13
|
+
|
14
|
+
def sound()
|
15
|
+
RS::Sound.load PATH
|
16
|
+
end
|
17
|
+
|
18
|
+
def setup()
|
19
|
+
B::Sound.new(B::Oscillator.new >> B::Gain.new(gain: 0), 0.1).save PATH
|
20
|
+
end
|
21
|
+
|
22
|
+
def teardown()
|
23
|
+
B::SoundPlayer.stop_all
|
24
|
+
File.delete PATH if File.exist?(PATH)
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_play_stop()
|
28
|
+
s = sound
|
29
|
+
assert_nothing_raised {s.play}
|
30
|
+
assert_nothing_raised {s.stop}
|
31
|
+
end
|
32
|
+
|
33
|
+
end# TestSound
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubysketch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.20
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- xordog
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-07-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: xot
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0.1.
|
47
|
+
version: 0.1.41
|
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
|
-
version: 0.1.
|
54
|
+
version: 0.1.41
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rays
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -72,28 +72,28 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 0.1.
|
75
|
+
version: 0.1.47
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 0.1.
|
82
|
+
version: 0.1.47
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: processing
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: 0.5.
|
89
|
+
version: 0.5.21
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: 0.5.
|
96
|
+
version: 0.5.21
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: rake
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -163,6 +163,7 @@ files:
|
|
163
163
|
- lib/rubysketch/context.rb
|
164
164
|
- lib/rubysketch/extension.rb
|
165
165
|
- lib/rubysketch/helper.rb
|
166
|
+
- lib/rubysketch/sound.rb
|
166
167
|
- lib/rubysketch/sprite.rb
|
167
168
|
- lib/rubysketch/window.rb
|
168
169
|
- pod.rake
|
@@ -170,6 +171,7 @@ files:
|
|
170
171
|
- src/RubySketch.h
|
171
172
|
- src/RubySketch.mm
|
172
173
|
- test/helper.rb
|
174
|
+
- test/test_sound.rb
|
173
175
|
- test/test_sprite.rb
|
174
176
|
homepage: https://github.com/xord/rubysketch
|
175
177
|
licenses:
|
@@ -196,4 +198,5 @@ specification_version: 4
|
|
196
198
|
summary: A game engine based on the Processing API.
|
197
199
|
test_files:
|
198
200
|
- test/helper.rb
|
201
|
+
- test/test_sound.rb
|
199
202
|
- test/test_sprite.rb
|