rubysketch 0.5.25 → 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: 41b147fcb3fd31ea85f6b29b30681a0280140ded656677ade8bddf91399af6b8
4
- data.tar.gz: 3cc93b88d182703d4c08750029058e0911fe3a17f9c98aa6f951482552c8f1b6
3
+ metadata.gz: 26c49c9860053850965c49ba550e222dbbc31dd41c26ed5a0e3ccba96cc70f30
4
+ data.tar.gz: f6d5e3eff58ce12340eccf50bb9dc2d21f19403ad54828890fe49c19428a9f30
5
5
  SHA512:
6
- metadata.gz: 68665dc8c90267229151102218044d4a95f9a7fbdae5ed61dd8a16cdc9ef14b65b0b582e491bb5be7576618594721ad101e0923245dcb8ed20f004ed658c9c85
7
- data.tar.gz: 94bdd58eda1690e820446a8b58fe2628110ec00d5093515416b9f0e64c2f31d9c545f075d436123abce715359cfe46f39a1d08f3125a1616248b15be2eead5eb
6
+ metadata.gz: fbab1d6a12f52dbbef8c66be6dc86fccfb5da9c63807ea579ca4b61042d4e8df0fa223f533eb2ef6505054b4d4e0cfe812e9eadebd6926ae65ec0a22243c0760
7
+ data.tar.gz: a942e138e2350c873a148cf2ec17f58c6aded29685956f00c35eb50583403d3771dfe84b8ea3d303c01c0026e93fdd079716b47699f21d4a86189de378f96234
data/ChangeLog.md CHANGED
@@ -1,6 +1,11 @@
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
+
4
9
  ## [v0.5.25] - 2023-07-22
5
10
 
6
11
  - Freeze EASINGS
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.25
1
+ 0.5.26
@@ -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
@@ -91,7 +91,7 @@ module RubySketch
91
91
  @timers__.delete_if do |id, (time, args, block)|
92
92
  (now >= time).tap {|fire| @firingTimers__[id] = [block, args] if fire}
93
93
  end
94
- @firingTimers__.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
@@ -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.25
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-22 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