Marcel Taeumel uploaded a new version of EToys to project The Trunk:
http://source.squeak.org/trunk/EToys-kfr.379.mcz ==================== Summary ==================== Name: EToys-kfr.379 Author: kfr Time: 19 January 2020, 5:56:35.451611 pm UUID: 4b09cf66-2c5f-2141-a27c-0300ecbef7ae Ancestors: EToys-kfr.378 Fix longstanding visual bug in SameGame. Cascade had wrong order so deselection could not work. =============== Diff against EToys-dtl.376 =============== Item was changed: AlignmentMorph subclass: #Mines + instanceVariableNames: 'board minesDisplay timeDisplay helpText level levelButton hiScoreDisplay' - instanceVariableNames: 'board minesDisplay timeDisplay helpText' classVariableNames: '' poolDictionaries: '' category: 'Etoys-Squeakland-Morphic-Games'! Item was added: + ----- Method: Mines class>>initialize (in category 'parts bin') ----- + initialize + super initialize. + "boardSizes are column, row, mines, highScore" + BoardSizes := Dictionary new. + BoardSizes at: 1 put:{8. 8. 10. 999. 'Beginner'}. + BoardSizes at: 2 put:{16. 16. 40. 999. 'Intermediate'}. + BoardSizes at: 3 put:{30. 16. 99. 999. 'Expert'}. + + ! Item was added: + ----- Method: Mines>>hiScoreDisplay (in category 'access') ----- + hiScoreDisplay + + ^ hiScoreDisplay! Item was changed: ----- Method: Mines>>initialize (in category 'initialization') ----- initialize "initialize the state of the receiver" + super initialize. + + level := 1. - "" self listDirection: #topToBottom; wrapCentering: #center; cellPositioning: #topCenter; vResizing: #shrinkWrap; hResizing: #shrinkWrap; layoutInset: 3; addMorph: self makeControls; addMorph: self board. helpText := nil. + self newGame! Item was added: + ----- Method: Mines>>level (in category 'access') ----- + level + ^level! Item was changed: ----- Method: Mines>>makeControls (in category 'initialize') ----- makeControls | row | row := AlignmentMorph newRow color: color; borderWidth: 2; layoutInset: 3. row borderStyle: BorderStyle inset. row hResizing: #spaceFill; vResizing: #shrinkWrap; wrapCentering: #center; cellPositioning: #leftCenter; extent: 5 @ 5. row addMorph: (self buildButton: SimpleSwitchMorph new target: self label: ' Help ' translated selector: #help:). row addMorph: (self + buildButton: (levelButton := SimpleButtonMorph new) + target: self + label: level asString translated + selector: #nextLevel). + row + addMorph: (self buildButton: SimpleButtonMorph new target: self label: ' Quit ' translated selector: #delete). "row addMorph: (self buildButton: SimpleButtonMorph new target: self label: ' Hint ' translated selector: #hint)." row addMorph: (self buildButton: SimpleButtonMorph new target: self label: ' New game ' translated selector: #newGame). minesDisplay := LedMorph new digits: 2; extent: 2 * 10 @ 15. row addMorph: (self wrapPanel: minesDisplay label: 'Mines:' translated). + timeDisplay := LedTimerMorph new digits: 3; extent: 3 * 10 @ 15. + - timeDisplay := LedTimerMorph new digits: 3; - extent: 3 * 10 @ 15. row addMorph: (self wrapPanel: timeDisplay label: 'Time:' translated). + hiScoreDisplay := LedMorph new digits: 3; extent: 3 * 10 @ 15. + row + addMorph: (self wrapPanel: hiScoreDisplay label: 'Hi Score:' translated). ^ row! Item was changed: ----- Method: Mines>>newGame (in category 'actions') ----- newGame + | boardSize | + boardSize := BoardSizes at: level. - timeDisplay value: 0; flash: false. timeDisplay stop. timeDisplay reset. + minesDisplay value: (boardSize at: 3). + hiScoreDisplay value: (boardSize at: 4). + levelButton label: (boardSize at: 5) asString. + self board resetBoard: level.! - minesDisplay value: 99. - self board resetBoard.! Item was added: + ----- Method: Mines>>nextLevel (in category 'actions') ----- + nextLevel + level := level + 1. + level = 4 ifTrue:[level := 1]. + self newGame + + ! Item was changed: AlignmentMorph subclass: #MinesBoard + instanceVariableNames: 'protoTile rows columns flashCount tileCount target actionSelector arguments gameStart gameOver boardSize' - instanceVariableNames: 'protoTile rows columns flashCount tileCount target actionSelector arguments gameStart gameOver' classVariableNames: '' poolDictionaries: '' category: 'Etoys-Squeakland-Morphic-Games'! Item was changed: ----- Method: MinesBoard>>initialize (in category 'initialization') ----- initialize "initialize the state of the receiver" super initialize. "" target := nil. actionSelector := #selection. arguments := #(). "" self layoutPolicy: nil; hResizing: #rigid; vResizing: #rigid. "" + boardSize := BoardSizes at: 1. + - rows := self preferredRows. columns := self preferredColumns. + rows := self preferredRows. flashCount := 0. "" self extent: self protoTile extent * (columns @ rows). self adjustTiles. + self resetBoard: 1.! - self resetBoard! Item was changed: ----- Method: MinesBoard>>preferredColumns (in category 'preferences') ----- preferredColumns + ^ boardSize at: 1! - ^ 30! Item was changed: ----- Method: MinesBoard>>preferredMines (in category 'preferences') ----- preferredMines + ^boardSize at:3! - ^ 99! Item was changed: ----- Method: MinesBoard>>preferredRows (in category 'preferences') ----- preferredRows + ^ boardSize at:2! - ^ 16! Item was removed: - ----- Method: MinesBoard>>resetBoard (in category 'initialization') ----- - resetBoard - - gameStart := false. - gameOver := false. - [flashCount = 0] whileFalse: [self step]. - flashCount := 0. - tileCount := 0. - Collection initialize. "randomize the Collection class" - self purgeAllCommands. - self submorphsDo: "set tiles to original state." - [:m | m privateOwner: nil. "Don't propagate all these changes..." - m mineFlag: false. - m disabled: false. - m switchState: false. - m isMine: false. - m privateOwner: self]. - self changed "Now note the change in bulk"! Item was added: + ----- Method: MinesBoard>>resetBoard: (in category 'initialization') ----- + resetBoard: aLevel + + boardSize := BoardSizes at: aLevel. + columns := self preferredColumns. + rows := self preferredRows. + flashCount := 0. + "" + self extent: self protoTile extent * (columns @ rows). + self adjustTiles. + + gameStart := false. + gameOver := false. + + flashCount := 0. + tileCount := 0. + Collection initialize. "randomize the Collection class" + self purgeAllCommands. + self submorphsDo: "set tiles to original state." + [:m | m privateOwner: nil. "Don't propagate all these changes..." + m mineFlag: false. + m disabled: false. + m switchState: false. + m isMine: false. + m privateOwner: self]. + self changed "Now note the change in bulk"! Item was changed: ----- Method: MinesBoard>>stepOnTile: (in category 'actions') ----- stepOnTile: location + | mines tile score | - | mines tile | tile := self tileAt: location. tile mineFlag ifFalse:[ tile isMine ifTrue: [tile color: Color gray darker darker. self blowUp. ^false.] ifFalse:[ mines := self findMines: location. tile switchState: true. tileCount := tileCount + 1. mines = 0 ifTrue: [self selectTilesAdjacentTo: location]]. + tileCount = ((columns*rows) - self preferredMines) ifTrue:[ gameOver := true. flashCount := 2. owner timeDisplay stop. + score := owner timeDisplay value. + ( score < (boardSize at:4)) + ifTrue:[(BoardSizes at: owner level ) at: 4 put: score. + owner hiScoreDisplay value: score]]. - tileCount = ((columns*rows) - self preferredMines) ifTrue:[ gameOver := true. flashCount := 2. owner timeDisplay stop.]. ^ true.] ifTrue: [^ false.] ! Item was changed: ----- Method: SameGameBoard>>removeSelection (in category 'actions') ----- removeSelection selection ifNil: [^ self]. self rememberUndoableAction: [selection + do: [:loc | (self tileAt: loc) setSwitchState: false; disabled: true]. - do: [:loc | (self tileAt: loc) disabled: true; - setSwitchState: false]. self collapseColumns: (selection collect: [:loc | loc x] as: Set) sorted. selection := nil. flash := false. (target notNil and: [actionSelector notNil]) ifTrue: [target perform: actionSelector withArguments: arguments]] named: 'remove selection' translated! |
Free forum by Nabble | Edit this page |