rubysketch 0.5.28 → 0.5.30

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a27c613bb9a268367ce581b9b4caa9e89d546f763680ec8b9b408bdadaed0c16
4
- data.tar.gz: b0503752020cc76e453922183b34c78d049c2c3b4665438cc024286cadf679c5
3
+ metadata.gz: dbbb972756576a0aa6c5dfc70ba1682776dd0f95c1bc0d0ec20a06dce0e1bd01
4
+ data.tar.gz: 7ce985bbaee1c81f3b20dea0392cd2b5459af3e520eb8552840306d32ba03adb
5
5
  SHA512:
6
- metadata.gz: 43c0549b9f6b9381351dad8204a389cf96e80da008d9b0c4a656ad67749a5736a9aff196378905cd42ef012df46e09a49c16f6176882a01cf292cab03056e315
7
- data.tar.gz: a66d891ae5a36ba98adb5611f5c5ed7c79f517dcf12a44d2debdcd175dbc2e7e4a8673358ea532712d5a02858f72452139677eb632913f390b6bfbf64ab27c8d
6
+ metadata.gz: f0f53b5fb3464b8cc6e0f9ff3b3c4d76d465816a5c6414b99a3d5724ca9c20411c37091f8a2b9ed850e05b863c8ef958ed7dceaf8257189dbdb1df125033d7fa
7
+ data.tar.gz: 1e9696d6e23b5333f4c784abd7847fd2ebb00e4dd210945c4f92b251eed80f7485cc1694fd1d09003c9a7cfe9e8ff1a95275cca6cb928d53814c65cdeb184781
data/ChangeLog.md CHANGED
@@ -1,6 +1,18 @@
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
+
4
16
  ## [v0.5.28] - 2023-07-30
5
17
 
6
18
  - Update dependencies
@@ -8,7 +20,7 @@
8
20
 
9
21
  ## [v0.5.27] - 2023-07-30
10
22
 
11
- - add vibrate()
23
+ - Add vibrate()
12
24
 
13
25
 
14
26
  ## [v0.5.26] - 2023-07-26
@@ -46,12 +58,12 @@
46
58
 
47
59
  ## [v0.5.20] - 2023-07-09
48
60
 
49
- - fix that calling mousePressed() without block removes mousePressed block
61
+ - Fix that calling mousePressed() without block removes mousePressed block
50
62
 
51
63
 
52
64
  ## [v0.5.19] - 2023-06-27
53
65
 
54
- - add loadSound() and RubySketch::Sound class
66
+ - Add loadSound() and RubySketch::Sound class
55
67
 
56
68
 
57
69
  ## [v0.5.18] - 2023-06-22
@@ -93,8 +105,8 @@
93
105
 
94
106
  ## [v0.5.11] - 2023-05-26
95
107
 
96
- - add left, top, right, and bottom accessors to Sprite class
97
- - add show(), hide(), and hidden?() to Sprite class
108
+ - Add left, top, right, and bottom accessors to Sprite class
109
+ - Add show(), hide(), and hidden?() to Sprite class
98
110
 
99
111
 
100
112
  ## [v0.5.10] - 2023-05-21
@@ -161,19 +173,19 @@
161
173
 
162
174
  ## [v0.5.2] - 2023-03-02
163
175
 
164
- - depend to processing-0.5.2 gem
176
+ - Depend to processing-0.5.2 gem
165
177
 
166
178
 
167
179
  ## [v0.5.1] - 2023-03-01
168
180
 
169
- - fix bugs
181
+ - Fix bugs
170
182
 
171
183
 
172
184
  ## [v0.5.0] - 2023-02-09
173
185
 
174
- - add Sprite class
186
+ - Add Sprite class
175
187
 
176
188
 
177
189
  ## [v0.4.0] - 2023-02-08
178
190
 
179
- - first version
191
+ - First version
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.28
1
+ 0.5.30
@@ -59,8 +59,8 @@ module RubySketch
59
59
  now, nextTime = Time.now.to_f, startTime + seconds
60
60
  nextTime = now if nextTime < now
61
61
  setTimeout__ id, nextTime do
62
- block.call(*args)
63
62
  setInterval__ id, nextTime, seconds, args, &block
63
+ block.call(*args)
64
64
  end
65
65
  end
66
66
 
@@ -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
- static: true, density: 1, friction: 0, restitution: 0,
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, *a, **k, &b)
894
+ def initialize(sprite, *args, physics:, **kwargs, &block)
879
895
  @sprite = sprite
880
- super(*a, **k, &b)
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 @contact, v.sprite, e.action if v.respond_to?(:sprite)
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/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.28
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-07-30 00:00:00.000000000 Z
11
+ date: 2023-08-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: xot