Stupid blob tricks - v1
Bob Arning
arning at charm.net
Sun Jan 16 00:44:17 UTC 2000
This causes Dave's blobs to adapt their color to suit their surroundings. Most will try to blend in, but some will try to stand out.
Cheers,
Bob
======
'From Squeak2.7 of 5 January 2000 [latest update: #1762] on 15 January 2000 at 7:43:29 pm'!
CurveMorph subclass: #DavesBlobMorph
instanceVariableNames: 'random direction velocity sneaky '
classVariableNames: ''
poolDictionaries: ''
category: 'Daves-Blob'!
!DavesBlobMorph methodsFor: 'stepping' stamp: 'RAA 1/15/2000 19:41'!
adjustColors
| nearbyColors center r degrees |
sneaky ifNil: [sneaky _ {true. true. true. false} atRandom].
center _ bounds center.
nearbyColors _ vertices collect: [ :each |
degrees _ (each - center) degrees.
r _ (each - center) r.
Display colorAt: (Point r: r + 6 degrees: degrees) + center
].
self color: (
Color
r: (nearbyColors collect: [ :each | each red]) average
g: (nearbyColors collect: [ :each | each green]) average
b: (nearbyColors collect: [ :each | each blue]) average
).
sneaky ifFalse: [self color: color negated].! !
!DavesBlobMorph methodsFor: 'stepping' stamp: 'RAA 1/15/2000 19:05'!
step
| verts |
verts := vertices copy.
" change two points at random to cause oozing across screen "
self oozeAFewPointsOf: verts.
" limit radius and interpoint angle "
verts := self limitRange: verts.
" Set new vertices; bounce off a wall if necessary "
self setVertices: verts.
self bounceOffWalls.
self adjustColors.
! !
More information about the Squeak-dev
mailing list
|