removed unnecessary class Light10B, minor fixes for LightmapRenderer

Former-commit-id: 4cddfb080cc689738d9bf308f7d08852f4c78a8b
Former-commit-id: 2354b2483f30e70862a327c1b9688a19bd1b2f66
This commit is contained in:
Song Minjae
2016-09-07 22:58:42 +09:00
parent d817c586e9
commit 9b9b65efba
31 changed files with 3718 additions and 134 deletions

View File

@@ -79,5 +79,5 @@ object AVKey {
const val _PLAYER_QUICKBARSEL = "__quickbarselection"
const val __PLAYER_QUICKBARSEL = "__quickbarselection"
}

View File

@@ -1,6 +1,7 @@
package net.torvald.terrarum.gameactors
import com.jme3.math.FastMath
import net.torvald.point.Point2d
import net.torvald.terrarum.*
import net.torvald.terrarum.gamemap.GameWorld
import net.torvald.terrarum.mapdrawer.MapDrawer
@@ -36,6 +37,7 @@ open class ActorWithBody : Actor(), Visible {
/**
* * Position: top-left point
* * Unit: pixel
* !! external class should not hitbox.set(); use setHitboxDimension() and setPosition()
*/
override val hitbox = Hitbox(0.0, 0.0, 0.0, 0.0)
@Transient val nextHitbox = Hitbox(0.0, 0.0, 0.0, 0.0)
@@ -261,6 +263,13 @@ open class ActorWithBody : Actor(), Visible {
baseHitboxH * scale)
}
val centrePosition: Vector2
get() = Vector2(hitbox.centeredX, hitbox.centeredY)
val centrePosPoint: Point2d
get() = Point2d(hitbox.centeredX, hitbox.centeredY)
val feetPosition: Vector2
get() = Vector2(hitbox.centeredX, hitbox.posY + hitbox.height)
override fun run() = update(Terrarum.appgc, Terrarum.ingame.UPDATE_DELTA)
/**
@@ -325,8 +334,10 @@ open class ActorWithBody : Actor(), Visible {
* If and only if:
* This body is NON-STATIC and the other body is STATIC
*/
displaceByCCD()
applyNormalForce()
if (!isPlayerNoClip) {
displaceByCCD()
applyNormalForce()
}
setHorizontalFriction()
if (isPlayerNoClip) // or hanging on the rope, etc.
@@ -342,6 +353,10 @@ open class ActorWithBody : Actor(), Visible {
// cheap solution for sticking into the wall while Left or Right is held
walledLeft = isTouchingSide(nextHitbox, COLLIDING_LEFT)
walledRight = isTouchingSide(nextHitbox, COLLIDING_RIGHT)
if (isPlayerNoClip) {
walledLeft = false
walledRight = false
}
}
}
@@ -428,7 +443,8 @@ open class ActorWithBody : Actor(), Visible {
else if (moveDelta.y < 0.0) { // or was moving upward?
grounded = false
if (isTouchingSide(nextHitbox, COLLIDING_TOP)) { // actor hit something on its top
hitAndForciblyReflectY()
//hitAndForciblyReflectY()
hitAndReflectY()
}
else { // the actor is not grounded at all
}
@@ -491,6 +507,7 @@ open class ActorWithBody : Actor(), Visible {
}
}
@Deprecated("it's no use!")
private fun hitAndForciblyReflectY() {
if (veloY.abs() * CEILING_HIT_ELASTICITY > A_PIXEL)
veloY = -veloY * CEILING_HIT_ELASTICITY

View File

@@ -12,7 +12,7 @@ object PBCynthia {
val p: Player = Player()
CreatureRawInjector.inject(p.actorValue, "CreatureHuman.json")
p.actorValue[AVKey._PLAYER_QUICKBARSEL] = 0
p.actorValue[AVKey.__PLAYER_QUICKBARSEL] = 0
p.actorValue["__selectedtile"] = 16

View File

@@ -58,6 +58,7 @@ object PBSigrid {
p.actorValue[AVKey.BASEDEFENCE] = 141
p.actorValue[AVKey.__PLAYER_QUICKBARSEL] = 0
p.actorValue["__selectedtile"] = 16 // test code; replace with <tile_item>.primaryUse(gc, delta)
p.actorValue["__aimhelper"] = true

View File

@@ -18,7 +18,7 @@ object PlayerBuilder {
// attach sprite
// do etc.
p.actorValue[AVKey._PLAYER_QUICKBARSEL] = 0
p.actorValue[AVKey.__PLAYER_QUICKBARSEL] = 0
return p
}

View File

@@ -0,0 +1,9 @@
package net.torvald.terrarum.gameactors
/**
* Projectile marker. Used to kill them when they're far away from the player, instead of making them sleep.
*
* Created by minjaesong on 16-09-05.
*/
interface Projectile {
}

View File

@@ -8,8 +8,8 @@ import org.dyn4j.geometry.Vector2
class ProjectileHoming(
type: Int,
fromPoint: Vector2, // projected coord
toPoint: Vector2, // arriving coord
override var luminosity: Int = 0) : ProjectileSimple(type, fromPoint, toPoint, luminosity) {
toPoint: Vector2 // arriving coord
) : ProjectileSimple(type, fromPoint, toPoint) {

View File

@@ -1,7 +1,9 @@
package net.torvald.terrarum.gameactors
import net.torvald.colourutil.CIELabUtil.brighterLab
import net.torvald.colourutil.CIELabUtil.darkerLab
import net.torvald.point.Point2d
import net.torvald.spriteanimation.SpriteAnimation
import net.torvald.terrarum.Terrarum
import org.dyn4j.geometry.Vector2
import org.newdawn.slick.Color
import org.newdawn.slick.GameContainer
@@ -14,16 +16,21 @@ import java.util.*
* Created by minjaesong on 16-08-29.
*/
open class ProjectileSimple(
type: Int,
private val type: Int,
fromPoint: Vector2, // projected coord
toPoint: Vector2, // arriving coord
override var luminosity: Int = 0) : ActorWithBody(), Luminous {
toPoint: Vector2 // arriving coord
) : ActorWithBody(), Luminous, Projectile {
val damage: Int
val displayColour: Color
/** scalar part of velocity */
val speed: Int
override var luminosity: Int
get() = bulletDatabase[type][OFFSET_LUMINOSITY] as Int
set(value) {
}
/**
* Arguments:
*
@@ -32,8 +39,14 @@ open class ProjectileSimple(
*/
override val lightBoxList = ArrayList<Hitbox>()
val lifetimeMax = 2500
var lifetimeCounter = 0
val posPre: Point2d
init {
hitbox.set(fromPoint.x, fromPoint.y, 2.0, 2.0) // 2.0: size of the hitbox in pixels
setPosition(fromPoint.x, fromPoint.y)
posPre = Point2d(fromPoint.x, fromPoint.y)
// lightbox sized 8x8 centered to the bullet
lightBoxList.add(Hitbox(-4.0, -4.0, 8.0, 8.0))
this.velocity.set(velocity)
@@ -43,16 +56,10 @@ open class ProjectileSimple(
isNoSubjectToGrav = bulletDatabase[type][OFFSET_NOGRAVITY] as Boolean
speed = bulletDatabase[type][OFFSET_SPEED] as Int
if (displayColour == Color(254, 0, 0, 0)) {
sprite = bulletDatabase[type][OFFSET_SPRITE] as SpriteAnimation
}
setHitboxDimension(2, 2, 0, 0) // should be following sprite's properties if there IS one
val initVelo = Vector2(speed.toDouble(), 0.0)
initVelo.setDirection((fromPoint to toPoint).direction)
velocity.set(initVelo)
velocity.set((fromPoint to toPoint).setMagnitude(speed.toDouble()))
@@ -61,34 +68,42 @@ open class ProjectileSimple(
override fun update(gc: GameContainer, delta: Int) {
// hit something and despawn
if (ccdCollided || grounded) flagDespawn()
lifetimeCounter += delta
if ((ccdCollided || grounded) || lifetimeCounter >= lifetimeMax) flagDespawn()
posPre.set(centrePosPoint)
super.update(gc, delta)
}
override fun drawBody(gc: GameContainer, g: Graphics) {
val colourTail = displayColour.darker(0f) // clone a colour
colourTail.a = 0.16f
// draw trail of solid colour (Terraria style maybe?)
g.lineWidth = 3f
g.lineWidth = 2f * Terrarum.ingame.screenZoom
g.drawGradientLine(
nextHitbox.centeredX.toFloat(),
nextHitbox.centeredY.toFloat(),
hitbox.centeredX.toFloat() * Terrarum.ingame.screenZoom,
hitbox.centeredY.toFloat() * Terrarum.ingame.screenZoom,
displayColour,
hitbox.centeredX.toFloat(),
hitbox.centeredY.toFloat(),
displayColour.brighterLab(0.8f)
posPre.x.toFloat() * Terrarum.ingame.screenZoom,
posPre.y.toFloat() * Terrarum.ingame.screenZoom,
colourTail
)
}
override fun drawGlow(gc: GameContainer, g: Graphics) = drawBody(gc, g)
companion object {
val OFFSET_DAMAGE = 0
val OFFSET_COL = 1 // set it to Color(254, 0, 0, 0) to use sprite
val OFFSET_COL = 1 // Color or SpriteAnimation
val OFFSET_NOGRAVITY = 2
val OFFSET_SPEED = 3
val OFFSET_SPRITE = 4
val OFFSET_LUMINOSITY = 4
val bulletDatabase = arrayOf(
// damage, display colour, no gravity, speed
arrayOf(7, Color(0xFF5429), true, 50),
arrayOf(8, Color(0xFF5429), true, 50)
arrayOf(7, Color(0xFF5429), true, 40, 32),
arrayOf(8, Color(0xFF5429), true, 20, 0)
// ...
)
}