quicker camera on buildingmaker

This commit is contained in:
minjaesong
2019-02-04 01:37:31 +09:00
parent a831a4d798
commit 3f108a6ea9
4 changed files with 27 additions and 7 deletions

View File

@@ -422,17 +422,29 @@ object Terrarum : Screen {
} }
/** Position of the cursor in the world */ /** Position of the cursor in the world */
inline val mouseX: Double val mouseX: Double
get() = WorldCamera.x + Gdx.input.x / (ingame?.screenZoom ?: 1f).toDouble() get() = WorldCamera.x + Gdx.input.x / (ingame?.screenZoom ?: 1f).toDouble()
/** Position of the cursor in the world */ /** Position of the cursor in the world */
inline val mouseY: Double val mouseY: Double
get() = WorldCamera.y + Gdx.input.y / (ingame?.screenZoom ?: 1f).toDouble() get() = WorldCamera.y + Gdx.input.y / (ingame?.screenZoom ?: 1f).toDouble()
/** Position of the cursor in the world */ /** Position of the cursor in the world */
@JvmStatic inline val mouseTileX: Int val oldMouseX: Double
get() = WorldCamera.x + (Gdx.input.x - Gdx.input.deltaX) / (ingame?.screenZoom ?: 1f).toDouble()
/** Position of the cursor in the world */
val oldMouseY: Double
get() = WorldCamera.y + (Gdx.input.y - Gdx.input.deltaY) / (ingame?.screenZoom ?: 1f).toDouble()
/** Position of the cursor in the world */
@JvmStatic val mouseTileX: Int
get() = (mouseX / FeaturesDrawer.TILE_SIZE).floorInt() get() = (mouseX / FeaturesDrawer.TILE_SIZE).floorInt()
/** Position of the cursor in the world */ /** Position of the cursor in the world */
@JvmStatic inline val mouseTileY: Int @JvmStatic val mouseTileY: Int
get() = (mouseY / FeaturesDrawer.TILE_SIZE).floorInt() get() = (mouseY / FeaturesDrawer.TILE_SIZE).floorInt()
/** Position of the cursor in the world */
@JvmStatic val oldMouseTileX: Int
get() = (oldMouseX / FeaturesDrawer.TILE_SIZE).floorInt()
/** Position of the cursor in the world */
@JvmStatic val oldMouseTileY: Int
get() = (oldMouseY / FeaturesDrawer.TILE_SIZE).floorInt()
inline val mouseScreenX: Int inline val mouseScreenX: Int
get() = Gdx.input.x get() = Gdx.input.x
inline val mouseScreenY: Int inline val mouseScreenY: Int

View File

@@ -29,6 +29,9 @@ object AVKey {
const val JUMPPOWER = "jumppower" const val JUMPPOWER = "jumppower"
const val JUMPPOWERBUFF = "$JUMPPOWER$BUFF" const val JUMPPOWERBUFF = "$JUMPPOWER$BUFF"
/** NOT meant for living creatures. Also, only effective when noclip=true. E.g. camera actor */
const val FRICTIONMULT = "frictionmult"
/** Int /** Int
* "Default" value of 1 000 * "Default" value of 1 000
*/ */

View File

@@ -1070,7 +1070,7 @@ open class ActorWBMovable(renderOrder: RenderOrder, val immobileBody: Boolean =
* for about get moving, see updateMovementControl */ * for about get moving, see updateMovementControl */
private fun setHorizontalFriction(delta: Float) { private fun setHorizontalFriction(delta: Float) {
val friction = if (isNoClip) val friction = if (isNoClip)
BASE_FRICTION * BlockCodex[Block.STONE].friction.frictionToMult() BASE_FRICTION * (actorValue.getAsDouble(AVKey.FRICTIONMULT) ?: 1.0) * BlockCodex[Block.STONE].friction.frictionToMult()
else { else {
// TODO status quo if !submerged else linearBlend(feetFriction, bodyFriction, submergedRatio) // TODO status quo if !submerged else linearBlend(feetFriction, bodyFriction, submergedRatio)
BASE_FRICTION * if (grounded) feetFriction else bodyFriction BASE_FRICTION * if (grounded) feetFriction else bodyFriction
@@ -1099,9 +1099,11 @@ open class ActorWBMovable(renderOrder: RenderOrder, val immobileBody: Boolean =
private fun setVerticalFriction(delta: Float) { private fun setVerticalFriction(delta: Float) {
val friction = if (isNoClip) val friction = if (isNoClip)
BASE_FRICTION * BlockCodex[Block.STONE].friction.frictionToMult() BASE_FRICTION * (actorValue.getAsDouble(AVKey.FRICTIONMULT) ?: 1.0) * BlockCodex[Block.STONE].friction.frictionToMult()
else else
BASE_FRICTION * bodyFriction BASE_FRICTION * bodyFriction
// TODO wall friction (wall skid) similar to setHorizintalFriction ?
if (externalV.y < 0) { if (externalV.y < 0) {
externalV.y += friction externalV.y += friction

View File

@@ -223,6 +223,7 @@ class BuildingMaker(batch: SpriteBatch) : IngameInstance(batch) {
makePenWork(Terrarum.mouseTileX, Terrarum.mouseTileY) makePenWork(Terrarum.mouseTileX, Terrarum.mouseTileY)
// TODO drag support using bresenham's algo // TODO drag support using bresenham's algo
// for some reason it just doesn't work...
} }
} }
@@ -312,10 +313,12 @@ class MovableWorldCamera : ActorHumanoid(0, usePhysics = false) {
actorValue[AVKey.SPEED] = 8.0 actorValue[AVKey.SPEED] = 8.0
actorValue[AVKey.SPEEDBUFF] = 1.0 actorValue[AVKey.SPEEDBUFF] = 1.0
actorValue[AVKey.ACCEL] = ActorHumanoid.WALK_ACCEL_BASE actorValue[AVKey.ACCEL] = ActorHumanoid.WALK_ACCEL_BASE
actorValue[AVKey.ACCELBUFF] = 1.0 actorValue[AVKey.ACCELBUFF] = 4.0
actorValue[AVKey.JUMPPOWER] = 0.0 actorValue[AVKey.JUMPPOWER] = 0.0
actorValue[AVKey.FRICTIONMULT] = 4.0
} }
override fun drawBody(batch: SpriteBatch) { override fun drawBody(batch: SpriteBatch) {
} }