The Trunk: EToys-ct.402.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: EToys-ct.402.mcz

commits-2
Marcel Taeumel uploaded a new version of EToys to project The Trunk:
http://source.squeak.org/trunk/EToys-ct.402.mcz

==================== Summary ====================

Name: EToys-ct.402
Author: ct
Time: 24 August 2020, 8:22:21.479269 pm
UUID: 8b6598bf-158f-a74f-a399-f82c39269bdc
Ancestors: EToys-eem.400

Fixes EToys fences for players within flexshells by subtracting transformations.

=============== Diff against EToys-eem.400 ===============

Item was changed:
  ----- Method: Player>>forward: (in category 'scripts-standard') -----
  forward: dist
  "Move forward (viz. in the direction of my heading) by the given amount"
 
  | rho radians delta didStray p aCostume aPlayfield |
  (aCostume := self costume) isInWorld ifFalse: [^ self].
  aCostume isWorldOrHandMorph ifTrue: [^ self].
  aCostume owner isHandMorph ifTrue: [^ self].
+
-
  rho := (aCostume asNumber: dist) asFloat.
+ radians := (self getHeadingUnrounded asFloat - 90) degreesToRadians.
- radians := (self getHeadingUnrounded asFloat - 90.0) degreesToRadians.
  delta := (radians cos @ radians sin) * rho.
+
+ (aPlayfield := aCostume pasteUpMorph) fenceEnabled ifTrue: [
+ | playfieldBounds costumeBounds |
+ playfieldBounds := aPlayfield boundsInWorld.
+ costumeBounds := aCostume boundsInWorld.
+ (playfieldBounds containsRect: costumeBounds) ifFalse: [
+ "If I stray out of the bounds of my playfield, pull me back, but without changing my heading as bounce would. Do nothing if bounce has already corrected the direction."
-
- (aPlayfield := aCostume pasteUpMorph) fenceEnabled ifTrue:
- [(aPlayfield bounds containsRect: aCostume bounds) ifFalse:
- ["If I stray out of the bounds of my playfield, pull me back, but
- without changing my heading as bounce would. Do nothing if
- bounce has already corrected the direction."
  didStray := false.
+ ((costumeBounds left < playfieldBounds left and: [delta x < 0])
+ or: [costumeBounds right > playfieldBounds right and: [delta x > 0]])
+ ifTrue: [
+ delta := delta x negated @ delta y.
+ didStray := true].
+ ((costumeBounds top < playfieldBounds top and: [delta y < 0])
+ or: [costumeBounds bottom > playfieldBounds bottom and: [delta y > 0]])
+ ifTrue: [
+ delta := delta x @ delta y negated.
+ didStray := true].
+ (didStray and: [Preferences fenceSoundEnabled]) ifTrue: [
+ aCostume makeFenceSound]]].
+
- ((aCostume left < aPlayfield left and: [delta x < 0]) or:
- [aCostume right > aPlayfield right and: [delta x > 0]]) ifTrue:
- [delta := delta x negated @ delta y.
- didStray := true].
- ((aCostume top < aPlayfield top and: [delta y < 0]) or:
- [aCostume bottom > aPlayfield bottom and: [delta y > 0]]) ifTrue:
- [delta := delta x @ delta y negated.
- didStray := true].
- (didStray and: [Preferences fenceSoundEnabled]) ifTrue: [aCostume makeFenceSound]]].
-
  "use and record the fractional position"
  p := aCostume referencePosition + delta.
+ aCostume referencePosition: p.!
- aCostume referencePosition: p!