Testing out JmonkeyEngine to make a game in Scala with Akka Actors within a pure FP layer
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

107 lines
2.6 KiB

4 years ago
  1. #!/usr/bin/env amm
  2. // import coursierapi.MavenRepository
  3. // interp.repositories.update(
  4. // interp.repositories() ::: List(
  5. // MavenRepository.of("file://home/rohan/.m2/repository")
  6. // )
  7. // )
  8. // @
  9. import $repo.`https://jcenter.bintray.com`
  10. // import $repo.`https://bintray.com/jmonkeyengine/com.jme3`
  11. // import $file.dep
  12. import $ivy.`org.jmonkeyengine:jme3-core:3.2.4-stable`
  13. // import $ivy.`wow.doge:game:1.0-SNAPSHOT`
  14. import $ivy.`wow.doge::mygame:1.0-SNAPSHOT`
  15. // import wow.doge.game.types.GameScript
  16. import com.jme3.scene.control.Control
  17. // println("hello from script")
  18. // class Scr extends GameScript {
  19. // def start(): Unit = println("hello from start")
  20. // def stop(): Unit = println("hello from stop")
  21. // }
  22. // // class SomeClass extends Control {}
  23. // @main
  24. // def main(): GameScript = new Scr()
  25. import com.simsilica.es.base.DefaultEntityData
  26. import com.simsilica.es.EntityData
  27. import com.jme3.app.Application
  28. import wow.doge.mygame.game.Implicits._
  29. import wow.doge.mygame.components.TestComponent
  30. import com.jme3.scene.shape.Box
  31. import com.jme3.scene.Geometry
  32. import com.jme3.material.Material
  33. import com.jme3.math.ColorRGBA
  34. import com.jme3.asset.AssetManager
  35. import com.jme3.math.Vector3f
  36. import wow.doge.mygame.state._
  37. class TestAppState(
  38. // private var _entity: Option[EntityData] = Some(new DefaultEntityData())
  39. ) extends MyBaseState {
  40. protected lazy val b = new Box(1, 1, 1)
  41. protected lazy val geom = new Geometry("Box", b)
  42. protected lazy val mat = Material(
  43. assetManager = assetManager,
  44. path = "Common/MatDefs/Misc/Unshaded.j3md"
  45. )
  46. // def entity = _entity
  47. // override def initialize(app: Application): Unit = {
  48. // super.initialize(app)
  49. // }
  50. override def init() = {
  51. entityData
  52. .createEntity()
  53. .withComponents(TestComponent())
  54. // entityData.setComponents(x, TestComponent())
  55. val es = entityData.getEntities(classOf[TestComponent])
  56. println(es)
  57. geom.setMaterial(mat)
  58. rootNode.attachChild(geom)
  59. // geom.foreach(e => {
  60. // })
  61. }
  62. override def update(tpf: Float) = {
  63. geom.rotate(0, 0.5f * tpf, 0)
  64. geom.move(new Vector3f(0, 1 * tpf, 0))
  65. }
  66. override def cleanup(app: Application): Unit = {
  67. // _entity.map(_.close())
  68. // _entity = None
  69. }
  70. override def onEnable(): Unit = {}
  71. override def onDisable(): Unit = {}
  72. }
  73. object Material {
  74. def apply(
  75. color: String = "Color",
  76. colorType: com.jme3.math.ColorRGBA = ColorRGBA.Blue,
  77. assetManager: AssetManager,
  78. path: String
  79. ): Material = {
  80. val mat =
  81. new Material(assetManager, path)
  82. mat.setColor(color, colorType)
  83. mat
  84. }
  85. }
  86. @main
  87. def main(): MyBaseState = new TestAppState()