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.

134 lines
3.1 KiB

4 years ago
  1. package ammonite
  2. package $file.src.main.resources
  3. import _root_.ammonite.interp.api.InterpBridge.{
  4. value => interp
  5. }
  6. import _root_.ammonite.interp.api.InterpBridge.value.{
  7. exit
  8. }
  9. import _root_.ammonite.interp.api.IvyConstructor.{
  10. ArtifactIdExt,
  11. GroupIdExt
  12. }
  13. import _root_.ammonite.runtime.tools.{
  14. browse,
  15. grep,
  16. time,
  17. tail
  18. }
  19. import _root_.ammonite.repl.tools.{
  20. desugar,
  21. source
  22. }
  23. import _root_.ammonite.main.Router.{
  24. doc,
  25. main
  26. }
  27. import _root_.ammonite.repl.tools.Util.{
  28. pathScoptRead
  29. }
  30. object hello2{
  31. /*<script>*/import $repo.$
  32. // import $repo.`https://bintray.com/jmonkeyengine/com.jme3`
  33. // import $file.dep
  34. import $ivy.$
  35. // import $ivy.`wow.doge:game:1.0-SNAPSHOT`
  36. import $ivy.$
  37. // import wow.doge.game.types.GameScript
  38. import com.jme3.scene.control.Control
  39. // println("hello from script")
  40. // class Scr extends GameScript {
  41. // def start(): Unit = println("hello from start")
  42. // def stop(): Unit = println("hello from stop")
  43. // }
  44. // // class SomeClass extends Control {}
  45. // @main
  46. // def main(): GameScript = new Scr()
  47. import com.simsilica.es.base.DefaultEntityData
  48. import com.simsilica.es.EntityData
  49. import com.jme3.app.Application
  50. import wow.doge.mygame.game.Implicits._
  51. import wow.doge.mygame.components.TestComponent
  52. import com.jme3.scene.shape.Box
  53. import com.jme3.scene.Geometry
  54. import com.jme3.material.Material
  55. import com.jme3.math.ColorRGBA
  56. import com.jme3.asset.AssetManager
  57. import com.jme3.math.Vector3f
  58. import wow.doge.mygame.state._
  59. class TestAppState(
  60. // private var _entity: Option[EntityData] = Some(new DefaultEntityData())
  61. ) extends MyBaseState {
  62. protected lazy val b = new Box(1, 1, 1)
  63. protected lazy val geom = new Geometry("Box", b)
  64. protected lazy val mat = Material(
  65. assetManager = assetManager,
  66. path = "Common/MatDefs/Misc/Unshaded.j3md"
  67. )
  68. // def entity = _entity
  69. // override def initialize(app: Application): Unit = {
  70. // super.initialize(app)
  71. // }
  72. override def init() = {
  73. entityData
  74. .createEntity()
  75. .withComponents(TestComponent())
  76. // entityData.setComponents(x, TestComponent())
  77. val es = entityData.getEntities(classOf[TestComponent])
  78. println(es)
  79. geom.setMaterial(mat)
  80. rootNode.attachChild(geom)
  81. // geom.foreach(e => {
  82. // })
  83. }
  84. override def update(tpf: Float) = {
  85. geom.rotate(0, 0.5f * tpf, 0)
  86. geom.move(new Vector3f(0, 1 * tpf, 0))
  87. }
  88. override def cleanup(app: Application): Unit = {
  89. // _entity.map(_.close())
  90. // _entity = None
  91. }
  92. override def onEnable(): Unit = {}
  93. override def onDisable(): Unit = {}
  94. }
  95. object Material {
  96. def apply(
  97. color: String = "Color",
  98. colorType: com.jme3.math.ColorRGBA = ColorRGBA.Blue,
  99. assetManager: AssetManager,
  100. path: String
  101. ): Material = {
  102. val mat =
  103. new Material(assetManager, path)
  104. mat.setColor(color, colorType)
  105. mat
  106. }
  107. }
  108. @main
  109. def main(): MyBaseState = new TestAppState()
  110. /*</script>*/ /*<generated>*/
  111. def $main() = { scala.Iterator[String]() }
  112. override def toString = "hello2"
  113. /*</generated>*/
  114. }