Skip to content

Commit

Permalink
refactored CABlocks + CACellMorph
Browse files Browse the repository at this point in the history
  • Loading branch information
kpawlak committed Jul 12, 2024
1 parent 3fc0f3b commit 32a86c6
Show file tree
Hide file tree
Showing 6 changed files with 201 additions and 147 deletions.
98 changes: 55 additions & 43 deletions src/ComputationalArt/CABlocks.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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;
Expand All @@ -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.
]
59 changes: 33 additions & 26 deletions src/ComputationalArt/CACellMorph.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -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.
]
Loading

0 comments on commit 32a86c6

Please sign in to comment.