2
我試圖創建PBE-Lighoutgame迷宮作爲我的裁判沒有鼠標點擊事件 我有2班創建一個迷宮
這兩個類都RectangleMorph
VisibleSquare>>initialize
"Visible borders with Some Color"
其他類的子類
InvisbleSquare>>initialize
"Everything is transparent Including Borders"
實施迷宮類,這是BorderedMorph的子類
Maze>>initialize
initialize
|sampleCell width height n sample|
super initialize.
self borderWidth: 0.
n := self cellsPerSide.
sampleCell := VisibleSquare new.
sample:= InvisibleSquare new.
width := sampleCell width.
height := sample height.
self bounds: ([email protected] extent: ((width + n) @ (height + n)) + (2 * self borderWidth)).
cells := Matrix new: n tabulate: [:i :j | self newCellAt: i at: j].
其他方法
Maze>> newCellAt: i at: j
"Create a cell for position (i,j) and add it to my on-screen
representation at the appropriate screen position. Answer the new cell"
|c origin b |
c := VisibleSquare new.
origin := self innerBounds origin.
self addMorph: c.
c position: ((i - 1) * c width) @ ((j - 1) * c height) + origin.
^ c
我怎麼能製表矩陣既VisibleSquare & InvisibleSquare使得它們能夠在網格中隨機添加(或)是否有任何其他方式做到這一點?
製表矩陣與可見和不可見的廣場,我不知道我該怎麼做 – Irfan 2013-02-28 05:07:23