Skip to content

Instantly share code, notes, and snippets.

@tk3
Created March 22, 2021 14:22
Show Gist options
  • Save tk3/e53a3141c352c9ebe3e99d273f3db870 to your computer and use it in GitHub Desktop.
Save tk3/e53a3141c352c9ebe3e99d273f3db870 to your computer and use it in GitHub Desktop.
name := "kata01"
version := "0.1"
scalaVersion := "2.13.5"
libraryDependencies ++= Seq (
"com.badlogicgames.gdx" % "gdx-backend-lwjgl" % "1.9.12",
"com.badlogicgames.gdx" % "gdx-platform" % "1.9.12" classifier "natives-desktop",
)
import com.badlogic.gdx.backends.lwjgl.{LwjglApplication, LwjglApplicationConfiguration}
object DesktopLauncher extends App {
val config = new LwjglApplicationConfiguration
new LwjglApplication(new MyGdxGame, config)
}
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import com.badlogic.gdx.graphics.{GL20, Texture}
import com.badlogic.gdx.{ApplicationAdapter, Gdx}
class MyGdxGame extends ApplicationAdapter {
lazy val batch = new SpriteBatch
lazy val img = new Texture("assets/hello.png")
override def create(): Unit = {}
override def render(): Unit = {
Gdx.gl.glClearColor(1, 0, 0, 1)
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT)
batch.begin()
batch.draw(img, 0, 0)
batch.end()
}
override def clone(): Unit = {
img.dispose()
batch.dispose()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment