You see Pharo as a file syntax too. You did all that because you do not like you use the code browser but you should try it. because coding in the playground for now does not really scales. Le 1/10/16 à 22:39, CodeDmitry a écrit :
Ok I got the proof of concept down, but I can't get it all to run at once since Pharo realizes that the class does not exist(at the time of running), even though it will exist by the time it gets to that line.
Is there a way to modify the following Transcript code make the following code run "at once". Ignoring the fact that classes are not created at time of writing?
([ SimpleSwitchMorph subclass: #LOCell instanceVariableNames: 'mouseAction' classVariableNames: '' package: 'PBE-LightsOut' ] value).
([ BorderedMorph subclass: #LOGame instanceVariableNames: 'cells' classVariableNames: '' package: 'PBE-LightsOut' ] value).
([ LOCell compile: 'mouseAction: a', (String cr), ' ^ mouseAction := a'. ] value).
([ LOCell compile: 'mouseUp: e', (String cr), ' mouseAction value' ] value).
([ LOCell compile: 'initialize', (String cr), ' super initialize.', (String cr), ' self label: ''''.', (String cr), ' self borderWidth: 2.', (String cr), ' bounds := (0@0) corner: (16@16).', (String cr), ' offColor := Color paleYellow.', (String cr), ' onColor := Color paleBlue darker.', (String cr), ' self useSquareCorners.', (String cr), ' self turnOff.' ] value).
([ LOGame compile: 'cellsPerSide', (String cr), ' ^10' ] value).
([ LOGame compile: 'toggleNeighboursOfCellAt: i at: j', (String cr), ' (i > 1) ifTrue: [', (String cr), ' (cells at: i - 1 at: j) toggleState.', (String cr), ' ].', (String cr), (String cr), ' (i < self cellsPerSide) ifTrue: [', (String cr), ' (cells at: i + 1 at: j) toggleState.', (String cr), ' ].', (String cr), (String cr), ' (j > 1) ifTrue: [', (String cr), ' (cells at: i at: j - 1) toggleState.', (String cr), ' ].', (String cr), (String cr), ' (j < self cellsPerSide) ifTrue: [', (String cr), ' (cells at: i at: j + 1) toggleState.', (String cr), ' ].' ] value).
([ LOGame compile: 'newCellAt: i at: j', (String cr), ' | c origin | ', (String cr), (String cr), ' c := LOCell new.', (String cr), ' origin := self innerBounds origin.', (String cr), (String cr), ' self addMorph: c.', (String cr), ' ', (String cr), ' c position: ([', (String cr), ' | x_index y_index c_width c_height |', (String cr), (String cr), ' x_index := i - 1.', (String cr), ' y_index := j - 1.', (String cr), ' c_width := c width.', (String cr), ' c_height := c height.', (String cr), ' ', (String cr), ' (x_index * c_width)@(y_index * c_height) + origin', (String cr), ' ] value).', (String cr), (String cr), ' c mouseAction: [', (String cr), ' self toggleNeighboursOfCellAt: i at: j.', (String cr), ' ].', (String cr), ' ^ c.', (String cr) ] value).
([ LOGame compile: 'initialize', (String cr), ' | sampleCell width height n |', (String cr), (String cr), ' super initialize.', (String cr), ' n := self cellsPerSide.', (String cr), (String cr), ' sampleCell := LOCell new.', (String cr), ' width := sampleCell width.', (String cr), ' height := sampleCell height.', (String cr), (String cr), ' self bounds: ', (String cr), ' ((5@5) extent:', (String cr), ' (width * n)@(height * n) + ', (String cr), ' (2 * (self borderWidth))).', (String cr), (String cr), ' cells := Matrix new: n tabulate: [:i :j |', (String cr), ' self newCellAt: i at: j.', (String cr), ' ].' ] value).
-- View this message in context: http://forum.world.st/New-to-Pharo-a-bunch-of-questions-tp4917701p4917707.ht... Sent from the Pharo Smalltalk Developers mailing list archive at Nabble.com.