Work through the Simple Game Extended section
This commit is contained in:
@@ -0,0 +1,29 @@
|
|||||||
|
package com.badlogic.drop
|
||||||
|
|
||||||
|
import com.badlogic.gdx.Game
|
||||||
|
import com.badlogic.gdx.Gdx
|
||||||
|
import com.badlogic.gdx.graphics.g2d.BitmapFont
|
||||||
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||||
|
import com.badlogic.gdx.utils.viewport.FitViewport
|
||||||
|
|
||||||
|
class Drop : Game() {
|
||||||
|
val batch: SpriteBatch = SpriteBatch()
|
||||||
|
val viewport: FitViewport = FitViewport(8f, 5f) // We put viewport above font for the .appy scope function
|
||||||
|
val font: BitmapFont = BitmapFont().apply {
|
||||||
|
setUseIntegerPositions(false)
|
||||||
|
data.scale(viewport.worldHeight / Gdx.graphics.height)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun create(): Unit {
|
||||||
|
this.screen = MainMenuScreen(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun render() {
|
||||||
|
super.render()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun dispose() {
|
||||||
|
batch.dispose()
|
||||||
|
font.dispose()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
package com.badlogic.drop
|
||||||
|
|
||||||
|
import com.badlogic.gdx.Screen
|
||||||
|
|
||||||
|
class GameScreen(val newGame: Drop) : Screen {
|
||||||
|
override fun show() {
|
||||||
|
TODO("Not yet implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun render(delta: Float) {
|
||||||
|
TODO("Not yet implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun resize(width: Int, height: Int) {
|
||||||
|
TODO("Not yet implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun pause() {
|
||||||
|
TODO("Not yet implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun resume() {
|
||||||
|
TODO("Not yet implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun hide() {
|
||||||
|
TODO("Not yet implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun dispose() {
|
||||||
|
TODO("Not yet implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
package com.badlogic.drop
|
||||||
|
|
||||||
|
import com.badlogic.gdx.Screen
|
||||||
|
import com.badlogic.gdx.Gdx
|
||||||
|
import com.badlogic.gdx.graphics.Color
|
||||||
|
import com.badlogic.gdx.utils.ScreenUtils
|
||||||
|
|
||||||
|
class MainMenuScreen(val newGame: Drop) : Screen {
|
||||||
|
|
||||||
|
val game: Drop = newGame
|
||||||
|
|
||||||
|
override fun show() {
|
||||||
|
TODO("Not yet implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun render(delta: Float) {
|
||||||
|
ScreenUtils.clear(Color.BLACK)
|
||||||
|
|
||||||
|
game.viewport.apply()
|
||||||
|
game.batch.projectionMatrix = game.viewport.camera.combined
|
||||||
|
|
||||||
|
game.batch.begin()
|
||||||
|
|
||||||
|
game.font.draw(game.batch, "Wekcine to Drop!!!", 1f, 1.5f)
|
||||||
|
game.font.draw(game.batch, "Tap anywhere to begin!", 1f, 1f)
|
||||||
|
|
||||||
|
game.batch.end()
|
||||||
|
|
||||||
|
if (Gdx.input.isTouched) {
|
||||||
|
game.screen = GameScreen(game)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun resize(width: Int, height: Int) {
|
||||||
|
TODO("Not yet implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun pause() {
|
||||||
|
TODO("Not yet implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun resume() {
|
||||||
|
TODO("Not yet implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun hide() {
|
||||||
|
TODO("Not yet implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun dispose() {
|
||||||
|
TODO("Not yet implemented")
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user