Permalink
Browse files

Regularize textures

Why the hell did I do what I did before
  • Loading branch information...
Plenglin committed Nov 14, 2017
1 parent 67796c5 commit be515cd0476f7c1f52d085d206fbb12ade31ce3c
@@ -23,6 +23,17 @@ object Assets {
val tankdestroyer = AssetDescriptor<Texture>("sprites/pawn/tankdestr.png", Texture::class.java)
val beammech = AssetDescriptor<Texture>("sprites/pawn/beammech.png", Texture::class.java)
val headquarters = AssetDescriptor<Texture>("sprites/building/headquarters.png", Texture::class.java)
val factory = AssetDescriptor<Texture>("sprites/building/factory.png", Texture::class.java)
val mine = AssetDescriptor<Texture>("sprites/building/mine.png", Texture::class.java)
val bighill = AssetDescriptor<Texture>("sprites/terrain/bighill-bg.png", Texture::class.java)
val grass = AssetDescriptor<Texture>("sprites/terrain/grass-bg.png", Texture::class.java)
val mountain = AssetDescriptor<Texture>("sprites/terrain/mountain.png", Texture::class.java)
val sand = AssetDescriptor<Texture>("sprites/terrain/sand-bg.png", Texture::class.java)
val smallhill = AssetDescriptor<Texture>("sprites/terrain/smallhill-bg.png", Texture::class.java)
val water = AssetDescriptor<Texture>("sprites/terrain/water.png", Texture::class.java)
val missingno = { this[missing] }
fun load() {
@@ -37,41 +48,21 @@ object Assets {
manager.load(missing)
manager.load(q)
}
operator fun <T> get(descriptor: AssetDescriptor<T>): T {
return manager[descriptor]
}
}
enum class TerrainTextures(simple: Boolean = false) {
GRASS, SMALLHILL, BIGHILL, SAND, WATER(true), MOUNTAIN(true);
manager.load(headquarters)
manager.load(factory)
manager.load(mine)
private val bgPath = "sprites/terrain/${name.toLowerCase()}${if (!simple) "-bg" else ""}.png"
private val fgPath = "sprites/terrain/${name.toLowerCase()}${if (!simple) "-fg" else ""}.png"
fun load() {
Textures.manager.load<Texture>(bgPath)
Textures.manager.load<Texture>(fgPath)
manager.load(bighill)
manager.load(grass)
manager.load(mountain)
manager.load(sand)
manager.load(smallhill)
manager.load(water)
}
fun bg() = manager.getAsset<Texture>(bgPath)
fun fg() = manager.getAsset<Texture>(fgPath)
companion object {
var manager: AssetManager = Assets.manager
operator fun <T> get(descriptor: AssetDescriptor<T>): T {
return manager[descriptor]
}
}
enum class Textures(dir: String) {
HEADQUARTERS("building"), MINE("building"), FACTORY("building");
val path = "sprites/$dir/${name.toLowerCase()}.png"
fun load() = manager.load<Texture>(path)
operator fun invoke() = manager.getAsset<Texture>(path)
companion object {
var manager: AssetManager = Assets.manager
}
}
@@ -18,8 +18,6 @@ object QuestOfCon : Game() {
GameData.register()
println("loading assets")
Textures.values().forEach { it.load() }
TerrainTextures.values().forEach { it.load() }
Assets.load()
Assets.manager.finishLoading()
@@ -2,10 +2,10 @@ package io.github.plenglin.questofcon.game
import io.github.plenglin.questofcon.Assets
import io.github.plenglin.questofcon.Constants
import io.github.plenglin.questofcon.TerrainTextures
import io.github.plenglin.questofcon.game.building.*
import io.github.plenglin.questofcon.game.building.BuildingType
import io.github.plenglin.questofcon.game.grid.Biome
import io.github.plenglin.questofcon.game.pawn.*
import io.github.plenglin.questofcon.game.pawn.PawnClass
import io.github.plenglin.questofcon.game.pawn.PawnType
import io.github.plenglin.util.ObjectRegistry
@@ -92,12 +92,14 @@ object GameData {
displayName = "headquarters"
upkeep = -Constants.BASE_ECO
power = -100
texture = { Assets[Assets.headquarters] }
}
val factory = BuildingType("bldg-factory").apply {
displayName = "factory"
upkeep = 0
power = 10
texture = { Assets[Assets.factory] }
/*buildable = listOf(
)*/
@@ -107,14 +109,15 @@ object GameData {
displayName = "headquarters"
upkeep = -30
power = 10
texture = { Assets[Assets.mine] }
}
val beach = Biome("biome-beach", "beach", TerrainTextures.SAND, true, false)
val desert = Biome("biome-desert", "desert", TerrainTextures.SAND, true, false)
val grass = Biome("biome-grassland", "grassland", TerrainTextures.GRASS, true, true)
val highlands = Biome("biome-highlands", "highlands", TerrainTextures.BIGHILL, true, false, movementCost = 2)
val water = Biome("biome-water", "water", TerrainTextures.WATER, false, false)
val mountains = Biome("biome-mountains", "mountains", TerrainTextures.MOUNTAIN, false, false)
val beach = Biome("biome-beach", "beach", true, false, { Assets[Assets.sand] })
val desert = Biome("biome-desert", "desert", true, false, { Assets[Assets.sand] })
val grass = Biome("biome-grassland", "grassland", true, true, { Assets[Assets.grass] })
val highlands = Biome("biome-highlands", "highlands", true, false, { Assets[Assets.bighill] }, movementCost = 2)
val water = Biome("biome-water", "water", false, false, { Assets[Assets.water] })
val mountains = Biome("biome-mountains", "mountains", false, false, { Assets[Assets.mountain] })
fun register() {
pawns.register(grunt)
@@ -5,7 +5,6 @@ import io.github.plenglin.questofcon.Assets
import io.github.plenglin.questofcon.game.BuildableType
import io.github.plenglin.questofcon.game.Team
import io.github.plenglin.questofcon.game.grid.WorldCoords
import io.github.plenglin.questofcon.game.pawn.Pawn
import io.github.plenglin.questofcon.game.pawn.PawnType
import io.github.plenglin.util.Registerable
@@ -1,10 +1,11 @@
package io.github.plenglin.questofcon.game.grid
import com.badlogic.gdx.graphics.Texture
import io.github.plenglin.questofcon.Assets
import io.github.plenglin.util.Registerable
import io.github.plenglin.questofcon.TerrainTextures
data class Biome(override val name: String, val displayName: String, val texture: TerrainTextures, val passable: Boolean, val buildable: Boolean, val movementCost: Int = 1) : Registerable {
data class Biome(override val name: String, val displayName: String, val passable: Boolean, val buildable: Boolean, val texture: () -> Texture = Assets.missingno, val movementCost: Int = 1) : Registerable {
override var id: Long = -1L
override fun toString(): String {
@@ -5,7 +5,7 @@ import com.badlogic.gdx.math.Vector3
import ktx.math.*
class CameraTransformBuffer(val camera: OrthographicCamera, val maxPositionSize: Int = 15, val maxZoomSize: Int = 20) {
class CameraTransformBuffer(val camera: OrthographicCamera, val maxPositionSize: Int = 10, val maxZoomSize: Int = 20) {
private val positions = mutableListOf<Vector3>()
private val zooms = mutableListOf<Float>()
@@ -45,7 +45,7 @@ class WorldRenderer(val world: World) {
val x = i.toFloat()
col.forEachIndexed { j, tile ->
val y = j.toFloat()
batch.draw(tile.biome.texture.bg(), x, y, 1f, 1f)
batch.draw(tile.biome.texture(), x, y, 1f, 1f)
}
}
@@ -74,12 +74,12 @@ class WorldRenderer(val world: World) {
shape.end()
// Draw in the selection sets
Gdx.gl.glEnable(GL20.GL_BLEND);
Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
Gdx.gl.glEnable(GL20.GL_BLEND)
Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA)
shape.begin()
paints.forEach { it.draw(shape) }
shape.end()
Gdx.gl.glDisable(GL20.GL_BLEND);
Gdx.gl.glDisable(GL20.GL_BLEND)
// Draw buildings
batch.enableBlending()
@@ -117,7 +117,7 @@ class WorldRenderer(val world: World) {
if (pawn != null) {
val tex = pawn.texture ?: Assets[Assets.missing]
val tex = pawn.texture
val y = j.toFloat()
// Team outline
@@ -266,6 +266,7 @@ object RadialMenuInputManager : KtxInputAdapter {
return if (selection.tile?.canBuildOn(currentTeam) == true)
listOf(RadialMenuItem("Build HQ", {
UI.targetPlayerInterface.makeBuilding(selectedCoord, GameData.hq)
currentTeam.hasBuiltHQ = true
}))
else emptyList()
}

0 comments on commit be515cd

Please sign in to comment.