rubysketch 0.5.27 → 0.5.30
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog.md +26 -9
- data/VERSION +1 -1
- data/lib/rubysketch/context.rb +1 -1
- data/lib/rubysketch/sprite.rb +32 -7
- data/rubysketch.gemspec +2 -2
- data/test/test_sprite.rb +10 -0
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dbbb972756576a0aa6c5dfc70ba1682776dd0f95c1bc0d0ec20a06dce0e1bd01
|
4
|
+
data.tar.gz: 7ce985bbaee1c81f3b20dea0392cd2b5459af3e520eb8552840306d32ba03adb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f0f53b5fb3464b8cc6e0f9ff3b3c4d76d465816a5c6414b99a3d5724ca9c20411c37091f8a2b9ed850e05b863c8ef958ed7dceaf8257189dbdb1df125033d7fa
|
7
|
+
data.tar.gz: 1e9696d6e23b5333f4c784abd7847fd2ebb00e4dd210945c4f92b251eed80f7485cc1694fd1d09003c9a7cfe9e8ff1a95275cca6cb928d53814c65cdeb184781
|
data/ChangeLog.md
CHANGED
@@ -1,9 +1,26 @@
|
|
1
1
|
# rubysketch ChangeLog
|
2
2
|
|
3
3
|
|
4
|
+
## [v0.5.30] - 2023-08-24
|
5
|
+
|
6
|
+
- Fix failed test
|
7
|
+
|
8
|
+
|
9
|
+
## [v0.5.29] - 2023-08-23
|
10
|
+
|
11
|
+
- Add Sprite#contact_end()
|
12
|
+
- Sprite.new() can take 'physics:' keyword parameter
|
13
|
+
- Fix that calling clearInterval() inside interval timer block would be ignored
|
14
|
+
|
15
|
+
|
16
|
+
## [v0.5.28] - 2023-07-30
|
17
|
+
|
18
|
+
- Update dependencies
|
19
|
+
|
20
|
+
|
4
21
|
## [v0.5.27] - 2023-07-30
|
5
22
|
|
6
|
-
-
|
23
|
+
- Add vibrate()
|
7
24
|
|
8
25
|
|
9
26
|
## [v0.5.26] - 2023-07-26
|
@@ -41,12 +58,12 @@
|
|
41
58
|
|
42
59
|
## [v0.5.20] - 2023-07-09
|
43
60
|
|
44
|
-
-
|
61
|
+
- Fix that calling mousePressed() without block removes mousePressed block
|
45
62
|
|
46
63
|
|
47
64
|
## [v0.5.19] - 2023-06-27
|
48
65
|
|
49
|
-
-
|
66
|
+
- Add loadSound() and RubySketch::Sound class
|
50
67
|
|
51
68
|
|
52
69
|
## [v0.5.18] - 2023-06-22
|
@@ -88,8 +105,8 @@
|
|
88
105
|
|
89
106
|
## [v0.5.11] - 2023-05-26
|
90
107
|
|
91
|
-
-
|
92
|
-
-
|
108
|
+
- Add left, top, right, and bottom accessors to Sprite class
|
109
|
+
- Add show(), hide(), and hidden?() to Sprite class
|
93
110
|
|
94
111
|
|
95
112
|
## [v0.5.10] - 2023-05-21
|
@@ -156,19 +173,19 @@
|
|
156
173
|
|
157
174
|
## [v0.5.2] - 2023-03-02
|
158
175
|
|
159
|
-
-
|
176
|
+
- Depend to processing-0.5.2 gem
|
160
177
|
|
161
178
|
|
162
179
|
## [v0.5.1] - 2023-03-01
|
163
180
|
|
164
|
-
-
|
181
|
+
- Fix bugs
|
165
182
|
|
166
183
|
|
167
184
|
## [v0.5.0] - 2023-02-09
|
168
185
|
|
169
|
-
-
|
186
|
+
- Add Sprite class
|
170
187
|
|
171
188
|
|
172
189
|
## [v0.4.0] - 2023-02-08
|
173
190
|
|
174
|
-
-
|
191
|
+
- First version
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.30
|
data/lib/rubysketch/context.rb
CHANGED
data/lib/rubysketch/sprite.rb
CHANGED
@@ -37,7 +37,7 @@ module RubySketch
|
|
37
37
|
#
|
38
38
|
def initialize(
|
39
39
|
x = 0, y = 0, w = nil, h = nil, image: nil, offset: nil,
|
40
|
-
context: nil)
|
40
|
+
physics: true, context: nil)
|
41
41
|
|
42
42
|
w ||= (image&.width || 0)
|
43
43
|
h ||= (image&.height || 0)
|
@@ -47,7 +47,7 @@ module RubySketch
|
|
47
47
|
@context__ = context || Context.context__
|
48
48
|
@view__ = SpriteView.new(
|
49
49
|
self, x: x, y: y, w: w, h: h,
|
50
|
-
|
50
|
+
physics: physics, density: 1, friction: 0, restitution: 0,
|
51
51
|
back: :white)
|
52
52
|
|
53
53
|
self.image = image if image
|
@@ -842,6 +842,21 @@ module RubySketch
|
|
842
842
|
#
|
843
843
|
def contact(&block)
|
844
844
|
@view__.contact = block if block
|
845
|
+
nil
|
846
|
+
end
|
847
|
+
|
848
|
+
# Defines contact_end block.
|
849
|
+
#
|
850
|
+
# @example Call jumping() when the player sprite leaves the ground sprite
|
851
|
+
# playerSprite.contact_end do |o|
|
852
|
+
# jumping if o == groundSprite
|
853
|
+
# end
|
854
|
+
#
|
855
|
+
# @return [nil] nil
|
856
|
+
#
|
857
|
+
def contact_end(&block)
|
858
|
+
@view__.contact_end = block if block
|
859
|
+
nil
|
845
860
|
end
|
846
861
|
|
847
862
|
# Defines contact? block.
|
@@ -855,6 +870,7 @@ module RubySketch
|
|
855
870
|
#
|
856
871
|
def contact?(&block)
|
857
872
|
@view__.will_contact = block if block
|
873
|
+
nil
|
858
874
|
end
|
859
875
|
|
860
876
|
# @private
|
@@ -871,13 +887,13 @@ module RubySketch
|
|
871
887
|
attr_accessor :update,
|
872
888
|
:mousePressed, :mouseReleased, :mouseMoved, :mouseDragged, :mouseClicked,
|
873
889
|
:touchStarted, :touchEnded, :touchMoved,
|
874
|
-
:contact, :will_contact
|
890
|
+
:contact, :contact_end, :will_contact
|
875
891
|
|
876
892
|
attr_reader :sprite, :touches
|
877
893
|
|
878
|
-
def initialize(sprite, *
|
894
|
+
def initialize(sprite, *args, physics:, **kwargs, &block)
|
879
895
|
@sprite = sprite
|
880
|
-
super(*
|
896
|
+
super(*args, **kwargs, &block)
|
881
897
|
|
882
898
|
@error = nil
|
883
899
|
@pointer = nil
|
@@ -885,6 +901,8 @@ module RubySketch
|
|
885
901
|
@pointersPressed = []
|
886
902
|
@pointersReleased = []
|
887
903
|
@touches = []
|
904
|
+
|
905
|
+
self.static = true if physics
|
888
906
|
end
|
889
907
|
|
890
908
|
def mouseX()
|
@@ -957,8 +975,15 @@ module RubySketch
|
|
957
975
|
end
|
958
976
|
|
959
977
|
def on_contact_begin(e)
|
978
|
+
return unless @contact
|
979
|
+
v = e.view
|
980
|
+
call_block @contact, v.sprite if v.respond_to?(:sprite)
|
981
|
+
end
|
982
|
+
|
983
|
+
def on_contact_end(e)
|
984
|
+
return unless @contact_end
|
960
985
|
v = e.view
|
961
|
-
call_block @
|
986
|
+
call_block @contact_end, v.sprite if v.respond_to?(:sprite)
|
962
987
|
end
|
963
988
|
|
964
989
|
def will_contact?(v)
|
@@ -997,7 +1022,7 @@ module RubySketch
|
|
997
1022
|
end
|
998
1023
|
|
999
1024
|
def mouseClicked?()
|
1000
|
-
return false unless @pointer && @pointerDownStartPos
|
1025
|
+
return false unless parent && @pointer && @pointerDownStartPos
|
1001
1026
|
[to_screen(@pointer.pos), @pointerDownStartPos]
|
1002
1027
|
.map {|pos| Rays::Point.new pos.x, pos.y, 0}
|
1003
1028
|
.then {|pos, startPos| (pos - startPos).length < 3}
|
data/rubysketch.gemspec
CHANGED
@@ -29,8 +29,8 @@ Gem::Specification.new do |s|
|
|
29
29
|
s.add_runtime_dependency 'rucy', '~> 0.1.39'
|
30
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.51'
|
33
|
+
s.add_runtime_dependency 'processing', '~> 0.5.27'
|
34
34
|
|
35
35
|
s.add_development_dependency 'rake'
|
36
36
|
s.add_development_dependency 'test-unit'
|
data/test/test_sprite.rb
CHANGED
@@ -272,21 +272,31 @@ class TestSprite < Test::Unit::TestCase
|
|
272
272
|
v = s.instance_variable_get :@view__
|
273
273
|
assert_nil v.update
|
274
274
|
assert_nil v.contact
|
275
|
+
assert_nil v.contact_end
|
275
276
|
assert_nil v.will_contact
|
276
277
|
|
277
278
|
s.update {}
|
278
279
|
assert_not_nil v.update
|
279
280
|
assert_nil v.contact
|
281
|
+
assert_nil v.contact_end
|
280
282
|
assert_nil v.will_contact
|
281
283
|
|
282
284
|
s.contact {}
|
283
285
|
assert_not_nil v.update
|
284
286
|
assert_not_nil v.contact
|
287
|
+
assert_nil v.contact_end
|
288
|
+
assert_nil v.will_contact
|
289
|
+
|
290
|
+
s.contact_end {}
|
291
|
+
assert_not_nil v.update
|
292
|
+
assert_not_nil v.contact
|
293
|
+
assert_not_nil v.contact_end
|
285
294
|
assert_nil v.will_contact
|
286
295
|
|
287
296
|
s.contact? {}
|
288
297
|
assert_not_nil v.update
|
289
298
|
assert_not_nil v.contact
|
299
|
+
assert_not_nil v.contact_end
|
290
300
|
assert_not_nil v.will_contact
|
291
301
|
end
|
292
302
|
|
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.30
|
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-08-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: xot
|
@@ -72,28 +72,28 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 0.1.
|
75
|
+
version: 0.1.51
|
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.51
|
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.27
|
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.27
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: rake
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|