'From etoys2.3 of 28 November 2007 [latest update: #1843] on 15 December 2007 at 12:41:08 am'!
"Change Set: headingPrecision-yo
Date: 15 December 2007
Author: Yoshiki Ohshima
Change the rounding behavior of setHeading:.
Setting heading historically round the value and ignore small changes in angle.However, the rounding and ignoreing are not so small. This change set attempts to fix the problem. Since the semantics is changed, some obscure existing projects may change its behavior, but the risk is relatively small. We will see what the community says."!
!Player methodsFor: 'heading' stamp: 'yo 12/15/2007 00:31'!
headDown
| radians |
radians _ (self getHeadingUnrounded - 90.0) degreesToRadians.
self setHeading:
(radians cos @ radians sin abs) theta radiansToDegrees + 90.0.
! !
!Player methodsFor: 'heading' stamp: 'yo 12/15/2007 00:32'!
headLeft
| radians |
radians _ (self getHeadingUnrounded - 90.0) degreesToRadians.
self setHeading: (radians cos abs negated @ radians sin) theta radiansToDegrees + 90.0.
! !
!Player methodsFor: 'heading' stamp: 'yo 12/15/2007 00:32'!
headRight
| radians |
radians _ (self getHeadingUnrounded - 90.0) degreesToRadians.
self setHeading: (radians cos abs @ radians sin) theta radiansToDegrees + 90.0.
! !
!Player methodsFor: 'heading' stamp: 'yo 12/15/2007 00:32'!
headUp
| radians |
radians _ (self getHeadingUnrounded - 90.0) degreesToRadians.
self setHeading: (radians cos @ radians sin abs negated) theta radiansToDegrees + 90.0.
! !
!Player methodsFor: 'slot getters/setters' stamp: 'yo 12/14/2007 23:17'!
setHeading: newHeading
"Set the heading as indicated"
| aCostume |
aCostume _ self costume.
aCostume isWorldMorph ifTrue: [^ self].
aCostume heading: newHeading.
aCostume _ self costume. "in case we just got flexed for no apparent reason"
(aCostume isFlexMorph and:[aCostume hasNoScaleOrRotation])
ifTrue: [aCostume removeFlexShell]! !