Compare commits

...

3 Commits

3 changed files with 39 additions and 11 deletions

View File

@@ -20,6 +20,7 @@ class Colin
{
private var pos = Vector2()
private var angle = 0.0f
private var offsAngle = Vector2()
private var cam: PerspectiveCamera
private var nutted = false
@@ -40,7 +41,8 @@ class Colin
cam.position.set(Vector3(pos.x, 1.0f, pos.y))
val forward = Vector3(0.0f, 0.0f, -1.0f)
val up = Vector3(0.0f, 1.0f, 0.0f)
cam.direction.set(forward.rotateRad(up, angle))
val right = Vector3(1.0f, 0.0f, 0.0f)
cam.direction.set(forward.rotateRad(right, offsAngle.y).rotateRad(up, offsAngle.x + angle))
cam.update()
}
@@ -70,6 +72,14 @@ class Colin
if (!stick.isZero)
pos -= forward * stick.y * speed * deltaTime
offsAngle = Controllers.getCurrent()?.let { pad ->
val dst = Vector2(
pad.getAxis(pad.mapping.axisRightX),
pad.getAxis(pad.mapping.axisRightY))
.radialDeadzone(0.1f, 1.0f) * MathUtils.PI * -0.25f
offsAngle.lerp(dst, 16.0f * deltaTime)
} ?: Vector2.Zero
if (Controllers.getCurrent()?.let { pad -> pad.getButton(pad.mapping.buttonA) } == true || Gdx.input.isKeyJustPressed(Input.Keys.N))
{
if (!nutted)

View File

@@ -8,6 +8,7 @@ import com.badlogic.gdx.graphics.g2d.BitmapFont
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import com.badlogic.gdx.graphics.g3d.*
import com.badlogic.gdx.graphics.g3d.attributes.ColorAttribute
import com.badlogic.gdx.graphics.g3d.attributes.FloatAttribute
import com.badlogic.gdx.graphics.g3d.attributes.IntAttribute
import com.badlogic.gdx.graphics.g3d.attributes.TextureAttribute
import com.badlogic.gdx.graphics.g3d.environment.DirectionalLight
@@ -42,13 +43,16 @@ class Game: ApplicationAdapter()
{
val modelBuilder = ModelBuilder()
val size = 2.0f
//val material = Material(ColorAttribute.createDiffuse(Color.WHITE))
val material = Material(TextureAttribute(TextureAttribute.Diffuse,
val material = Material(
ColorAttribute.createDiffuse(XnaColor.White),
TextureAttribute(TextureAttribute.Diffuse,
TextureDescriptor(texture,
Texture.TextureFilter.Linear,
Texture.TextureFilter.Linear,
Texture.TextureWrap.ClampToEdge,
Texture.TextureWrap.ClampToEdge)))
Texture.TextureWrap.ClampToEdge)),
ColorAttribute.createSpecular(XnaColor.Gray),
FloatAttribute.createShininess(20.0f))
val attribs = VertexAttributes.Usage.Position or VertexAttributes.Usage.TextureCoordinates or VertexAttributes.Usage.Normal
return modelBuilder.createBox(size, size, size, material, attribs.toLong())
}
@@ -56,8 +60,11 @@ class Game: ApplicationAdapter()
private fun makeFloor(texture: Texture): Model
{
val modelBuilder = ModelBuilder()
//val material = Material(ColorAttribute.createDiffuse(XnaColor.BlanchedAlmond))
val material = Material(TextureAttribute.createDiffuse(texture))
val material = Material(
ColorAttribute.createDiffuse(XnaColor.BlanchedAlmond.lighten(0.01)),
ColorAttribute.createSpecular(XnaColor.BlanchedAlmond.mix(XnaColor.Black, 0.4f)),
FloatAttribute.createShininess(65.0f),
TextureAttribute.createDiffuse(texture))
val attribs = VertexAttributes.Usage.Position or VertexAttributes.Usage.TextureCoordinates or VertexAttributes.Usage.Normal
val size = 10.0f
return modelBuilder.createRect(
@@ -76,7 +83,11 @@ class Game: ApplicationAdapter()
texJolk = assetManager.get("jolkmeup.jpg")
fntComic = assetManager.get("Comic Sans MS.ttf")
val suzanne = assetManager.get("suzanne.g3db", Model::class.java)
// Override ridiculous shininess because i cbf to fix the model
for (i in suzanne.materials)
i.set(FloatAttribute.createShininess(30.0f))
cube = makeCube(texJolk)
floor = makeFloor(assetManager.get("cobblestone.png"))
@@ -101,7 +112,7 @@ class Game: ApplicationAdapter()
cubeInstance = ModelInstance(cube)
floorInstance = ModelInstance(floor)
suzanneInstance = ModelInstance(assetManager.get("suzanne.g3db", Model::class.java))
suzanneInstance = ModelInstance(suzanne)
suzanneInstance.transform = Matrix4().translate(3.0f, 1.0f, -3.5f)
}

View File

@@ -1,6 +1,7 @@
package gay.pizza.CavesOfJolk
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.math.MathUtils
import com.badlogic.gdx.math.Vector2
import ktx.math.div
import ktx.math.times
@@ -51,3 +52,9 @@ fun Color.lighten(ld: Double): Color
val rgb = HUSLColorConverter.hsluvToRgb(hsl)
return Color(rgb[0].toFloat(), rgb[1].toFloat(), rgb[2].toFloat(), a)
}
fun Color.mix(rhs: Color, x: Float) = Color(
MathUtils.lerp(this.r, rhs.r, x),
MathUtils.lerp(this.g, rhs.g, x),
MathUtils.lerp(this.b, rhs.b, x),
MathUtils.lerp(this.a, rhs.a, x))