rubysketch 0.5.24 → 0.5.26

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: 5538cde508d958c69978b0cdf51727303c3c509f96fae21a30b41cfabc99a9a8
4
- data.tar.gz: 9b7fd39a1684f7fe49fbc98250c0315038419566443209fddce8701ff9683228
3
+ metadata.gz: 26c49c9860053850965c49ba550e222dbbc31dd41c26ed5a0e3ccba96cc70f30
4
+ data.tar.gz: f6d5e3eff58ce12340eccf50bb9dc2d21f19403ad54828890fe49c19428a9f30
5
5
  SHA512:
6
- metadata.gz: f71cd9de84e98317c61ad25c013cf0d6ec2257cc884138984908ee6ecd505c7a87068798539b8491fcccad90e7a829dea8d62fb907483c46be215cea010cb074
7
- data.tar.gz: 4758d91420fb1069ce87438ec0df5cfea7af382847f9375bc7869f48fce5ed3d21936d0af79c0c3b2a166121991f922a82944c5a89515e1b09f872fb8723b7cd
6
+ metadata.gz: fbab1d6a12f52dbbef8c66be6dc86fccfb5da9c63807ea579ca4b61042d4e8df0fa223f533eb2ef6505054b4d4e0cfe812e9eadebd6926ae65ec0a22243c0760
7
+ data.tar.gz: a942e138e2350c873a148cf2ec17f58c6aded29685956f00c35eb50583403d3771dfe84b8ea3d303c01c0026e93fdd079716b47699f21d4a86189de378f96234
data/ChangeLog.md CHANGED
@@ -1,6 +1,17 @@
1
1
  # rubysketch ChangeLog
2
2
 
3
3
 
4
+ ## [v0.5.26] - 2023-07-26
5
+
6
+ - Rescue exceptions thrown at sprite event handlers
7
+
8
+
9
+ ## [v0.5.25] - 2023-07-22
10
+
11
+ - Freeze EASINGS
12
+ - Fix that clearTimer() fails clearing timer in very rare cases
13
+
14
+
4
15
  ## [v0.5.24] - 2023-07-21
5
16
 
6
17
  - Add animate(), animateValue(), and EASINGS
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.24
1
+ 0.5.26
@@ -9,7 +9,7 @@ module RubySketch
9
9
  # @private
10
10
  def initialize(window)
11
11
  super
12
- @timers__, @nextTimerID__ = {}, 0
12
+ @timers__, @firingTimers__, @nextTimerID__ = {}, {}, 0
13
13
 
14
14
  @layer__ = window.add_overlay SpriteLayer.new
15
15
 
@@ -44,7 +44,7 @@ module RubySketch
44
44
  def setInterval(seconds = 0, *args, id: nextTimerID__, now: false, &block)
45
45
  return unless block
46
46
  time = Time.now.to_f
47
- block.call *args if now
47
+ block.call(*args) if now
48
48
  setInterval__ id, time, seconds, args, &block
49
49
  end
50
50
 
@@ -59,7 +59,7 @@ 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
62
+ block.call(*args)
63
63
  setInterval__ id, nextTime, seconds, args, &block
64
64
  end
65
65
  end
@@ -71,7 +71,7 @@ module RubySketch
71
71
  # @return [nil] nil
72
72
  #
73
73
  def clearTimer(id)
74
- @timers__.delete id
74
+ [@timers__, @firingTimers__].each {|timers| timers.delete id}
75
75
  nil
76
76
  end
77
77
 
@@ -87,11 +87,11 @@ module RubySketch
87
87
  # @private
88
88
  def fireTimers__()
89
89
  now = Time.now.to_f
90
- blocks = []
91
- @timers__.delete_if do |_, (time, args, block)|
92
- (now >= time).tap {|fire| blocks.push [block, args] if fire}
90
+ @firingTimers__.clear
91
+ @timers__.delete_if do |id, (time, args, block)|
92
+ (now >= time).tap {|fire| @firingTimers__[id] = [block, args] if fire}
93
93
  end
94
- blocks.each {|block, args| block.call *args}
94
+ @firingTimers__.each {|_, (block, args)| block.call(*args)}
95
95
  end
96
96
 
97
97
  # Animate with easing functions
@@ -100,6 +100,6 @@ module RubySketch
100
100
  backInOut: backInOut,
101
101
  elasticInOut: elasticInOut,
102
102
  bounceInOut: bounceInOut
103
- }
103
+ }.freeze
104
104
 
105
105
  end# RubySketch
@@ -879,6 +879,7 @@ module RubySketch
879
879
  @sprite = sprite
880
880
  super(*a, **k, &b)
881
881
 
882
+ @error = nil
882
883
  @pointer = nil
883
884
  @pointerPrev = nil
884
885
  @pointersPressed = []
@@ -915,7 +916,7 @@ module RubySketch
915
916
  end
916
917
 
917
918
  def on_update(e)
918
- @update&.call
919
+ call_block @update
919
920
  end
920
921
 
921
922
  def on_pointer_down(e)
@@ -923,8 +924,8 @@ module RubySketch
923
924
  updatePointersPressedAndReleased e, true
924
925
  @pointerDownStartPos = to_screen @pointer.pos
925
926
  if e.view_index == 0
926
- @mousePressed&.call if e.any? {|p| p.id == @pointer.id}
927
- @touchStarted&.call
927
+ call_block @mousePressed if e.any? {|p| p.id == @pointer.id}
928
+ call_block @touchStarted
928
929
  end
929
930
  end
930
931
 
@@ -933,10 +934,10 @@ module RubySketch
933
934
  updatePointersPressedAndReleased e, false
934
935
  if e.view_index == 0
935
936
  if e.any? {|p| p.id == @pointer.id}
936
- @mouseReleased&.call
937
- @mouseClicked&.call if mouseClicked?
937
+ call_block @mouseReleased
938
+ call_block @mouseClicked if mouseClicked?
938
939
  end
939
- @touchEnded&.call
940
+ call_block @touchEnded
940
941
  end
941
942
  @pointerDownStartPos = nil
942
943
  @pointersReleased.clear
@@ -946,8 +947,8 @@ module RubySketch
946
947
  updatePointerStates e
947
948
  if e.view_index == 0
948
949
  mouseMoved = e.drag? ? @mouseDragged : @mouseMoved
949
- mouseMoved&.call if e.any? {|p| p.id == @pointer.id}
950
- @touchMoved&.call
950
+ call_block mouseMoved if e.any? {|p| p.id == @pointer.id}
951
+ call_block @touchMoved
951
952
  end
952
953
  end
953
954
 
@@ -957,12 +958,12 @@ module RubySketch
957
958
 
958
959
  def on_contact_begin(e)
959
960
  v = e.view
960
- @contact.call v.sprite, e.action if @contact && v.respond_to?(:sprite)
961
+ call_block @contact, v.sprite, e.action if @contact && v.respond_to?(:sprite)
961
962
  end
962
963
 
963
964
  def will_contact?(v)
964
965
  return true unless @will_contact && v.respond_to?(:sprite)
965
- @will_contact.call v.sprite
966
+ call_block @will_contact, v.sprite
966
967
  end
967
968
 
968
969
  private
@@ -1002,6 +1003,13 @@ module RubySketch
1002
1003
  .then {|pos, startPos| (pos - startPos).length < 3}
1003
1004
  end
1004
1005
 
1006
+ def call_block(block, *args)
1007
+ block.call(*args) if block && !@error
1008
+ rescue Exception => e
1009
+ @error = e
1010
+ $stderr.puts e.full_message
1011
+ end
1012
+
1005
1013
  end# SpriteView
1006
1014
 
1007
1015
 
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.24
4
+ version: 0.5.26
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-21 00:00:00.000000000 Z
11
+ date: 2023-07-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: xot