diff --git a/assets/down.png b/assets/down.png new file mode 100644 index 0000000000000000000000000000000000000000..eef12f93f7ac558175ada4be92053f5d5eb32c9e Binary files /dev/null and b/assets/down.png differ diff --git a/assets/up.png b/assets/up.png new file mode 100644 index 0000000000000000000000000000000000000000..4441efdcdcbff26421e1bdc1c4751bbe466a958d Binary files /dev/null and b/assets/up.png differ diff --git a/core/src/tdt4240/netrunner/Netrunner.kt b/core/src/tdt4240/netrunner/Netrunner.kt index f9a580f1c45f97eca072c0cf76274af5bf608d06..f3ce50d84f6380c0f10fecad8465f752e6cb84cd 100644 --- a/core/src/tdt4240/netrunner/Netrunner.kt +++ b/core/src/tdt4240/netrunner/Netrunner.kt @@ -22,8 +22,6 @@ class Netrunner : Game() { lateinit var uiViewport: Viewport var characterTextures = mutableMapOf<PlayerColor, Texture>() - //private var position: Vector2 = Vector2(300f, 0f) - //private var speed: Float = 10.0f; override fun create() { val localProps = Gdx.files.internal("local-game.properties") diff --git a/core/src/tdt4240/netrunner/view/GameScreen.kt b/core/src/tdt4240/netrunner/view/GameScreen.kt index d6b4761efea75a19c6019df89ce9a86483e1c6bf..b3746642ca30949ecefe589db6bd39abc8982349 100644 --- a/core/src/tdt4240/netrunner/view/GameScreen.kt +++ b/core/src/tdt4240/netrunner/view/GameScreen.kt @@ -5,11 +5,16 @@ import com.badlogic.gdx.ScreenAdapter import com.badlogic.gdx.graphics.Color import com.badlogic.gdx.graphics.GL20 import com.badlogic.gdx.graphics.OrthographicCamera +import com.badlogic.gdx.graphics.Texture import com.badlogic.gdx.scenes.scene2d.InputEvent import com.badlogic.gdx.scenes.scene2d.Stage +import com.badlogic.gdx.scenes.scene2d.ui.ImageButton +import com.badlogic.gdx.scenes.scene2d.ui.ImageButton.ImageButtonStyle import com.badlogic.gdx.scenes.scene2d.ui.Table import com.badlogic.gdx.scenes.scene2d.ui.TextButton import com.badlogic.gdx.scenes.scene2d.utils.ClickListener +import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable +import org.slf4j.LoggerFactory import tdt4240.netrunner.Netrunner import tdt4240.netrunner.game.GameController @@ -17,6 +22,10 @@ class GameScreen(private val game: Netrunner, private val controller: GameContro private val stage = Stage(game.uiViewport) private var cam = OrthographicCamera(Netrunner.MIN_WIDTH, Netrunner.MIN_HEIGHT) + companion object { + private val logger = LoggerFactory.getLogger(Netrunner::class.java) + } + init { val buttonStyle = TextButton.TextButtonStyle() buttonStyle.font = game.skin.getFont("default-font") @@ -40,6 +49,39 @@ class GameScreen(private val game: Netrunner, private val controller: GameContro table.add(exitButton).pad(50f).expand().top().right() table.row() stage.addActor(table) + + val imageButtonUpStyle = ImageButtonStyle() + val drawableUp = TextureRegionDrawable(Texture("up.png")) + imageButtonUpStyle.imageUp = drawableUp + imageButtonUpStyle.imageDown = drawableUp + val buttonUp = ImageButton(imageButtonUpStyle) + buttonUp.setPosition(550f, 100f) + buttonUp.isTransform = true + buttonUp.setScale(0.4f) + buttonUp.addListener(object : ClickListener() { + override fun clicked(event: InputEvent?, x: Float, y: Float) { + // TODO: Send to server? + logger.info("Button UP clicked!") + } + }) + stage.addActor(buttonUp) + + val imageButtonDownStyle = ImageButtonStyle() + val drawableDown = TextureRegionDrawable(Texture("down.png")) + imageButtonDownStyle.imageUp = drawableDown + imageButtonDownStyle.imageDown = drawableDown + val buttonDown = ImageButton(imageButtonDownStyle) + buttonDown.setPosition(550f, 20f) + buttonDown.isTransform = true + buttonDown.setScale(0.4f) + buttonDown.addListener(object : ClickListener() { + override fun clicked(event: InputEvent?, x: Float, y: Float) { + // TODO: Send to server? + logger.info("Button DOWN clicked!") + } + }) + stage.addActor(buttonDown) + } override fun show() {