Skip to content

Commit

Permalink
Update MapLoader.kt
Browse files Browse the repository at this point in the history
  • Loading branch information
nickquach02 authored Jan 9, 2020
1 parent ed8270a commit 4adbeaa
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion core/src/me/srikavin/fbla/game/map/MapLoader.kt
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,23 @@ class MapLoader {
createCoin(world, mapObject.rectangle.getPosition(pos).scl(MAP_SCALE_FACTOR))
info { "Making coin at $pos" }
}
TriggerType.values().any { it.name == type.toUpperCase() } -> {
val rect = mapObject.rectangle

world.createEntity().edit()
.add(Transform().apply { position = rect.getCenter(recycledVector2).scl(MAP_SCALE_FACTOR).cpy() })
.add(PhysicsBody().apply {
shape = PolygonShape().apply {
setAsBox(rect.width * MAP_SCALE_FACTOR * .5f, rect.height * MAP_SCALE_FACTOR * .5f,
recycledVector2.setZero(), 0f)
}
this.type = BodyDef.BodyType.StaticBody
})
.add(MapTrigger().apply {
this.type = TriggerType.valueOf(type.toUpperCase())
properties = mapObject.properties
})
}
type == "damage" -> {
// val rect = mapObject.rectangle

Expand Down Expand Up @@ -297,4 +314,4 @@ class MapLoader {

return mapEntity
}
}
}

0 comments on commit 4adbeaa

Please sign in to comment.