Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
case class JPlayer(id: Int, x: Int, y: Int)
val players: ImmutableBag[Entity] = world.getManager(classOf[GroupManager]).getEntities("PLAYERS");
val numEntities = players.size
var entityJString : String = "["
var aPlayers: ArrayBuffer[JPlayer] = ArrayBuffer()
for( i <- 0 until numEntities) {
val tempEntity : Entity = players.get(i)
val tempPos : Position = tempEntity.getComponent(classOf[Position])
val tempId = tempEntity.getId()
aPlayers += JPlayer(tempId, tempPos.x, tempPos.y)
//entityJString += "{id:" + tempId + ", x: " + tempPos.x + ", y: " + tempPos.y + "},\n"
}
entityJString += "]"
val json = ("players" -> aPlayers.toList.map{ p =>
(("id" -> p.id) ~
("x" -> p.x) ~
("y" -> p.y))})
println(compact(render(json)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.