Compare commits
3 Commits
6887e65a70
...
23eefd9408
| Author | SHA1 | Date | |
|---|---|---|---|
| 23eefd9408 | |||
| 331efe5030 | |||
| 7bf7b0501c |
@@ -20,6 +20,7 @@ class Colin
|
|||||||
{
|
{
|
||||||
private var pos = Vector2()
|
private var pos = Vector2()
|
||||||
private var angle = 0.0f
|
private var angle = 0.0f
|
||||||
|
private var offsAngle = Vector2()
|
||||||
private var cam: PerspectiveCamera
|
private var cam: PerspectiveCamera
|
||||||
private var nutted = false
|
private var nutted = false
|
||||||
|
|
||||||
@@ -40,7 +41,8 @@ class Colin
|
|||||||
cam.position.set(Vector3(pos.x, 1.0f, pos.y))
|
cam.position.set(Vector3(pos.x, 1.0f, pos.y))
|
||||||
val forward = Vector3(0.0f, 0.0f, -1.0f)
|
val forward = Vector3(0.0f, 0.0f, -1.0f)
|
||||||
val up = Vector3(0.0f, 1.0f, 0.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()
|
cam.update()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,6 +72,14 @@ class Colin
|
|||||||
if (!stick.isZero)
|
if (!stick.isZero)
|
||||||
pos -= forward * stick.y * speed * deltaTime
|
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 (Controllers.getCurrent()?.let { pad -> pad.getButton(pad.mapping.buttonA) } == true || Gdx.input.isKeyJustPressed(Input.Keys.N))
|
||||||
{
|
{
|
||||||
if (!nutted)
|
if (!nutted)
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import com.badlogic.gdx.graphics.g2d.BitmapFont
|
|||||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||||
import com.badlogic.gdx.graphics.g3d.*
|
import com.badlogic.gdx.graphics.g3d.*
|
||||||
import com.badlogic.gdx.graphics.g3d.attributes.ColorAttribute
|
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.IntAttribute
|
||||||
import com.badlogic.gdx.graphics.g3d.attributes.TextureAttribute
|
import com.badlogic.gdx.graphics.g3d.attributes.TextureAttribute
|
||||||
import com.badlogic.gdx.graphics.g3d.environment.DirectionalLight
|
import com.badlogic.gdx.graphics.g3d.environment.DirectionalLight
|
||||||
@@ -42,13 +43,16 @@ class Game: ApplicationAdapter()
|
|||||||
{
|
{
|
||||||
val modelBuilder = ModelBuilder()
|
val modelBuilder = ModelBuilder()
|
||||||
val size = 2.0f
|
val size = 2.0f
|
||||||
//val material = Material(ColorAttribute.createDiffuse(Color.WHITE))
|
val material = Material(
|
||||||
val material = Material(TextureAttribute(TextureAttribute.Diffuse,
|
ColorAttribute.createDiffuse(XnaColor.White),
|
||||||
|
TextureAttribute(TextureAttribute.Diffuse,
|
||||||
TextureDescriptor(texture,
|
TextureDescriptor(texture,
|
||||||
Texture.TextureFilter.Linear,
|
Texture.TextureFilter.Linear,
|
||||||
Texture.TextureFilter.Linear,
|
Texture.TextureFilter.Linear,
|
||||||
Texture.TextureWrap.ClampToEdge,
|
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
|
val attribs = VertexAttributes.Usage.Position or VertexAttributes.Usage.TextureCoordinates or VertexAttributes.Usage.Normal
|
||||||
return modelBuilder.createBox(size, size, size, material, attribs.toLong())
|
return modelBuilder.createBox(size, size, size, material, attribs.toLong())
|
||||||
}
|
}
|
||||||
@@ -56,8 +60,11 @@ class Game: ApplicationAdapter()
|
|||||||
private fun makeFloor(texture: Texture): Model
|
private fun makeFloor(texture: Texture): Model
|
||||||
{
|
{
|
||||||
val modelBuilder = ModelBuilder()
|
val modelBuilder = ModelBuilder()
|
||||||
//val material = Material(ColorAttribute.createDiffuse(XnaColor.BlanchedAlmond))
|
val material = Material(
|
||||||
val material = Material(TextureAttribute.createDiffuse(texture))
|
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 attribs = VertexAttributes.Usage.Position or VertexAttributes.Usage.TextureCoordinates or VertexAttributes.Usage.Normal
|
||||||
val size = 10.0f
|
val size = 10.0f
|
||||||
return modelBuilder.createRect(
|
return modelBuilder.createRect(
|
||||||
@@ -76,7 +83,11 @@ class Game: ApplicationAdapter()
|
|||||||
|
|
||||||
texJolk = assetManager.get("jolkmeup.jpg")
|
texJolk = assetManager.get("jolkmeup.jpg")
|
||||||
fntComic = assetManager.get("Comic Sans MS.ttf")
|
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)
|
cube = makeCube(texJolk)
|
||||||
floor = makeFloor(assetManager.get("cobblestone.png"))
|
floor = makeFloor(assetManager.get("cobblestone.png"))
|
||||||
@@ -101,7 +112,7 @@ class Game: ApplicationAdapter()
|
|||||||
|
|
||||||
cubeInstance = ModelInstance(cube)
|
cubeInstance = ModelInstance(cube)
|
||||||
floorInstance = ModelInstance(floor)
|
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)
|
suzanneInstance.transform = Matrix4().translate(3.0f, 1.0f, -3.5f)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package gay.pizza.CavesOfJolk
|
package gay.pizza.CavesOfJolk
|
||||||
|
|
||||||
import com.badlogic.gdx.graphics.Color
|
import com.badlogic.gdx.graphics.Color
|
||||||
|
import com.badlogic.gdx.math.MathUtils
|
||||||
import com.badlogic.gdx.math.Vector2
|
import com.badlogic.gdx.math.Vector2
|
||||||
import ktx.math.div
|
import ktx.math.div
|
||||||
import ktx.math.times
|
import ktx.math.times
|
||||||
@@ -51,3 +52,9 @@ fun Color.lighten(ld: Double): Color
|
|||||||
val rgb = HUSLColorConverter.hsluvToRgb(hsl)
|
val rgb = HUSLColorConverter.hsluvToRgb(hsl)
|
||||||
return Color(rgb[0].toFloat(), rgb[1].toFloat(), rgb[2].toFloat(), a)
|
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))
|
||||||
|
|||||||
Reference in New Issue
Block a user