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.

108 lines
2.7 KiB

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