rubysketch 0.5.10 → 0.5.12

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
  SHA256:
3
- metadata.gz: 7e4589a97dabb9fd55efdc88db52b3b47026a10888c8e2a80109137830746399
4
- data.tar.gz: df12166d8d9b4711bbf0a957181658e63dfcaf43bca5fa557a24404d69ae02cc
3
+ metadata.gz: 89c9430464e46375e771df7dea669efb44b39420e74cd39f768565261eccbaea
4
+ data.tar.gz: e5e2f5d02342288f28a1b9b39bfb65a3df5a689a3f2357dfbec2fd08ac72528d
5
5
  SHA512:
6
- metadata.gz: a1bcac7645dbf4c4a80a24339149b73f165f3bac7c366fef65e7bf6a5f7d60033564dac70178a10bbcc43bb77718ddb1e927514a207c99191a68d0ce9b30c6a2
7
- data.tar.gz: a3635cceb2cb9f7fdf1a665892fed34e1ca826e7337a98a228d93e25fe35f054a241ab031b8aab128b247700f0b168082f45f60835c13852d2597344dd625e2d
6
+ metadata.gz: 59f9a68562024f0902f9b684d0488af1ed788774a21312b1d89ebe6a49c214a1931ab126034bfd2e216bcf00ab7fd8c60dac2186cd82393a5302010873ac4e91
7
+ data.tar.gz: ace3f137ae3485fbe318be5c38fbd404a963b23b51afb5941ee047b89ccc4fb5746b0ee068dd9b91a6a795d86f09d452b3f0c3cac3cdb7eef550ded264b0596b
data/ChangeLog.md CHANGED
@@ -1,6 +1,19 @@
1
1
  # rubysketch ChangeLog
2
2
 
3
3
 
4
+ ## [v0.5.12] - 2023-05-27
5
+
6
+ - required_ruby_version >= 3.0.0
7
+ - Add spec.license
8
+ - Add fixAngle() and angleFixed() to Sprite class
9
+
10
+
11
+ ## [v0.5.11] - 2023-05-26
12
+
13
+ - add left, top, right, and bottom accessors to Sprite class
14
+ - add show(), hide(), and hidden?() to Sprite class
15
+
16
+
4
17
  ## [v0.5.10] - 2023-05-21
5
18
 
6
19
  - Update dependencies
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.10
1
+ 0.5.12
@@ -74,6 +74,7 @@ module RubySketch
74
74
  def sprite(*sprites)
75
75
  sprites.flatten! if sprites.first&.is_a? Array
76
76
  sprites.each do |sp|
77
+ next if sp.hidden?
77
78
  view, draw = sp.getInternal__, sp.instance_variable_get(:@drawBlock__)
78
79
  f, degrees, pivot = view.frame, view.angle, view.pivot
79
80
  if draw
@@ -15,25 +15,25 @@ module RubySketch
15
15
  #
16
16
  # @overload new(x, y, image: img)
17
17
  # pos: [x, y], size: [image.width, image.height]
18
- # @param [Numeric] x x of sprite position
19
- # @param [Numeric] y y of sprite position
18
+ # @param [Numeric] x x of the sprite position
19
+ # @param [Numeric] y y of the sprite position
20
20
  # @param [Image] img sprite image
21
21
  #
22
22
  # @overload new(x, y, w, h)
23
23
  # pos(x, y), size: [w, h]
24
- # @param [Numeric] x x of sprite position
25
- # @param [Numeric] y y of sprite position
26
- # @param [Numeric] w width of sprite
27
- # @param [Numeric] h height of sprite
24
+ # @param [Numeric] x x of the sprite position
25
+ # @param [Numeric] y y of the sprite position
26
+ # @param [Numeric] w width of the sprite
27
+ # @param [Numeric] h height of the sprite
28
28
  #
29
29
  # @overload new(x, y, w, h, image: img, offset: off)
30
30
  # pos: [x, y], size: [w, h], offset: [offset.x, offset.x]
31
- # @param [Numeric] x x of sprite position
32
- # @param [Numeric] y y of sprite position
33
- # @param [Numeric] w width of sprite
34
- # @param [Numeric] h height of sprite
31
+ # @param [Numeric] x x of the sprite position
32
+ # @param [Numeric] y y of the sprite position
33
+ # @param [Numeric] w width of the sprite
34
+ # @param [Numeric] h height of the sprite
35
35
  # @param [Image] img sprite image
36
- # @param [Vector] off offset of sprite image
36
+ # @param [Vector] off offset of the sprite image
37
37
  #
38
38
  def initialize(
39
39
  x = 0, y = 0, w = nil, h = nil, image: nil, offset: nil,
@@ -54,6 +54,35 @@ module RubySketch
54
54
  self.offset = offset if offset
55
55
  end
56
56
 
57
+ # Shows the sprite
58
+ #
59
+ # Since one call to "hide()" increases the hide count, it is necessary to call "show()" n times to make the sprite visible again after calling "hide()" n times.
60
+ #
61
+ # @return [Sprite] self
62
+ #
63
+ def show()
64
+ @view__.show
65
+ self
66
+ end
67
+
68
+ # Hides the sprite
69
+ #
70
+ # Since one call to "hide()" increases the hide count, it is necessary to call "show()" n times to make the sprite visible again after calling "hide()" n times.
71
+ #
72
+ # @return [Sprite] self
73
+ #
74
+ def hide()
75
+ @view__.hide
76
+ end
77
+
78
+ # Returns the sprite is visible
79
+ #
80
+ # @return [Boolean] true: invisible, false: visible
81
+ #
82
+ def hidden?()
83
+ @view__.hidden?
84
+ end
85
+
57
86
  # Returns the position of the sprite.
58
87
  #
59
88
  # @return [Vector] position
@@ -137,6 +166,79 @@ module RubySketch
137
166
  alias pos position
138
167
  alias pos= position=
139
168
 
169
+ # Returns the left position of the sprite.
170
+ #
171
+ # @return [Numeric] left position
172
+ #
173
+ def left()
174
+ @view__.left
175
+ end
176
+
177
+ # Set the left position of the sprite.
178
+ #
179
+ # @param [Numeric] n sprite left position
180
+ #
181
+ # @return [Numeric] sprite left position
182
+ #
183
+ def left=(n)
184
+ @view__.left = n
185
+ n
186
+ end
187
+
188
+ # Returns the top position of the sprite.
189
+ #
190
+ # @return [Numeric] top position
191
+ #
192
+ def top()
193
+ @view__.top
194
+ end
195
+
196
+ # Set the top position of the sprite.
197
+ #
198
+ # @param [Numeric] n sprite top position
199
+ #
200
+ # @return [Numeric] sprite top position
201
+ #
202
+ def top=(n)
203
+ @view__.top = n
204
+ end
205
+
206
+ # Returns the right position of the sprite.
207
+ #
208
+ # @return [Numeric] right position
209
+ #
210
+ def right()
211
+ @view__.right
212
+ end
213
+
214
+ # Set the right position of the sprite.
215
+ #
216
+ # @param [Numeric] n sprite right position
217
+ #
218
+ # @return [Numeric] sprite right position
219
+ #
220
+ def right=(n)
221
+ @view__.right = n
222
+ end
223
+
224
+ # Returns the bottom position of the sprite.
225
+ #
226
+ # @return [Numeric] bottom
227
+ #
228
+ def bottom()
229
+ @view__.bottom
230
+ end
231
+
232
+ # Set the bottom position of the sprite.
233
+ #
234
+ # @param [Numeric] n sprite bottom position
235
+ #
236
+ # @return [Numeric] sprite bottom position
237
+ #
238
+ def bottom=(bottom)
239
+ @view__.bottom = bottom
240
+ end
241
+
140
242
  # Returns the center position of the sprite.
141
243
  #
142
244
  # @return [Vector] center position
@@ -219,7 +321,7 @@ module RubySketch
219
321
  alias h height
220
322
  alias h= height=
221
323
 
222
- # Returns the rotation angle of sprite.
324
+ # Returns the rotation angle of the sprite.
223
325
  #
224
326
  # @return [Numeric] radians or degrees depending on angleMode()
225
327
  #
@@ -228,7 +330,7 @@ module RubySketch
228
330
  c ? c.fromDegrees__(a) : a * Processing::GraphicsContext::DEG2RAD__
229
331
  end
230
332
 
231
- # Sets the rotation angle of sprite.
333
+ # Sets the rotation angle of the sprite.
232
334
  #
233
335
  # @param [Numeric] angle radians or degrees depending on angleMode()
234
336
  #
@@ -241,7 +343,26 @@ module RubySketch
241
343
  angle
242
344
  end
243
345
 
244
- # Returns the rotation center of sprite.
346
+ # Fixes the angle of the sprite.
347
+ #
348
+ # @param [Boolean] fix fix rotation or not
349
+ #
350
+ # @return [Sprite] self
351
+ #
352
+ def fixAngle(fix = true)
353
+ @view__.fix_angle = fix
354
+ self
355
+ end
356
+
357
+ # Returns the angle of the sprite is fixed or not.
358
+ #
359
+ # @return [Boolean] whether the rotation is fixed or not
360
+ #
361
+ def angleFixed?()
362
+ @view__.fix_angle?
363
+ end
364
+
365
+ # Returns the rotation center of the sprite.
245
366
  #
246
367
  # @return [Array<Numeric>] [pivotX, pivotY]
247
368
  #
@@ -249,7 +370,7 @@ module RubySketch
249
370
  @view__.pivot.to_a[0, 2]
250
371
  end
251
372
 
252
- # Sets the rotation center of sprite.
373
+ # Sets the rotation center of the sprite.
253
374
  # [0.0, 0.0] is the left-top, [1.0, 1.0] is the right-bottom, and [0.5, 0.5] is the center.
254
375
  #
255
376
  # @param [Array<Numeric>] ary an array of pivotX and pivotY
data/rubysketch.gemspec CHANGED
@@ -17,23 +17,23 @@ Gem::Specification.new do |s|
17
17
  rdocs = glob.call *%w[README]
18
18
 
19
19
  s.name = name
20
+ s.version = ext.version
21
+ s.license = 'MIT'
20
22
  s.summary = 'A game engine based on the Processing API.'
21
23
  s.description = 'A game engine based on the Processing API.'
22
- s.version = ext.version
23
-
24
- s.authors = %w[xordog]
25
- s.email = 'xordog@gmail.com'
26
- s.homepage = "https://github.com/xord/rubysketch"
24
+ s.authors = %w[xordog]
25
+ s.email = 'xordog@gmail.com'
26
+ s.homepage = "https://github.com/xord/rubysketch"
27
27
 
28
28
  s.platform = Gem::Platform::RUBY
29
- s.required_ruby_version = '>= 2.7.0'
30
-
31
- s.add_runtime_dependency 'xot', '~> 0.1.36'
32
- s.add_runtime_dependency 'rucy', '~> 0.1.36'
33
- s.add_runtime_dependency 'beeps', '~> 0.1.37'
34
- s.add_runtime_dependency 'rays', '~> 0.1.37'
35
- s.add_runtime_dependency 'reflexion', '~> 0.1.39'
36
- s.add_runtime_dependency 'processing', '~> 0.5.11'
29
+ s.required_ruby_version = '>= 3.0.0'
30
+
31
+ s.add_runtime_dependency 'xot', '~> 0.1.37'
32
+ s.add_runtime_dependency 'rucy', '~> 0.1.37'
33
+ s.add_runtime_dependency 'beeps', '~> 0.1.38'
34
+ s.add_runtime_dependency 'rays', '~> 0.1.38'
35
+ s.add_runtime_dependency 'reflexion', '~> 0.1.40'
36
+ s.add_runtime_dependency 'processing', '~> 0.5.13'
37
37
 
38
38
  s.add_development_dependency 'rake'
39
39
  s.add_development_dependency 'test-unit'
data/test/test_sprite.rb CHANGED
@@ -39,6 +39,18 @@ class TestSprite < Test::Unit::TestCase
39
39
  assert_raise {sprite 0, 0, 0, -1}
40
40
  end
41
41
 
42
+ def test_show_hide()
43
+ s = sprite; assert_false s.hidden?
44
+ s.hide; assert_true s.hidden?
45
+ s.show; assert_false s.hidden?
46
+ 2.times {s.hide}; assert_true s.hidden?
47
+ s.show; assert_true s.hidden?
48
+ s.show; assert_false s.hidden?
49
+ s.show; assert_false s.hidden?
50
+ s.hide; assert_false s.hidden?
51
+ s.hide; assert_true s.hidden?
52
+ end
53
+
42
54
  def test_position()
43
55
  s = sprite
44
56
  assert_equal vec(0, 0), s.pos
@@ -117,6 +129,20 @@ class TestSprite < Test::Unit::TestCase
117
129
  assert_in_epsilon Math::PI, s.angle
118
130
  end
119
131
 
132
+ def test_fixAngle()
133
+ s = sprite
134
+ assert_false s.angleFixed?
135
+
136
+ s.fixAngle true
137
+ assert_true s.angleFixed?
138
+
139
+ s.fixAngle false
140
+ assert_false s.angleFixed?
141
+
142
+ s.fixAngle
143
+ assert_true s.angleFixed?
144
+ end
145
+
120
146
  def test_pivot()
121
147
  s = sprite
122
148
  assert_each_in_epsilon [0, 0], s.pivot
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.10
4
+ version: 0.5.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - xordog
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-05-20 00:00:00.000000000 Z
11
+ date: 2023-05-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: xot
@@ -16,84 +16,84 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.1.36
19
+ version: 0.1.37
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.1.36
26
+ version: 0.1.37
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rucy
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 0.1.36
33
+ version: 0.1.37
34
34
  type: :runtime
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.1.36
40
+ version: 0.1.37
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: beeps
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 0.1.37
47
+ version: 0.1.38
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.37
54
+ version: 0.1.38
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rays
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 0.1.37
61
+ version: 0.1.38
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 0.1.37
68
+ version: 0.1.38
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: reflexion
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 0.1.39
75
+ version: 0.1.40
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.39
82
+ version: 0.1.40
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.11
89
+ version: 0.5.13
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.11
96
+ version: 0.5.13
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: rake
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -172,7 +172,8 @@ files:
172
172
  - test/helper.rb
173
173
  - test/test_sprite.rb
174
174
  homepage: https://github.com/xord/rubysketch
175
- licenses: []
175
+ licenses:
176
+ - MIT
176
177
  metadata: {}
177
178
  post_install_message:
178
179
  rdoc_options: []
@@ -182,7 +183,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
182
183
  requirements:
183
184
  - - ">="
184
185
  - !ruby/object:Gem::Version
185
- version: 2.7.0
186
+ version: 3.0.0
186
187
  required_rubygems_version: !ruby/object:Gem::Requirement
187
188
  requirements:
188
189
  - - ">="