mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 20:31:51 +09:00
wall block item to use its own texture (for real)
This commit is contained in:
@@ -535,6 +535,14 @@ fun SpriteBatch.drawStraightLine(x: Float, y: Float, otherEnd: Float, thickness:
|
||||
|
||||
|
||||
infix fun Color.mul(other: Color): Color = this.cpy().mul(other)
|
||||
infix fun Color.mulAndAssign(other: Color): Color {
|
||||
this.r *= other.r
|
||||
this.g *= other.g
|
||||
this.b *= other.b
|
||||
this.a *= other.a
|
||||
|
||||
return this
|
||||
}
|
||||
|
||||
|
||||
fun blendMul(batch: SpriteBatch) {
|
||||
|
||||
@@ -269,7 +269,7 @@ object ItemCodex {
|
||||
// wall
|
||||
else if (item.originalID in ITEM_WALLS) {
|
||||
return BlocksDrawer.tileItemWall.get(
|
||||
(item.originalID.minus(ITEM_WALLS.first) % 16) * 16,
|
||||
(item.originalID.minus(ITEM_WALLS.first) % 16),
|
||||
(item.originalID.minus(ITEM_WALLS.first) / 16)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -143,13 +143,32 @@ internal object BlocksDrawer {
|
||||
printdbg(this, "Making wall item textures...")
|
||||
|
||||
// create item_wall images
|
||||
// will just use the terrain texture :p
|
||||
tileItemWall = weatherTerrains[1]
|
||||
// because some limitation, we'll use summer image
|
||||
// CPU render shits (lots of magic numbers xD)
|
||||
val itemWallPixmap = Pixmap(_terrainPixMap[1].width / 16, _terrainPixMap[1].height, Pixmap.Format.RGBA8888)
|
||||
for (blocksCol in 0 until itemWallPixmap.width / TILE_SIZE) { // 0..15
|
||||
val pxColStart = blocksCol * 256 // 0, 256, 512, 768, ...
|
||||
for (pxCol in pxColStart until pxColStart + TILE_SIZE) {
|
||||
val x = blocksCol * TILE_SIZE + (pxCol fmod TILE_SIZE)
|
||||
|
||||
for (y in 0 until itemWallPixmap.height) {
|
||||
val colour = Color(_terrainPixMap[1].getPixel(pxCol, y)) mulAndAssign wallOverlayColour
|
||||
itemWallPixmap.drawPixel(x, y, colour.toRGBA())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// test print
|
||||
//PixmapIO2.writeTGA(Gdx.files.local("wallitem.tga"), itemWallPixmap, false)
|
||||
|
||||
val itemWallTexture = Texture(itemWallPixmap)
|
||||
itemWallPixmap.dispose()
|
||||
tileItemWall = TextureRegionPack(itemWallTexture, TILE_SIZE, TILE_SIZE)
|
||||
|
||||
|
||||
_terrainPixMap.forEach { it.dispose() } // finally
|
||||
|
||||
|
||||
// finally
|
||||
_terrainPixMap.forEach { it.dispose() }
|
||||
tilesTerrain = weatherTerrains[1]
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user