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.

89 lines
2.8 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  1. package wow.doge.mygame
  2. import monix.bio.Task
  3. import cats.effect.Resource
  4. import io.odin.syntax._
  5. import cats.effect.ExitCode
  6. import cats.implicits._
  7. import com.softwaremill.macwire._
  8. import scala.concurrent.duration._
  9. import monix.bio.BIOApp
  10. import monix.bio.UIO
  11. import monix.bio.IO
  12. import io.odin._
  13. import wow.doge.mygame.implicits._
  14. import wow.doge.mygame.game.GameAppResource
  15. import io.odin.json.Formatter
  16. object Main extends BIOApp with MainModule {
  17. import java.util.logging.{Logger => JLogger, Level}
  18. JLogger.getLogger("").setLevel(Level.SEVERE)
  19. def appResource =
  20. for {
  21. logger <-
  22. consoleLogger().withAsync(timeWindow = 1.milliseconds) |+|
  23. fileLogger(
  24. "application-log-1.log",
  25. Formatter.json
  26. ).withAsync(timeWindow = 1.milliseconds)
  27. jmeScheduler <- jMESchedulerResource
  28. // consoleTextArea <- Resource.liftF(Task(new TextArea()))
  29. // consoleStream <- wireWith(JFXConsoleStream.textAreaStream _)
  30. (gameApp, gameAppFib) <- {
  31. // new BulletAppState()
  32. // bas.setThreadingType(Thr)
  33. // gameAppResource(new StatsAppState())
  34. wire[GameAppResource].make
  35. }
  36. // _ <- Resource.liftF(IO(JMERunner.runner = gameApp))
  37. // _ <- Resource.liftF(IO {
  38. // new ActorSystemModule {}
  39. // })
  40. actorSystem <- wireWith(actorSystemResource _)
  41. _ <- Resource.liftF(
  42. gameApp.enqueueT(actorSystem ! RootActor.Start(actorSystem.scheduler))
  43. )
  44. // _ <- Resource.liftF {
  45. // Task {
  46. // implicit val sched = actorSystem.scheduler
  47. // implicit val timeout = Timeout(2.seconds)
  48. // // val module = new EventsModule {}
  49. // }
  50. // }
  51. // actorSystem <- wireWith(actorSystemResource2 _)
  52. // (tickEventBus, playerMovementEventBus) <- wireWith(eventBusesResource _)
  53. // rootActor <- wireWith(rootActorResource _)
  54. // inputSystemHandler <- {
  55. // inputHandlerSystemResource(
  56. // GameInputHandler.Props(gameApp.inputManager, playerMovementEventBus)
  57. // )
  58. // }
  59. // gameSystemsInitializer <-
  60. // gameSystemsResource(actorSystem, inputSystemHandler)
  61. // _ <- Resource.liftF(
  62. // gameApp.enqueueT(rootActor ! RootActor.Start(actorSystem.scheduler))
  63. // )
  64. // _ <- Resource.liftF {
  65. // IO(gameApp.start())
  66. // .executeOn(jmeScheduler)
  67. // }
  68. // (_ => IO(gameApp.stop(() => actorSystem ! RootActor.Stop)))
  69. } yield (gameAppFib)
  70. def run(args: List[String]): UIO[ExitCode] = {
  71. // Console.withOut(
  72. // new JFXConsoleStream(
  73. // new scalafx.scene.control.TextArea(),
  74. // new ByteArrayOutputStream(35)
  75. // )
  76. // )(())
  77. appResource
  78. .use(_.join)
  79. .onErrorHandle(_.printStackTrace())
  80. .as(ExitCode.Success)
  81. }
  82. }