diff --git a/src/ComputationalArt/CABlocks.class.st b/src/ComputationalArt/CABlocks.class.st index fa18219..0eed734 100644 --- a/src/ComputationalArt/CABlocks.class.st +++ b/src/ComputationalArt/CABlocks.class.st @@ -10,100 +10,111 @@ Class { } { - #category : #'as yet unclassified', - #'squeak_changestamp' : 'Sars 6/7/2024 14:07' + #category : #blocks, + #'squeak_changestamp' : 'KoPa 7/12/2024 18:21' } CABlocks class >> air [ - ^0 + + ^ 0. ] { - #category : #'as yet unclassified', - #'squeak_changestamp' : 'Sars 6/7/2024 18:15' + #category : #blocks, + #'squeak_changestamp' : 'KoPa 7/12/2024 18:21' } CABlocks class >> algae [ - ^ 4 + + ^ 4. ] { - #category : #'as yet unclassified', - #'squeak_changestamp' : 'Sars 6/12/2024 20:04' + #category : #blocks, + #'squeak_changestamp' : 'KoPa 7/12/2024 18:21' } CABlocks class >> fire [ - ^ 6 + + ^ 6. ] { - #category : #'as yet unclassified', - #'squeak_changestamp' : 'Sars 6/12/2024 20:04' + #category : #blocks, + #'squeak_changestamp' : 'KoPa 7/12/2024 18:21' } CABlocks class >> fish [ - ^ 9 + + ^ 9. ] { - #category : #'as yet unclassified', - #'squeak_changestamp' : 'HaMa 5/31/2024 12:03' + #category : #blocks, + #'squeak_changestamp' : 'KoPa 7/12/2024 18:21' } CABlocks class >> sand [ - ^ 2 + + ^ 2. ] { - #category : #'as yet unclassified', - #'squeak_changestamp' : 'Sars 6/12/2024 20:03' + #category : #blocks, + #'squeak_changestamp' : 'KoPa 7/12/2024 18:21' } CABlocks class >> smoke [ - ^ 7 + + ^ 7. ] { - #category : #'as yet unclassified', - #'squeak_changestamp' : 'HaMa 5/31/2024 12:04' + #category : #blocks, + #'squeak_changestamp' : 'KoPa 7/12/2024 18:21' } CABlocks class >> stone [ - ^ 3 + + ^ 3. ] { - #category : #'as yet unclassified', - #'squeak_changestamp' : 'Sars 6/12/2024 20:09' + #category : #blocks, + #'squeak_changestamp' : 'KoPa 7/12/2024 18:21' } CABlocks class >> tnt [ -^8 + + ^ 8. ] { - #category : #'as yet unclassified', - #'squeak_changestamp' : 'HaMa 5/31/2024 12:04' + #category : #blocks, + #'squeak_changestamp' : 'KoPa 7/12/2024 18:21' } CABlocks class >> water [ - ^ 1 + + ^ 1. ] { - #category : #'as yet unclassified', - #'squeak_changestamp' : 'Sars 6/12/2024 20:02' + #category : #blocks, + #'squeak_changestamp' : 'KoPa 7/12/2024 18:21' } CABlocks class >> wood [ - ^5 + + ^ 5. ] { - #category : #'as yet unclassified', - #'squeak_changestamp' : 'Sars 6/3/2024 23:46' + #category : #accessing, + #'squeak_changestamp' : 'KoPa 7/12/2024 18:04' } -CABlocks >> colorOf: index [ +CABlocks >> colorAt: anIndex [ - ^ blockColors at: index. + ^ blockColors at: anIndex. ] { - #category : #'as yet unclassified', - #'squeak_changestamp' : 'Sars 6/19/2024 16:41' + #category : #'initialize-release', + #'squeak_changestamp' : 'KoPa 7/12/2024 18:22' } CABlocks >> initialize [ - blockNames := IdentityDictionary new at: 0 put: 'air'; + blockNames := IdentityDictionary new + at: 0 put: 'air'; at: 1 put: 'water'; at: 2 put: 'sand'; at: 3 put: 'stone'; @@ -114,7 +125,8 @@ CABlocks >> initialize [ at: 8 put: 'tnt'; at: 9 put: 'fish'; yourself. - blockColors := IdentityDictionary new at: 0 put: Color white; + blockColors := IdentityDictionary new + at: 0 put: Color white; at: 1 put: Color blue; at: 2 put: Color yellow; at: 3 put: Color black; @@ -124,13 +136,13 @@ CABlocks >> initialize [ at: 7 put: Color lightGray; at: 8 put: Color orange; at: 9 put: Color lightRed; - yourself + yourself. ] { - #category : #'as yet unclassified', - #'squeak_changestamp' : 'HaMa 5/31/2024 11:21' + #category : #accessing, + #'squeak_changestamp' : 'KoPa 7/12/2024 18:04' } -CABlocks >> nameOf: index [ - ^ blockNames at: index. +CABlocks >> nameAt: anIndex [ + ^ blockNames at: anIndex. ] diff --git a/src/ComputationalArt/CACellMorph.class.st b/src/ComputationalArt/CACellMorph.class.st index bf68a9c..4408679 100644 --- a/src/ComputationalArt/CACellMorph.class.st +++ b/src/ComputationalArt/CACellMorph.class.st @@ -10,61 +10,68 @@ Class { } { - #category : #'as yet unclassified', - #'squeak_changestamp' : 'Sars 6/16/2024 14:58' + #category : #accessing, + #'squeak_changestamp' : 'KoPa 7/12/2024 18:39' } -CACellMorph >> col: colPos [ - col:= colPos +CACellMorph >> col: aPosition [ + + col:= aPosition. ] { - #category : #'as yet unclassified', - #'squeak_changestamp' : 'Sars 6/16/2024 14:58' + #category : #accessing, + #'squeak_changestamp' : 'KoPa 7/12/2024 18:38' } CACellMorph >> game: aGame [ - game := aGame + + game := aGame. ] { - #category : #'as yet unclassified', - #'squeak_changestamp' : 'Sars 6/16/2024 15:02' + #category : #handling, + #'squeak_changestamp' : 'KoPa 7/12/2024 18:38' } CACellMorph >> handlesMouseDown: anEvent [ -^ true + + ^ true. ] { - #category : #'as yet unclassified', - #'squeak_changestamp' : 'Sars 7/3/2024 16:03' + #category : #handling, + #'squeak_changestamp' : 'KoPa 7/12/2024 18:38' } -CACellMorph >> handlesMouseOver: anEvent [ - ^ true +CACellMorph >> handlesMouseOver: anEvent [ + + ^ true. ] { - #category : #'as yet unclassified', - #'squeak_changestamp' : 'Sars 7/3/2024 15:58' + #category : #handling, + #'squeak_changestamp' : 'KoPa 7/12/2024 18:38' } -CACellMorph >> mouseDown: anEvent [ +CACellMorph >> mouseDown: anEvent [ + anEvent redButtonPressed ifTrue: [game putCellAtRow: row andCol: col] - ifFalse: [game toggleBrushActive] + ifFalse: [game toggleBrushActive]. ] { - #category : #'as yet unclassified', - #'squeak_changestamp' : 'Sars 7/3/2024 16:02' + #category : #handling, + #'squeak_changestamp' : 'KoPa 7/12/2024 18:39' } -CACellMorph >> mouseEnter: anEvent [ +CACellMorph >> mouseEnter: anEvent [ + game brushActive - ifTrue: [game putCellAtRow: row andCol: col] + ifTrue: [game putCellAtRow: row andCol: col]. ] { - #category : #'as yet unclassified', - #'squeak_changestamp' : 'Sars 6/16/2024 14:58' + #category : #accessing, + #'squeak_changestamp' : 'KoPa 7/12/2024 18:39' } -CACellMorph >> row: rowPos [ -row := rowPos +CACellMorph >> row: aPosition [ + + row := aPosition. ] diff --git a/src/ComputationalArt/CADisplay.class.st b/src/ComputationalArt/CADisplay.class.st index 4853887..fd7e17a 100644 --- a/src/ComputationalArt/CADisplay.class.st +++ b/src/ComputationalArt/CADisplay.class.st @@ -11,8 +11,44 @@ Class { } { - #category : #'as yet unclassified', - #'squeak_changestamp' : 'Sars 6/16/2024 20:43' + #category : #constants, + #'squeak_changestamp' : 'KoPa 7/12/2024 18:27' +} +CADisplay class >> border [ + + ^ 1. +] + +{ + #category : #constants, + #'squeak_changestamp' : 'KoPa 7/12/2024 18:26' +} +CADisplay class >> gap [ + + ^ 0. +] + +{ + #category : #constants, + #'squeak_changestamp' : 'KoPa 7/12/2024 18:27' +} +CADisplay class >> offset [ + + ^ 320@30. +] + +{ + #category : #constants, + #'squeak_changestamp' : 'KoPa 7/12/2024 18:27' +} +CADisplay class >> size [ + + ^ 10. +] + +{ + #category : #accessing, + #'squeak_changestamp' : 'KoPa 7/12/2024 18:38' } CADisplay >> attachedGame: aGame [ @@ -21,8 +57,8 @@ CADisplay >> attachedGame: aGame [ ] { - #category : #'as yet unclassified', - #'squeak_changestamp' : 'Sars 6/16/2024 20:43' + #category : #accessing, + #'squeak_changestamp' : 'KoPa 7/12/2024 18:38' } CADisplay >> attachedGrid: aGrid [ @@ -31,10 +67,11 @@ CADisplay >> attachedGrid: aGrid [ ] { - #category : #'as yet unclassified', - #'squeak_changestamp' : 'Sars 6/23/2024 15:54' + #category : #'initialize-release', + #'squeak_changestamp' : 'KoPa 7/12/2024 18:22' } CADisplay >> initialize [ + cells := OrderedCollection new. viewMorph := Morph new bounds: (100 @ 100 corner: 1450 @ 1160); @@ -46,45 +83,43 @@ CADisplay >> initialize [ ] { - #category : #'as yet unclassified', - #'squeak_changestamp' : 'Sars 6/16/2024 20:45' + #category : #accessing, + #'squeak_changestamp' : 'KoPa 7/12/2024 18:31' } CADisplay >> showGrid: aGrid [ -|grid cols rows origin size border gap blockLookup| - -blockLookup := CABlocks new. -grid := aGrid grid. -cols := aGrid numCols. -rows := aGrid numRows. -origin := viewMorph position. -size := 10. -border := 1. -gap := 0. - -self wipeCells. - -(1 to: rows) do: [:rowIndex | - (1 to: cols) do: [:colIndex | - | cellMorph cell| - cell := aGrid getCellAtRow: rowIndex andCol: colIndex. - cellMorph := Morph new - extent: size @ size; - borderColor: Color black; - color: "Color random;" (blockLookup colorOf: cell); - borderWidth: border; - position: (((colIndex-1) * (size+gap)) @ ((rowIndex-1) * (size+gap)) + origin). - viewMorph addMorph: cellMorph. - cells add: cellMorph. - ]. -]. + | grid cols rows origin size border gap blockLookup | + blockLookup := CABlocks new. + grid := aGrid grid. + cols := aGrid numCols. + rows := aGrid numRows. + origin := viewMorph position. + size := CADisplay size. + border := CADisplay border. + gap := CADisplay gap. + + self wipeCells. + + 1 to: rows do: [ :rowIndex | + 1 to: cols do: [ :colIndex | + | cellMorph cell | + cell := aGrid getCellAtRow: rowIndex andCol: colIndex. + cellMorph := Morph new + extent: size @ size; + borderColor: Color black; + color: (blockLookup colorAt: cell); + borderWidth: border; + position: (((colIndex-1) * (size+gap)) @ ((rowIndex-1) * (size+gap)) + origin). + viewMorph addMorph: cellMorph. + cells add: cellMorph. ]]. ] { - #category : #'as yet unclassified', - #'squeak_changestamp' : 'Sars 6/23/2024 15:39' + #category : #functional, + #'squeak_changestamp' : 'KoPa 7/12/2024 18:33' } CADisplay >> step [ + | grid cols rows origin size border gap blockLookup aGrid | aGrid := attachedGrid. blockLookup := CABlocks new. @@ -92,9 +127,10 @@ CADisplay >> step [ cols := aGrid numCols. rows := aGrid numRows. origin := viewMorph position + (320@30). - size := 10. - border := 1. - gap := 0. + size := CADisplay size. + border := CADisplay border. + gap := CADisplay gap. + cells isEmpty ifTrue: [Transcript show: 'grid was empty'; cr. @@ -106,7 +142,7 @@ CADisplay >> step [ cellMorph := CACellMorph new extent: size @ size; borderColor: Color gray; - color: (blockLookup colorOf: cell); + color: (blockLookup colorAt: cell); borderWidth: border; position: colIndex - 1 * (size + gap) @ (rowIndex - 1 * (size + gap)) + origin; row: rowIndex; @@ -124,27 +160,26 @@ CADisplay >> step [ cell := aGrid getCellAtRow: rowIndex andCol: colIndex. cellMorph := cells at: rowIndex - 1 * rows + colIndex. cellMorph - color: (blockLookup colorOf: cell)]]] + color: (blockLookup colorAt: cell)]]] ] { - #category : #'as yet unclassified', - #'squeak_changestamp' : 'Sars 6/16/2024 20:43' + #category : #accessing, + #'squeak_changestamp' : 'KoPa 7/12/2024 18:07' } CADisplay >> viewMorph [ - ^viewMorph + ^ viewMorph. ] { - #category : #'as yet unclassified', - #'squeak_changestamp' : 'Sars 6/3/2024 23:45' + #category : #functional, + #'squeak_changestamp' : 'KoPa 7/12/2024 18:11' } CADisplay >> wipeCells [ -cells do: [:eachMorph | - eachMorph delete. -]. -cells removeAll. + cells do: [ :eachMorph | + eachMorph delete. ]. + cells removeAll. ] diff --git a/src/ComputationalArt/CAGame.class.st b/src/ComputationalArt/CAGame.class.st index 2c6e6b5..d753460 100644 --- a/src/ComputationalArt/CAGame.class.st +++ b/src/ComputationalArt/CAGame.class.st @@ -109,7 +109,7 @@ CAGame >> skipAhead: stepCount [ { #category : #'as yet unclassified', - #'squeak_changestamp' : 'Sars 7/10/2024 15:46' + #'squeak_changestamp' : 'KoPa 7/12/2024 18:38' } CAGame >> start [ | maxIterations iterationCount gameloop ui | diff --git a/src/ComputationalArtTests/CABlocksTest.class.st b/src/ComputationalArtTests/CABlocksTest.class.st index 171e7da..4ce498a 100644 --- a/src/ComputationalArtTests/CABlocksTest.class.st +++ b/src/ComputationalArtTests/CABlocksTest.class.st @@ -33,19 +33,19 @@ CABlocksTest >> tearDown [ { #category : #'as yet unclassified', - #'squeak_changestamp' : 'HaMa 6/20/2024 10:18' + #'squeak_changestamp' : 'KoPa 7/12/2024 18:03' } CABlocksTest >> testColors [ - self assert: Color white equals: (blocks colorOf: CABlocks air). - self assert: Color blue equals: (blocks colorOf: CABlocks water). - self assert: Color yellow equals: (blocks colorOf: CABlocks sand). - self assert: Color black equals: (blocks colorOf: CABlocks stone). - self assert: Color green equals: (blocks colorOf: CABlocks algae). - self assert: Color brown equals: (blocks colorOf: CABlocks wood). - self assert: Color red equals: (blocks colorOf: CABlocks fire). - self assert: Color lightGray equals: (blocks colorOf: CABlocks smoke). - self assert: Color orange equals: (blocks colorOf: CABlocks tnt). - self assert: Color lightRed equals: (blocks colorOf: CABlocks fish). + self assert: Color white equals: (blocks colorAt: CABlocks air). + self assert: Color blue equals: (blocks colorAt: CABlocks water). + self assert: Color yellow equals: (blocks colorAt: CABlocks sand). + self assert: Color black equals: (blocks colorAt: CABlocks stone). + self assert: Color green equals: (blocks colorAt: CABlocks algae). + self assert: Color brown equals: (blocks colorAt: CABlocks wood). + self assert: Color red equals: (blocks colorAt: CABlocks fire). + self assert: Color lightGray equals: (blocks colorAt: CABlocks smoke). + self assert: Color orange equals: (blocks colorAt: CABlocks tnt). + self assert: Color lightRed equals: (blocks colorAt: CABlocks fish). ] { @@ -67,25 +67,25 @@ CABlocksTest >> testIndexMethods [ { #category : #'as yet unclassified', - #'squeak_changestamp' : 'HaMa 6/20/2024 10:21' + #'squeak_changestamp' : 'KoPa 7/12/2024 18:03' } CABlocksTest >> testNames [ - self assert: 'air' equals: (blocks nameOf: CABlocks air). - self assert: 'water' equals: (blocks nameOf: CABlocks water). - self assert: 'sand' equals: (blocks nameOf: CABlocks sand). - self assert: 'stone' equals: (blocks nameOf: CABlocks stone). - self assert: 'algae' equals: (blocks nameOf: CABlocks algae). - self assert: 'wood' equals: (blocks nameOf: CABlocks wood). - self assert: 'fire' equals: (blocks nameOf: CABlocks fire). - self assert: 'smoke' equals: (blocks nameOf: CABlocks smoke). - self assert: 'tnt' equals: (blocks nameOf: CABlocks tnt). - self assert: 'fish' equals: (blocks nameOf: CABlocks fish). + self assert: 'air' equals: (blocks nameAt: CABlocks air). + self assert: 'water' equals: (blocks nameAt: CABlocks water). + self assert: 'sand' equals: (blocks nameAt: CABlocks sand). + self assert: 'stone' equals: (blocks nameAt: CABlocks stone). + self assert: 'algae' equals: (blocks nameAt: CABlocks algae). + self assert: 'wood' equals: (blocks nameAt: CABlocks wood). + self assert: 'fire' equals: (blocks nameAt: CABlocks fire). + self assert: 'smoke' equals: (blocks nameAt: CABlocks smoke). + self assert: 'tnt' equals: (blocks nameAt: CABlocks tnt). + self assert: 'fish' equals: (blocks nameAt: CABlocks fish). ] { #category : #'as yet unclassified', - #'squeak_changestamp' : 'HaMa 6/20/2024 10:27' + #'squeak_changestamp' : 'KoPa 7/12/2024 18:03' } CABlocksTest >> testWrongIndexFail [ - self assert: 'wall' equals: (blocks nameOf: -1). + self assert: 'wall' equals: (blocks nameAt: -1). ] diff --git a/src/ComputationalArtTests/CAOverlayTest.class.st b/src/ComputationalArtTests/CAOverlayTest.class.st index 43f44ef..80e523b 100644 --- a/src/ComputationalArtTests/CAOverlayTest.class.st +++ b/src/ComputationalArtTests/CAOverlayTest.class.st @@ -37,7 +37,7 @@ CAOverlayTest >> tearDown [ { #category : #'as yet unclassified', - #'squeak_changestamp' : 'JAL 6/23/2024 17:49' + #'squeak_changestamp' : 'KoPa 7/12/2024 18:03' } CAOverlayTest >> testBlockMenu [ | list blocks | @@ -45,5 +45,5 @@ CAOverlayTest >> testBlockMenu [ list := (overlay submorphOfClass: CAOverlayBlockMenu) submorphOfClass: CAOverlayList. list submorphsDo: [:s | s click. - self assert: (blocks nameOf: (game activeCellType)) equals: s contents asLowercase]. + self assert: (blocks nameAt: (game activeCellType)) equals: s contents asLowercase]. ]