Skip to content

Commit

Permalink
fixed visual layer morphicLayer and tile update nil error
Browse files Browse the repository at this point in the history
  • Loading branch information
valteu committed May 28, 2024
1 parent 9a3e3bc commit 01c6043
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 7 deletions.
4 changes: 2 additions & 2 deletions source/GM-TE/GMTEEditableTileMap.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ GMTEEditableTileMap >> tileSelectionSet: anObject [

{
#category : #'as yet unclassified',
#'squeak_changestamp' : 'Alex M 5/28/2024 12:53'
#'squeak_changestamp' : 'Valentin 5/28/2024 13:25'
}
GMTEEditableTileMap >> updateTile: aTile inLayer: aLayer FromEvent: anEvent [
| tileIdx hoveredTile |
Expand All @@ -158,7 +158,7 @@ GMTEEditableTileMap >> updateTile: aTile inLayer: aLayer FromEvent: anEvent [
tileIdx ifNil: [^nil].
hoveredTile := self generateTileAtlayer: aLayer x: tileIdx x y: tileIdx y stack: self tileMatrixStack.].
self updateTileSprite: hoveredTile].
(anEvent yellowButtonPressed)
((anEvent yellowButtonPressed) and: [hoveredTile notNil])
ifTrue: [aLayer
ifNotNil: [
tileIdx := self tileIdxFromPosition: anEvent position.
Expand Down
3 changes: 2 additions & 1 deletion source/GM-TE/GMTETileMap.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,7 @@ GMTETileMap >> updateDimensions [

{
#category : #updating,
#'squeak_changestamp' : 'Ivo Zilkenat 5/27/2024 22:21'
#'squeak_changestamp' : 'Valentin 5/28/2024 13:18'
}
GMTETileMap >> updateMap [
"Update map by: fitting grid to current screen, generating tile matrix, adding sprites"
Expand All @@ -688,6 +688,7 @@ GMTETileMap >> updateMap [
ifNil: [
self tileMatrixStack: (GMTETileMatrixStack fromWidth: self tileWidth height: self tileHeight).
self tileMatrixStackVisual: (GMTETileMatrixStack fromWidth: self tileWidth height: self tileHeight).
self tileMatrixStackVisual morphicLayerStartingOffset: 10. "TODO: Number ?"
self generateVisualTiles]
ifNotNil: [self updateTiles].
self processTiles
Expand Down
28 changes: 24 additions & 4 deletions source/GM-TE/GMTETileMatrixStack.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ Class {
#instVars : [
'width',
'height',
'matrixLayers'
'matrixLayers',
'morphicLayerStartingOffset'
],
#category : #'GM-TE-Core'
}
Expand Down Expand Up @@ -43,12 +44,13 @@ GMTETileMatrixStack >> height: anObject [

{
#category : #'as yet unclassified',
#'squeak_changestamp' : 'Ivo Zilkenat 5/27/2024 22:08'
#'squeak_changestamp' : 'Valentin 5/28/2024 13:17'
}
GMTETileMatrixStack >> initialize [

super initialize.
self matrixLayers: LinkedList new.
self morphicLayerStartingOffset: 100.
"TODO: no base layer created"
]

Expand All @@ -72,13 +74,13 @@ GMTETileMatrixStack >> layer: aLayerIdx at: x at: y [

{
#category : #'as yet unclassified',
#'squeak_changestamp' : 'Ivo Zilkenat 5/27/2024 23:48'
#'squeak_changestamp' : 'Valentin 5/28/2024 13:17'
}
GMTETileMatrixStack >> layer: aLayerIdx at: x at: y put: aTile [

"TODO this is temporary solution; set max layers; use constants"

aTile ifNotNil: [aTile morphicLayerNumber: 100 - aLayerIdx].
aTile ifNotNil: [aTile morphicLayerNumber: self morphicLayerStartingOffset - aLayerIdx].
^ (self matrixLayers at: aLayerIdx) at: x at: y put: aTile
]

Expand Down Expand Up @@ -109,6 +111,24 @@ GMTETileMatrixStack >> matrixLayers: anObject [
matrixLayers := anObject.
]

{
#category : #accessing,
#'squeak_changestamp' : 'Valentin 5/28/2024 13:16'
}
GMTETileMatrixStack >> morphicLayerStartingOffset [

^ morphicLayerStartingOffset
]

{
#category : #accessing,
#'squeak_changestamp' : 'Valentin 5/28/2024 13:16'
}
GMTETileMatrixStack >> morphicLayerStartingOffset: anObject [

morphicLayerStartingOffset := anObject.
]

{
#category : #'as yet unclassified',
#'squeak_changestamp' : 'Ivo Zilkenat 5/27/2024 21:38'
Expand Down

0 comments on commit 01c6043

Please sign in to comment.