--- Bot.st.orig 2006-07-16 11:28:11.000000000 +0300 +++ Bot.st.new 2006-07-16 11:28:06.000000000 +0300 @@ -1,6 +1,6 @@ -'From Squeak3.8gamma of ''24 November 2004'' [latest update: #6662] on 16 July 2006 at 11:26:03 am'! +'From Squeak3.8gamma of ''24 November 2004'' [latest update: #6662] on 1 April 2006 at 2:43:56 pm'! Morph subclass: #Bot - instanceVariableNames: 'direction shown penColor penSize drawSelector image turtleBuffer vars memorizedPoints' + instanceVariableNames: 'direction shown penColor penSize drawSelector image turtleBuffer vars memorizedPoints delay slow' classVariableNames: 'DefaultDisplaySelector DrawSelector Halos Image' poolDictionaries: '' category: 'Pica-Bot'! @@ -33,6 +33,11 @@ ifTrue: [180 + (dy / dx) arcTan radiansToDegrees negated] ifFalse: [90 * dy negated sign]]! ! +!Bot methodsFor: 'basic operations' stamp: 'N.S. 4/1/2006 12:24'! +beFast + "Make the bot fast" + slow := false.! ! + !Bot methodsFor: 'basic operations' stamp: 'sd 2/17/2005 21:15'! beInvisible "Make the receiver invisible" @@ -41,6 +46,11 @@ shown := false. self changed! ! +!Bot methodsFor: 'basic operations' stamp: 'N.S. 4/1/2006 12:24'! +beSlow + "Make the bot slow" + slow := true.! ! + !Bot methodsFor: 'basic operations' stamp: 'sd 2/17/2005 21:15'! beVisible "Make the receiver visible" @@ -218,13 +228,14 @@ drawSelector _ aSymbol. self changed.! ! -!Bot methodsFor: 'private' stamp: 'sd 1/6/2005 10:13'! +!Bot methodsFor: 'private' stamp: 'N.S. 4/1/2006 13:03'! privateInitialize self getImageFromClass. drawSelector := self class drawSelector. vars := Dictionary new. - memorizedPoints := OrderedCollection new.! ! + memorizedPoints := OrderedCollection new. + delay := self defaultDelay.! ! !Bot methodsFor: 'advanced operations' stamp: 'sd 6/28/2002 11:36'! @@ -559,6 +570,20 @@ self clearBotBuffer. super color: aColor.! ! +!Bot methodsFor: 'drawing' stamp: 'N.S. 4/1/2006 12:46'! +defaultDelay + "Return the default delay" + ^ (Delay forMilliseconds: 20)! ! + +!Bot methodsFor: 'drawing' stamp: 'N.S. 4/1/2006 12:31'! +delay + ^ delay.! ! + +!Bot methodsFor: 'drawing' stamp: 'N.S. 4/1/2006 12:32'! +delay: aDelay + "Set the delay after each drawing operation." + delay := aDelay.! ! + !Bot methodsFor: 'drawing' stamp: 'sd 2/17/2005 21:15'! extent: aPoint "Change the receiver's extent, but check for a minimun" @@ -736,7 +761,7 @@ self image: (self class getImageFromMorph: aMorph)! ! -!Bot methodsFor: 'operations' stamp: 'sd 2/19/2005 13:16'! +!Bot methodsFor: 'operations' stamp: 'N.S. 4/1/2006 13:02'! goTo: aPoint "make the receiver go at a given point of the screen. The @@ -745,7 +770,9 @@ the final point." self yield. self drawTrailFrom: self center to: aPoint. - self center: aPoint! ! + self center: aPoint. + + slow ifTrue: [delay wait].! ! !Bot methodsFor: 'operations' stamp: 'sd 3/30/2005 10:25'! go: distance @@ -783,7 +810,7 @@ jumpTo: (self positionIfGo: distance)! ! -!Bot methodsFor: 'initialization' stamp: 'sd 3/19/2005 20:35'! +!Bot methodsFor: 'initialization' stamp: 'N.S. 4/1/2006 12:41'! initializeToStandAlone "Initialize a newly created object" "Bot newStandAlone openInWorld" @@ -795,6 +822,7 @@ self clearBotBuffer. self penSize: 1. self beVisible. + self beFast. self color: (Color blue alpha: 0.85). self penColor: Color black. @@ -1001,6 +1029,33 @@ nextPutAll: ' position: '; nextPutAll: self center printString! ! + +!Bot methodsFor: 'shapes' stamp: 'N.S. 3/24/2006 18:47'! +rectangle: size + 4 timesRepeat: + [self go: size. + self turn: 90.] + +! ! + +!Bot methodsFor: 'shapes' stamp: 'N.S. 3/31/2006 20:41'! +star: aNumber + "Draw a star with default number of branches" + | center radious branches angle | + + radious := aNumber / 2. + branches := 60. + angle := 360 / branches. + center := self center. + + branches timesRepeat: + [self go: radious; jumpTo: center; turn: angle.]. +! ! + +!Bot methodsFor: 'shapes' stamp: 'N.S. 3/31/2006 21:00'! +sun: aNumber + self star: aNumber.! ! + "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "! Bot class