render is fixed (tile breakage not tested as loading items are still wip); air tile no longer has tilenum of 0

This commit is contained in:
minjaesong
2021-02-24 11:04:11 +09:00
parent 36387753b1
commit b6a688c484
4 changed files with 19 additions and 4 deletions

Binary file not shown.

View File

@@ -76,7 +76,7 @@ void main() {
int tile = getTileFromColor(tileFromMap);
int breakage = getBreakageFromColor(tileFromMap);
ivec2 tileXY = getTileXY(tile);
ivec2 breakageXY = getTileXY(breakage + 5); // +5 is hard-coded constant that depends on the atlas
ivec2 breakageXY = getTileXY(breakage + 5); // +5 is hard-coded constant that depends on the contents of the atlas
// calculate the UV coord value for texture sampling //

View File

@@ -152,6 +152,9 @@ open class GameWorld : Disposable {
tileNumberToNameMap[it.value.tileNumber] = it.key
tileNameToNumberMap[it.key] = it.value.tileNumber
}
// AN EXCEPTIONAL TERM: tilenum 0 is always redirected to Air tile, even if the tilenum for actual Air tile is not zero
tileNumberToNameMap[0] = Block.AIR
}
/**
@@ -201,6 +204,9 @@ open class GameWorld : Disposable {
// TODO rename wire map
}
}
// AN EXCEPTIONAL TERM: tilenum 0 is always redirected to Air tile, even if the tilenum for actual Air tile is not zero
tileNumberToNameMap[0] = Block.AIR
}
/**

View File

@@ -60,7 +60,7 @@ object CreateTileAtlas {
// 16 tiles are reserved for internal use: solid black, solid white, breakage stages.
// 0th tile is complete transparent tile and is also a BlockID of zero: air.
private var atlasCursor = 0
private var atlasCursor = 64 // 64 predefined tiles. The normal blocks (e.g. Air) should start from this number
private val atlasInit = "./assets/graphics/blocks/init.tga"
private var itemSheetCursor = 16
@@ -86,6 +86,14 @@ object CreateTileAtlas {
atlasFluid.blending = Pixmap.Blending.None
atlasGlow.blending = Pixmap.Blending.None
// populate the atlantes with atlasInit
// this just directly copies the image to the atlantes :p
val initPixmap = Pixmap(Gdx.files.internal(atlasInit))
atlas.drawPixmap(initPixmap, 0, 0)
atlasAutumn.drawPixmap(initPixmap, 0, 0)
atlasWinter.drawPixmap(initPixmap, 0, 0)
atlasSpring.drawPixmap(initPixmap, 0, 0)
// get all the files applicable
// first, get all the '/blocks' directory, and add all the files, regardless of their extension, to the list
val tgaList = ArrayList<Pair<String, FileHandle>>() //Pair of <modname, filehandle>
@@ -192,6 +200,7 @@ object CreateTileAtlas {
itemWallTexture = Texture(itemWallPixmap)
itemTerrainPixmap.dispose()
itemWallPixmap.dispose()
initPixmap.dispose()
initialised = true
} }