Commit e42f521e authored by Mathias O. Myklebust's avatar Mathias O. Myklebust 🦆
Browse files

Merge branch 'blue-converted-your-side' into 'master'

Make friendly converted units green

See merge request !57
parents 6597f289 5b6cb859
Pipeline #175804 failed with stages
in 9 minutes and 33 seconds
#ifdef GL_ES
precision mediump float;
#endif
varying vec4 v_color;
varying vec2 v_texCoords;
uniform sampler2D u_texture;
void main() {
vec4 c = v_color * texture2D(u_texture, v_texCoords);
float color = (c.r + c.g + c.b) / 3.0;
gl_FragColor = vec4(color / 3.0, color / 3.0, color, c.a);
}
#ifdef GL_ES
precision mediump float;
#endif
varying vec4 v_color;
varying vec2 v_texCoords;
uniform sampler2D u_texture;
void main() {
vec4 c = v_color * texture2D(u_texture, v_texCoords);
float color = (c.r + c.g + c.b) / 3.0;
gl_FragColor = vec4(color, color, color, c.a);
}
#ifdef GL_ES
precision mediump float;
#endif
varying vec4 v_color;
varying vec2 v_texCoords;
uniform sampler2D u_texture;
void main() {
vec4 c = v_color * texture2D(u_texture, v_texCoords);
float color = (c.r + c.g + c.b) / 3.0;
gl_FragColor = vec4(color / 3.0, color, color / 3.0, c.a);
}
......@@ -357,16 +357,20 @@ class BattleController(
for (unitClass in hero.army) {
val controller = when (unitClass) {
GuardGoose::class -> UnitController(
GuardGoose(hero), UnitView(UnitSprite.GUARD_GOOSE, direction)
GuardGoose(hero),
UnitView(UnitSprite.GUARD_GOOSE, direction, isThisPlayer)
)
DelinquentDuck::class -> UnitController(
DelinquentDuck(hero), UnitView(UnitSprite.DELINQUENT_DUCK, direction)
DelinquentDuck(hero),
UnitView(UnitSprite.DELINQUENT_DUCK, direction, isThisPlayer)
)
PrivatePenguin::class -> UnitController(
PrivatePenguin(hero), UnitView(UnitSprite.PRIVATE_PENGUIN, direction)
PrivatePenguin(hero),
UnitView(UnitSprite.PRIVATE_PENGUIN, direction, isThisPlayer)
)
SpitfireSeagull::class -> UnitController(
SpitfireSeagull(hero), UnitView(UnitSprite.SPITFIRE_SEAGULL, direction)
SpitfireSeagull(hero),
UnitView(UnitSprite.SPITFIRE_SEAGULL, direction, isThisPlayer)
)
else -> throw NotImplementedError(
"No controller creator for unit class " +
......
......@@ -9,8 +9,7 @@ import se.battlegoo.battlegoose.views.UnitView
open class UnitController(
val unitModel: UnitModel,
private val unitView: UnitView
) :
ControllerBase(unitView) {
) : ControllerBase(unitView) {
// Extra backing property to allow accessors with non-default implementations while delegating
private var _viewSize: ScreenVector by unitView::size
......
package se.battlegoo.battlegoose.views
import com.badlogic.gdx.Gdx
import com.badlogic.gdx.graphics.glutils.ShaderProgram
object RedShiftShader : ShaderProgram(
// No-op vertex shader
Gdx.files.internal("shaders/noop.vert"),
// Red-shifting fragment shader
Gdx.files.internal("shaders/redShift.frag")
)
package se.battlegoo.battlegoose.views
import com.badlogic.gdx.Gdx
import com.badlogic.gdx.graphics.glutils.ShaderProgram
sealed class Shaders(
vertexShaders: VertexShaders,
fragmentShaders: FragmentShaders
) : ShaderProgram(
Gdx.files.internal(vertexShaders.path),
Gdx.files.internal(fragmentShaders.path)
) {
object RedShift : Shaders(
VertexShaders.NOOP,
FragmentShaders.RED_SHIFT
)
object GreenShift : Shaders(
VertexShaders.NOOP,
FragmentShaders.GREEN_SHIFT
)
object BlueShift : Shaders(
VertexShaders.NOOP,
FragmentShaders.BLUE_SHIFT
)
object Grayscale : Shaders(
VertexShaders.NOOP,
FragmentShaders.GRAYSCALE
)
}
enum class VertexShaders(val path: String) {
NOOP("shaders/noop.vert"),
}
enum class FragmentShaders(val path: String) {
BLUE_SHIFT("shaders/blueShift.frag"),
GREEN_SHIFT("shaders/greenShift.frag"),
RED_SHIFT("shaders/redShift.frag"),
GRAYSCALE("shaders/grayscale.frag"),
}
......@@ -5,7 +5,8 @@ import se.battlegoo.battlegoose.utils.TextureAsset
class UnitView(
unitSprite: UnitSprite,
val textureStartFacingDirection: FacingDirection
val textureStartFacingDirection: FacingDirection,
val ownedByThisPlayer: Boolean = true
) : SpriteViewBase(
when (unitSprite) {
UnitSprite.PRIVATE_PENGUIN -> TextureAsset.UNIT_PRIVATE_PENGUIN
......@@ -35,7 +36,7 @@ class UnitView(
override fun render(sb: SpriteBatch) {
val previousShader = sb.shader
if (converted) {
sb.shader = RedShiftShader
sb.shader = if (ownedByThisPlayer) Shaders.RedShift else Shaders.GreenShift
}
super.render(sb)
sb.shader = previousShader
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment