diff --git a/audio/README.md b/audio/README.md index c04a1ce..5ed2202 100644 --- a/audio/README.md +++ b/audio/README.md @@ -1,3 +1,7 @@ +**Note** + +> LibGDX provides [AssetManager](https://github.com/libgdx/libgdx/wiki/Managing-your-assets), which has a fully-fledged API for loading, storing and fetching assets (sounds, music, textures, fonts...). Using `AssetManager` (with maybe some DI framework) might be a more scalable and testable solution as projects grow in complexity. The manager modules (`ImageManager`, `SoundManger`, `MusicManager`...) may eventually become wrappers around `AssetManager`. Until then, they'll remain as singleton-based managers whose simplicity might come in handy for game jams or PoCs. + The audio package for Cyberpunk is split into two different utilities: [`SoundManager`](#soundmanager) and [`MusicManager`](#musicmanager). ### SoundManager @@ -23,12 +27,13 @@ SoundManager.pause("mysound") SoundManager.resume("mysound") ``` -Diposose it when you don't need to use it anymore - hey, leave a good footprint! +Dispose it when you don't need to use it anymore - hey, leave a good footprint! ```kotlin SoundManager.dispose("mysound") ``` ### MusicManager + The [`MusicManager`](https://github.com/ImXico/Cyberpunk/blob/master/audio/src/main/kotlin/cyberpunk/audio/MusicManager.kt) will hold [`Music`](https://github.com/libgdx/libgdx/wiki/Streaming-music) instances. As stated in the official libGDX [wiki](https://github.com/libgdx/libgdx/wiki/Streaming-music): > For any sound that's longer than a few seconds, it is preferable to stream it from disk instead of fully loading it into RAM. Libgdx provides a Music interface that lets you do that. diff --git a/core/README.md b/core/README.md index a3bf54e..9b54bbb 100644 --- a/core/README.md +++ b/core/README.md @@ -88,6 +88,7 @@ Start out by initializing the `StateManager`: private lateinit var stateManager: StateManager override fun create() { + // Have a Camera val camera = OrthographicCamera(WORLD_WIDTH.toFloat(), WORLD_HEIGHT.toFloat()) camera.position.set(viewportWidth / 2f, viewportHeight / 2f, 0f) diff --git a/core/src/main/kotlin/cyberpunk/core/WorldConfig.kt b/core/src/main/kotlin/cyberpunk/core/WorldConfig.kt index f789f1e..076c0f7 100644 --- a/core/src/main/kotlin/cyberpunk/core/WorldConfig.kt +++ b/core/src/main/kotlin/cyberpunk/core/WorldConfig.kt @@ -2,5 +2,5 @@ package cyberpunk.core -@JvmField val WORLD_WIDTH = 700 -@JvmField val WORLD_HEIGHT = 300 \ No newline at end of file +const val WORLD_WIDTH = 700 +const val WORLD_HEIGHT = 300 \ No newline at end of file diff --git a/core/src/main/kotlin/cyberpunk/core/state/StateAdapter.kt b/core/src/main/kotlin/cyberpunk/core/state/StateAdapter.kt index 6e07c85..2c74ad4 100644 --- a/core/src/main/kotlin/cyberpunk/core/state/StateAdapter.kt +++ b/core/src/main/kotlin/cyberpunk/core/state/StateAdapter.kt @@ -8,9 +8,9 @@ abstract class StateAdapter(protected val stateManager: StateManager) : State { /** * State methods that absolutely must be overridden. */ - override abstract fun update(delta: Float) - override abstract fun render(batch: Batch) - override abstract fun dispose() + abstract override fun update(delta: Float) + abstract override fun render(batch: Batch) + abstract override fun dispose() /** * State methods that may or may not be overridden (no-op implementation). diff --git a/core/src/main/kotlin/cyberpunk/core/state/StateManager.kt b/core/src/main/kotlin/cyberpunk/core/state/StateManager.kt index 61347f5..955e933 100644 --- a/core/src/main/kotlin/cyberpunk/core/state/StateManager.kt +++ b/core/src/main/kotlin/cyberpunk/core/state/StateManager.kt @@ -2,13 +2,12 @@ package cyberpunk.core.state import com.badlogic.gdx.Gdx import com.badlogic.gdx.graphics.Camera -import com.badlogic.gdx.graphics.Pixmap import com.badlogic.gdx.graphics.g2d.Batch import com.badlogic.gdx.graphics.g2d.SpriteBatch -import com.badlogic.gdx.graphics.g2d.TextureRegion import com.badlogic.gdx.graphics.glutils.FrameBuffer import com.badlogic.gdx.utils.viewport.Viewport import cyberpunk.core.transition.Transition +import cyberpunk.core.transition.TransitionFBO /** * Initializes the [StateManager] with it a [Camera] and [Viewport]. @@ -33,22 +32,15 @@ class StateManager(val camera: Camera, val viewport: Viewport) { private var transition: Transition? = null /** - * [FrameBuffer] objects and [TextureRegion]s for the transitions. - * Initialized at the init block, under [setupFBOs]. + * Holds the frame buffer objects (FBOs) and flipped regions + * that are used during transitions. */ - lateinit private var currentFBO: FrameBuffer - lateinit private var nextFBO: FrameBuffer - lateinit private var currentFlippedRegion: TextureRegion - lateinit private var nextFlippedRegion: TextureRegion + private val transitionFBO = TransitionFBO() /** * [Batch] used to render everything. */ - private val batch: Batch = SpriteBatch() - - init { - setupFBOs() - } + private val batch = SpriteBatch() /** * Sets a [State] to be the currently running one. Optionally, pass @@ -77,7 +69,9 @@ class StateManager(val camera: Camera, val viewport: Viewport) { */ fun update(delta: Float) { currentState?.update(delta) - transition?.let { if (it.running()) it.update(delta) } + transition?.let { + if (it.running()) it.update(delta) + } } /** @@ -98,11 +92,10 @@ class StateManager(val camera: Camera, val viewport: Viewport) { currentState?.render(batch) Gdx.input.inputProcessor = currentState } else { - currentFBO.wrap { currentState?.render(batch) } - nextFBO.wrap { nextState?.render(batch) } - currentFlippedRegion.texture = currentFBO.colorBufferTexture - nextFlippedRegion.texture = nextFBO.colorBufferTexture - transition?.render(batch, currentFlippedRegion, nextFlippedRegion) + transitionFBO.wrapCurrent { currentState?.render(batch) } + transitionFBO.wrapNext { nextState?.render(batch) } + val (currentRegion, nextRegion) = transitionFBO.getFlippedRegions() + transition?.render(batch, currentRegion, nextRegion) } } } @@ -144,34 +137,7 @@ class StateManager(val camera: Camera, val viewport: Viewport) { fun dispose() { currentState?.dispose() nextState?.dispose() - currentFBO.dispose() - nextFBO.dispose() - } - - /** - * Utility extension function to wrap any [block] inside the - * [FrameBuffer.begin] and [FrameBuffer.end] calls, for shortness. - * @param block a [Unit] returning function. - */ - private inline fun FrameBuffer.wrap(block: () -> Unit) { - this.begin() - block() - this.end() - } - - /** - * Initializes the [FrameBuffer] objects and the [TextureRegion]s that will - * serve any running [Transition]. - */ - private fun setupFBOs() { - val screenWidth = Gdx.graphics.width - val screenHeight = Gdx.graphics.height - currentFBO = FrameBuffer(Pixmap.Format.RGBA8888, screenWidth, screenHeight, false) - nextFBO = FrameBuffer(Pixmap.Format.RGBA8888, screenWidth, screenHeight, false) - currentFlippedRegion = TextureRegion(currentFBO.colorBufferTexture) - currentFlippedRegion.flip(false, true) - nextFlippedRegion = TextureRegion(nextFBO.colorBufferTexture) - nextFlippedRegion.flip(false, true) + transitionFBO.dispose() } /** @@ -179,10 +145,5 @@ class StateManager(val camera: Camera, val viewport: Viewport) { * @param width new screen width. * @param height new screen height. */ - private fun resizeFBOs(width: Int, height: Int) { - currentFBO.dispose() - nextFBO.dispose() - currentFBO = FrameBuffer(Pixmap.Format.RGBA8888, width, height, false) - nextFBO = FrameBuffer(Pixmap.Format.RGBA8888, width, height, false) - } + private fun resizeFBOs(width: Int, height: Int) = transitionFBO.resize(width, height) } \ No newline at end of file diff --git a/core/src/main/kotlin/cyberpunk/core/transition/Transition.kt b/core/src/main/kotlin/cyberpunk/core/transition/Transition.kt index a0fc9ea..2b157d8 100644 --- a/core/src/main/kotlin/cyberpunk/core/transition/Transition.kt +++ b/core/src/main/kotlin/cyberpunk/core/transition/Transition.kt @@ -28,13 +28,13 @@ interface Transition { * Checks whether or not this [Transition] is running. * @return true if it is running, false otherwise. */ - fun running(): Boolean = running + fun running() = running /** * Checks whether or not this [Transition] is completed. * @return true if it is completed, false otherwise. */ - fun completed(): Boolean = !running + fun completed() = !running /** * Updates the [Transition]. diff --git a/core/src/main/kotlin/cyberpunk/core/transition/TransitionFBO.kt b/core/src/main/kotlin/cyberpunk/core/transition/TransitionFBO.kt new file mode 100644 index 0000000..ea9abb9 --- /dev/null +++ b/core/src/main/kotlin/cyberpunk/core/transition/TransitionFBO.kt @@ -0,0 +1,91 @@ +package cyberpunk.core.transition + +import com.badlogic.gdx.Gdx +import com.badlogic.gdx.graphics.Pixmap +import com.badlogic.gdx.graphics.g2d.TextureRegion +import com.badlogic.gdx.graphics.glutils.FrameBuffer + +/** + * Holds the frame buffer objects (FBOs) and flipped regions + * that are used during state transitions. + */ +internal class TransitionFBO { + + /** + * [FrameBuffer] objects that are used to wrap render calls during state transitions. + */ + private var currentFBO: FrameBuffer + private var nextFBO: FrameBuffer + + /** + * [TextureRegion] objects that represent frames before and after a transition. + */ + private var currentFlippedRegion: TextureRegion + private var nextFlippedRegion: TextureRegion + + init { + val screenWidth = Gdx.graphics.width + val screenHeight = Gdx.graphics.height + currentFBO = FrameBuffer(Pixmap.Format.RGBA8888, screenWidth, screenHeight, false) + nextFBO = FrameBuffer(Pixmap.Format.RGBA8888, screenWidth, screenHeight, false) + currentFlippedRegion = TextureRegion(currentFBO.colorBufferTexture) + currentFlippedRegion.flip(false, true) + nextFlippedRegion = TextureRegion(nextFBO.colorBufferTexture) + nextFlippedRegion.flip(false, true) + } + + /** + * Dispose the current and next FBOs. + */ + internal fun dispose() { + currentFBO.dispose() + nextFBO.dispose() + } + + /** + * Resizes the [FrameBuffer] objects. + * The [FrameBuffer] objects are disposed manually and re-defined. + * @param width new screen width. + * @param height new screen height. + */ + internal fun resize(width: Int, height: Int) { + this.dispose() + currentFBO = FrameBuffer(Pixmap.Format.RGBA8888, width, height, false) + nextFBO = FrameBuffer(Pixmap.Format.RGBA8888, width, height, false) + } + + /** + * Render an arbitrary block onto the currentFBO. + * @param block a [Unit] returning function. + */ + internal fun wrapCurrent(block: () -> Unit) { + currentFBO.wrap { block() } + currentFlippedRegion.texture = currentFBO.colorBufferTexture + } + + /** + * Render an arbitrary block onto the nextFBO. + * @param block a [Unit] returning function. + */ + internal fun wrapNext(block: () -> Unit) { + nextFBO.wrap { block() } + nextFlippedRegion.texture = nextFBO.colorBufferTexture + } + + /** + * Return the current and next flipped regions in an easy-to-destruct way. + * @return a [Pair] holding both flipped regions. + */ + internal fun getFlippedRegions() = Pair(currentFlippedRegion, nextFlippedRegion) + + /** + * Utility extension function to wrap any [block] inside the + * [FrameBuffer.begin] and [FrameBuffer.end] calls, for shortness. + * @param block a [Unit] returning function. + */ + private inline fun FrameBuffer.wrap(block: () -> Unit) { + this.begin() + block() + this.end() + } +} diff --git a/core/src/main/kotlin/cyberpunk/core/transition/types/Fade.kt b/core/src/main/kotlin/cyberpunk/core/transition/types/Fade.kt index 2cf9ba7..cda4e0b 100644 --- a/core/src/main/kotlin/cyberpunk/core/transition/types/Fade.kt +++ b/core/src/main/kotlin/cyberpunk/core/transition/types/Fade.kt @@ -6,33 +6,31 @@ import cyberpunk.core.WORLD_HEIGHT import cyberpunk.core.WORLD_WIDTH import cyberpunk.core.transition.Transition -@JvmField val DEFAULT_SPEED: Float = 1.5f +const val DEFAULT_SPEED = 1.5f class Fade @JvmOverloads constructor(private var speed: Float = DEFAULT_SPEED) : Transition { - @JvmField val MAX_ALPHA: Float = 1f - @JvmField val DEFAULT_ALPHA_INC: Float = 0.05f + @JvmField val MAX_ALPHA = 1f + @JvmField val DEFAULT_ALPHA_INC = 0.05f /** * Overrides the property defined at the [Transition] interface. - * * @property [Transition.running] */ - override var running: Boolean = false + override var running = false /** * Current alpha, ranging from 0 to [MAX_ALPHA]. - * * @see MAX_ALPHA */ - private var alpha: Float = 0f + private var alpha = 0f /** * Alpha increment to be used at each frame */ - private val alphaInc: Float = calculateAlphaInc() + private val alphaInc = calculateAlphaInc() /** * @see [Transition.update] @@ -60,8 +58,7 @@ class Fade /** * Calculates the alpha increment to be used at each frame based on the [speed] property. - * * @return alpha increment. */ - private fun calculateAlphaInc(): Float = this.speed * DEFAULT_ALPHA_INC / DEFAULT_SPEED + private fun calculateAlphaInc() = this.speed * DEFAULT_ALPHA_INC / DEFAULT_SPEED } \ No newline at end of file diff --git a/core/src/main/kotlin/cyberpunk/core/transition/types/HorizontalSlide.kt b/core/src/main/kotlin/cyberpunk/core/transition/types/HorizontalSlide.kt index 3ac3db8..eba8c24 100644 --- a/core/src/main/kotlin/cyberpunk/core/transition/types/HorizontalSlide.kt +++ b/core/src/main/kotlin/cyberpunk/core/transition/types/HorizontalSlide.kt @@ -25,7 +25,7 @@ enum class Motion ( LEFT_TO_RIGHT(Vector2(), Vector2(-WORLD_WIDTH.toFloat(), 0f), Vector2(WORLD_WIDTH.toFloat(), 0f), Vector2()) } -@JvmField val DEFAULT_LERP = 0.2f +const val DEFAULT_LERP = 0.2f class HorizontalSlide @JvmOverloads @@ -35,17 +35,17 @@ class HorizontalSlide * Overrides the property defined at the [Transition] interface. * @property [Transition.running] */ - override var running: Boolean = false + override var running = false /** * Current position, in the form of a [Vector2], of the current state. */ - private val currentStateCurrentPos: Vector2 = motion.currentInitial + private val currentStateCurrentPos = motion.currentInitial /** * Current position, in the form of a [Vector2], of the next state. */ - private val nextStateCurrentPos: Vector2 = motion.nextInitial + private val nextStateCurrentPos = motion.nextInitial /** * Overrides the default [Transition.completed] function, declared diff --git a/image/README.md b/image/README.md index 9bdbdc7..0ec38f9 100644 --- a/image/README.md +++ b/image/README.md @@ -1,4 +1,8 @@ -Likewise the [`audio`](https://github.com/ImXico/Cyberpunk/tree/master/audio) module, the [`image`]() extension is also split in two classes: [`ImageManager`](https://github.com/ImXico/Cyberpunk/blob/master/image/src/main/kotlin/cyberpunk/image/ImageManager.kt) and [`ImageHelper`](https://github.com/ImXico/Cyberpunk/blob/master/image/src/main/kotlin/cyberpunk/image/ImageHelper.kt). +**Note** + +> LibGDX provides [AssetManager](https://github.com/libgdx/libgdx/wiki/Managing-your-assets), which has a fully-fledged API for loading, storing and fetching assets (sounds, music, textures, fonts...). Using `AssetManager` (with maybe some DI framework) might be a more scalable and testable solution as projects grow in complexity. The manager modules (`ImageManager`, `SoundManger`, `MusicManager`...) may eventually become wrappers around `AssetManager`. Until then, they'll remain as singleton-based managers whose simplicity might come in handy for game jams or PoCs. + +The [`image`]() extension is split in two classes: [`ImageManager`](https://github.com/ImXico/Cyberpunk/blob/master/image/src/main/kotlin/cyberpunk/image/ImageManager.kt) and [`ImageHelper`](https://github.com/ImXico/Cyberpunk/blob/master/image/src/main/kotlin/cyberpunk/image/ImageHelper.kt). ### ImageManager This is made to be used with [`TextureAtlas`](https://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/g2d/TextureAtlas.html). Information on how to use the TexturePacker to pack many smaller images onto larger images can be found [here](https://github.com/libgdx/libgdx/wiki/Texture-packer). diff --git a/image/src/main/kotlin/cyberpunk/image/ImageManager.kt b/image/src/main/kotlin/cyberpunk/image/ImageManager.kt index b20ff62..571c9e5 100644 --- a/image/src/main/kotlin/cyberpunk/image/ImageManager.kt +++ b/image/src/main/kotlin/cyberpunk/image/ImageManager.kt @@ -32,7 +32,7 @@ object ImageManager { @JvmOverloads fun load(key: String, path: String, setAsDefault: Boolean = false) { val atlas = TextureAtlas(Gdx.files.internal(path)) - atlases.put(key, atlas) + atlases[key] = atlas if (setAsDefault) { DEFAULT_ATLAS_KEY = key } diff --git a/physics/src/main/kotlin/cyberpunk/physics/PhysicsWorld.kt b/physics/src/main/kotlin/cyberpunk/physics/PhysicsWorld.kt index 4b4847c..fd61a6c 100644 --- a/physics/src/main/kotlin/cyberpunk/physics/PhysicsWorld.kt +++ b/physics/src/main/kotlin/cyberpunk/physics/PhysicsWorld.kt @@ -9,7 +9,7 @@ class PhysicsWorld /** * The [World] instance of this [PhysicsWorld]. */ - val world: World = World(config.gravity, true) + val world = World(config.gravity, true) /** * The [PhysicsDebugger] that will render this [PhysicsWorld]. diff --git a/physics/src/main/kotlin/cyberpunk/physics/builder/BodyDefBuilder.kt b/physics/src/main/kotlin/cyberpunk/physics/builder/BodyDefBuilder.kt index 0924d74..e08f606 100644 --- a/physics/src/main/kotlin/cyberpunk/physics/builder/BodyDefBuilder.kt +++ b/physics/src/main/kotlin/cyberpunk/physics/builder/BodyDefBuilder.kt @@ -20,8 +20,7 @@ class BodyDefBuilder { * @return this [BodyDefBuilder] instance. * @see [BodyDef.BodyType] */ - fun type(bodyType: BodyDef.BodyType) = - this.apply { bodyDef.type = bodyType } + fun type(bodyType: BodyDef.BodyType) = this.apply { bodyDef.type = bodyType } /** * Sets the world angle of the body, in radians. @@ -29,8 +28,7 @@ class BodyDefBuilder { * @param bodyAngle the desired [BodyDef.angle], in radians. * @return this [BodyDefBuilder] instance. */ - fun angle(bodyAngle: Float) = - this.apply { bodyDef.angle = bodyAngle } + fun angle(bodyAngle: Float) = this.apply { bodyDef.angle = bodyAngle } /** * Sets the linear velocity of the body's origin, in world coordinates. @@ -38,8 +36,7 @@ class BodyDefBuilder { * @param velocity the desired [BodyDef.linearVelocity], in the form of a [Vector2]. * @return this [BodyDefBuilder] instance. */ - fun linearVelocity(velocity: Vector2) = - this.apply { bodyDef.linearVelocity.set(velocity) } + fun linearVelocity(velocity: Vector2) = this.apply { bodyDef.linearVelocity.set(velocity) } /** * Sets the linear velocity of the body's origin, in world coordinates. @@ -48,8 +45,7 @@ class BodyDefBuilder { * @param y the desired [BodyDef.linearVelocity] Y. * @return this [BodyDefBuilder] instance. */ - fun linearVelocity(x: Float, y: Float) = - this.apply { bodyDef.linearVelocity.set(Vector2(x, y)) } + fun linearVelocity(x: Float, y: Float) = this.apply { bodyDef.linearVelocity.set(Vector2(x, y)) } /** * Sets the angular velocity of the body. @@ -57,8 +53,7 @@ class BodyDefBuilder { * @param velocity the desired [BodyDef.angularVelocity]. * @return this [BodyDefBuilder] instance. */ - fun angularVelocity(velocity: Float) = - this.apply { bodyDef.angularVelocity = velocity } + fun angularVelocity(velocity: Float) = this.apply { bodyDef.angularVelocity = velocity } /** * Sets the linear damping of the body. @@ -66,8 +61,7 @@ class BodyDefBuilder { * @param damping the desired [BodyDef.linearDamping]. * @return this [BodyDefBuilder] instance. */ - fun linearDamping(damping: Float) = - this.apply { bodyDef.linearDamping = damping } + fun linearDamping(damping: Float) = this.apply { bodyDef.linearDamping = damping } /** * Sets the angular damping of the body. @@ -75,40 +69,35 @@ class BodyDefBuilder { * @param damping the desired [BodyDef.angularDamping]- * @return this [BodyDefBuilder] instance. */ - fun angularDamping(damping: Float) = - this.apply { bodyDef.angularDamping = damping } + fun angularDamping(damping: Float) = this.apply { bodyDef.angularDamping = damping } /** * Never fall asleep - note that this WILL increase CPU usage. * The default value is false (i.e. the body can fall asleep). * @return this [BodyDefBuilder] instance. */ - fun noSleep() = - this.apply { bodyDef.allowSleep = false } + fun noSleep() = this.apply { bodyDef.allowSleep = false } /** * Sets this body to not be awake on spawn. * The default value is true (i.e. the body is awake on spawn). * @return this [BodyDefBuilder] instance. */ - fun notAwakeOnSpawn() = - this.apply { bodyDef.awake = false } + fun notAwakeOnSpawn() = this.apply { bodyDef.awake = false } /** * Sets this body to not be active on spawn. * The default value is true (i.e. the body is active on spawn). * @return this [BodyDefBuilder] instance. */ - fun notActiveOnSpawn() = - this.apply { bodyDef.active = false } + fun notActiveOnSpawn() = this.apply { bodyDef.active = false } /** * Prevents this body from rotating. * The default value is false (i.e. the body can rotate). * @return this [BodyDefBuilder] instance. */ - fun fixedRotation() = - this.apply { bodyDef.fixedRotation = true } + fun fixedRotation() = this.apply { bodyDef.fixedRotation = true } /** * Turns this flag on in case this is a fast moving body that should be prevented from @@ -116,8 +105,7 @@ class BodyDefBuilder { * The default value is false. * @return this [BodyDefBuilder] instance. */ - fun asBullet() = - this.apply { bodyDef.bullet = true } + fun asBullet() = this.apply { bodyDef.bullet = true } /** * Scales the gravity that will be applied to this body. @@ -125,8 +113,7 @@ class BodyDefBuilder { * @param scale the desired [BodyDef.gravityScale]. * @return this [BodyDefBuilder] instance. */ - fun gravityScale(scale: Float) = - this.apply { bodyDef.gravityScale = scale } + fun gravityScale(scale: Float) = this.apply { bodyDef.gravityScale = scale } /** * Sets the *world* position of the body. @@ -135,8 +122,7 @@ class BodyDefBuilder { * @param bodyPosition the desired [BodyDef.position]. * @return this [BodyDefBuilder] instance. */ - fun position(bodyPosition: Vector2) = - this.apply { bodyDef.position.set(bodyPosition.asBox2DUnits()) } + fun position(bodyPosition: Vector2) = this.apply { bodyDef.position.set(bodyPosition.asBox2DUnits()) } /** * Sets the *world* position of the body. diff --git a/physics/src/main/kotlin/cyberpunk/physics/builder/FixtureDefBuilder.kt b/physics/src/main/kotlin/cyberpunk/physics/builder/FixtureDefBuilder.kt index 24dba7f..660e50b 100644 --- a/physics/src/main/kotlin/cyberpunk/physics/builder/FixtureDefBuilder.kt +++ b/physics/src/main/kotlin/cyberpunk/physics/builder/FixtureDefBuilder.kt @@ -88,8 +88,7 @@ class FixtureDefBuilder { * @param friction desired friction. * @return this [FixtureDefBuilder] instance. */ - fun friction(friction: Float) = - this.apply { fixtureDef.friction = friction } + fun friction(friction: Float) = this.apply { fixtureDef.friction = friction } /** * Sets the fixture def's restitution (elasticity/bounciness). @@ -98,8 +97,7 @@ class FixtureDefBuilder { * @param restitution desired restitution. * @return this [FixtureDefBuilder] instance. */ - fun restitution(restitution: Float) = - this.apply { fixtureDef.restitution = restitution } + fun restitution(restitution: Float) = this.apply { fixtureDef.restitution = restitution } /** * Sets the fixture def's density. @@ -108,8 +106,7 @@ class FixtureDefBuilder { * @param density desired density. * @return this [FixtureDefBuilder] instance. */ - fun density(density: Float) = - this.apply { fixtureDef.density = density } + fun density(density: Float) = this.apply { fixtureDef.density = density } /** * Set this fixture def to be a sensor. @@ -118,8 +115,7 @@ class FixtureDefBuilder { * The default value for this property is false. * @return this [FixtureDefBuilder] instance. */ - fun asSensor() = - this.apply { fixtureDef.isSensor = true } + fun asSensor() = this.apply { fixtureDef.isSensor = true } /** * Finish building this [FixtureDef].