game: update to truly center text and rect

This commit is contained in:
LeHaine 2024-01-22 11:24:04 -05:00
parent 511b1fb9db
commit 6ed7d19c96
No known key found for this signature in database
GPG key ID: 8AEC4F9B9F33E9AC

View file

@ -2,10 +2,12 @@ package com.game.template
import com.lehaine.littlekt.Context
import com.lehaine.littlekt.ContextListener
import com.lehaine.littlekt.graph.node.resource.HAlign
import com.lehaine.littlekt.graphics.Color
import com.lehaine.littlekt.graphics.Fonts
import com.lehaine.littlekt.graphics.g2d.*
import com.lehaine.littlekt.graphics.g2d.SpriteBatch
import com.lehaine.littlekt.graphics.g2d.shape.ShapeRenderer
import com.lehaine.littlekt.graphics.g2d.use
import com.lehaine.littlekt.graphics.gl.ClearBufferMask
import com.lehaine.littlekt.graphics.toFloatBits
import com.lehaine.littlekt.math.geom.degrees
@ -33,8 +35,8 @@ class Game(context: Context) : ContextListener(context) {
gl.clear(ClearBufferMask.COLOR_BUFFER_BIT)
batch.use(camera.viewProjection) {
Fonts.default.draw(it, "Hello LittleKt!", -15f, 0f)
shapeRenderer.filledRectangle(-25f, 50f, 100f, 50f, rotation, color = Color.RED.toFloatBits())
Fonts.default.draw(it, "Hello LittleKt!", 0f, 0f, align = HAlign.CENTER)
shapeRenderer.filledRectangle(-50f, 50f, 100f, 50f, rotation, color = Color.RED.toFloatBits())
}
rotationTimer += dt
if (rotationTimer > 10.milliseconds) {