Skip to content

Commit

Permalink
Fix graphic issues
Browse files Browse the repository at this point in the history
  • Loading branch information
EmmanuelMess committed Jul 2, 2020
1 parent bd7ce59 commit 9c63a76
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ protected void onCreate (Bundle savedInstanceState) {
AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();
config.useAccelerometer = false;
config.useCompass = false;
config.numSamples = 2;
RelativeLayout layout = new RelativeLayout(this);
layout.addView(initializeForView(new TicTacToeGame(), config));
setContentView(layout);
Expand Down
1 change: 0 additions & 1 deletion core/src/com/emmanuelmess/tictactoe/DrawableShape.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.emmanuelmess.tictactoe

import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.glutils.ShapeRenderer
import com.badlogic.gdx.utils.viewport.Viewport

Expand Down
6 changes: 3 additions & 3 deletions core/src/com/emmanuelmess/tictactoe/OActor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ class OActor(
width: Float, height: Float
): DrawableShape(viewport, x, y, width, height) {
companion object {
const val WIDTH = 4f
const val WIDTH = 4f * TicTacToeGame.Size.C
}

override fun draw(shapeRenderer: ShapeRenderer) {
shapeRenderer.apply {
begin(ShapeRenderer.ShapeType.Filled)

color = Color.BLACK
circle(x + width/2, y + height/2, width/2, 16)
circle(x + width/2, y + height/2, width/2)

color = Color.WHITE
circle(x + width/2, y + height/2, width/2 - WIDTH, 16)
circle(x + width/2, y + height/2, width/2 - WIDTH)

end()
}
Expand Down
17 changes: 10 additions & 7 deletions core/src/com/emmanuelmess/tictactoe/TicTacToeGame.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,18 @@ const val DEBUG = true

class TicTacToeGame : ApplicationAdapter() {
object Size {
const val WIDTH = 100f
const val WIDTH = 1000f
const val HEIGHT = 16 * WIDTH / 9

const val C = 10f
}

object Grid {
const val STROKE_WIDTH = 2f
const val TOP = 45f
const val HEIGHT = 90f
const val LEFT = 15f
const val WIDTH = 70f
const val STROKE_WIDTH = 2f * Size.C
const val TOP = 45f * Size.C
const val HEIGHT = 90f * Size.C
const val LEFT = 15f * Size.C
const val WIDTH = 70f * Size.C
}

private lateinit var ticTacToeText: TicTacToeText
Expand Down Expand Up @@ -66,7 +68,8 @@ class TicTacToeGame : ApplicationAdapter() {

override fun render() {
Gdx.gl.glClearColor(1f, 1f, 1f, 1f)
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT)
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT or GL20.GL_DEPTH_BUFFER_BIT
or if(Gdx.graphics.bufferFormat.coverageSampling) GL20.GL_COVERAGE_BUFFER_BIT_NV else 0)

shapeRenderer.projectionMatrix = viewport.camera.combined

Expand Down
6 changes: 3 additions & 3 deletions core/src/com/emmanuelmess/tictactoe/TicTacToeRenderer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ class TicTacToeRenderer(
width: Float, height: Float
): DrawableShape(viewport, x, y, width, height) {
object XAndO {
const val MARGIN_O = 2f
const val MARGIN_X = 5f
const val MARGIN_O = 2f * TicTacToeGame.Size.C
const val MARGIN_X = 5f * TicTacToeGame.Size.C
}

enum class Piece {
Expand Down Expand Up @@ -177,7 +177,7 @@ class TicTacToeRenderer(
color = Color.RED

begin(ShapeRenderer.ShapeType.Filled)
rectLine(start, end, 2f)
rectLine(start, end, 2f * TicTacToeGame.Size.C)
end()
}
}
Expand Down
4 changes: 2 additions & 2 deletions core/src/com/emmanuelmess/tictactoe/XActor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ class XActor(viewport: Viewport, x: Float, y: Float, width: Float, height: Float

begin(ShapeRenderer.ShapeType.Filled)

rectLine(x, y, x + width, y + height, 5f)
rectLine(x, y + height, x + width, y, 5f)
rectLine(x, y, x + width, y + height, 5f * TicTacToeGame.Size.C)
rectLine(x, y + height, x + width, y, 5f * TicTacToeGame.Size.C)

end()
}
Expand Down

0 comments on commit 9c63a76

Please sign in to comment.