Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added summoning sickness to the gates and shepherds.

  • Loading branch information...
commit 50349a3176bd580884f1e62d50a4811c9a2cfc64 1 parent e06660a
@fversnel authored
View
2  src/main/scala/org/frankversnel/poortjes/game/gameobjects/candy.scala
@@ -8,7 +8,7 @@ import org.frankversnel.poortjes.DimensionValue
class Candy(protected val resourceLoader: ResourceLoader) extends DrawableShape with Collidable
with TimeBasedLife {
- protected val maxTimeAliveMillis = 10000
+ protected val maxTimeAliveMillis = 10000L
protected val shape = resourceLoader.addResource("candy.svg")
View
2  src/main/scala/org/frankversnel/poortjes/game/gameobjects/explosion.scala
@@ -12,7 +12,7 @@ class Explosion extends Drawable with Color with Collidable
val color = ColorValue().r(255).a(125)
var dimension = DimensionValue().width(0).height(0)
- protected val maxTimeAliveMillis = 2000
+ protected val maxTimeAliveMillis = 2000L
private val targetRadius = 200f
override def process(update: Update) {
View
6 src/main/scala/org/frankversnel/poortjes/game/gameobjects/gate.scala
@@ -24,13 +24,15 @@ class GateEnd(protected val resourceLoader: ResourceLoader)
protected val shape = resourceLoader.addResource("gate-end.svg")
}
class GateConnector(protected val resourceLoader: ResourceLoader)
- extends DrawableShape with Collidable {
+ extends DrawableShape with Collidable with SummoningSickness {
+ protected val maxSicknessDurationMillis = 3000L
+
var dimension = DimensionValue().width(2).height(50)
protected val shape = resourceLoader.addResource("gate-connector.svg")
def onCollision(collider: GameObject) {
- if(collider.is[Player]) {
+ if(collider.is[Player] && !hasSummoningSickness) {
val explosion = new Explosion
explosion.translate(matrixStack.translation._1, matrixStack.translation._2)
EntityManager().spawn(explosion)
View
6 src/main/scala/org/frankversnel/poortjes/game/gameobjects/player_killer.scala
@@ -3,9 +3,11 @@ package org.frankversnel.poortjes.game.gameobjects
import org.frankversnel.poortjes.GameObject
import org.frankversnel.poortjes.collision.Collidable
-trait PlayerKiller extends Collidable {
+trait PlayerKiller extends Collidable with SummoningSickness {
+ protected val maxSicknessDurationMillis = 3000L
+
def onCollision(collider: GameObject) {
- if(collider.is[Player]) {
+ if(collider.is[Player] && !hasSummoningSickness) {
collider.destroy
}
}
View
15 src/main/scala/org/frankversnel/poortjes/game/gameobjects/summoning_sickness.scala
@@ -0,0 +1,15 @@
+package org.frankversnel.poortjes.game.gameobjects
+
+import org.frankversnel.poortjes._
+
+trait SummoningSickness extends Component {
+ protected val maxSicknessDurationMillis: Long
+
+ private var sicknessDurationMillis = 0L
+
+ override def process(update: Update) {
+ sicknessDurationMillis += update.deltaTime.millis
+ }
+
+ def hasSummoningSickness = sicknessDurationMillis < maxSicknessDurationMillis
+}
View
4 src/main/scala/org/frankversnel/poortjes/game/gameobjects/time_based_life.scala
@@ -8,8 +8,8 @@ import org.frankversnel.poortjes.Update
* the specified maxTimeAliveMillis length.
*/
trait TimeBasedLife extends Component {
- protected val maxTimeAliveMillis: Int
- private var timeAliveMillis = 0
+ protected val maxTimeAliveMillis: Long
+ private var timeAliveMillis = 0L
override def process(update: Update) {
super.process(update)
View
2  src/main/scala/org/frankversnel/poortjes/util/delta_time.scala
@@ -1,6 +1,6 @@
package org.frankversnel.poortjes.util
-case class DeltaTime(millis: Int) {
+case class DeltaTime(millis: Long) {
val seconds: Float = millis.toFloat / 1000f
}
Please sign in to comment.
Something went wrong with that request. Please try again.