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.

70 lines
1.9 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
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  1. package wow.doge.mygame
  2. import scala.concurrent.duration._
  3. import _root_.monix.bio.BIOApp
  4. import _root_.monix.bio.Task
  5. import _root_.monix.bio.UIO
  6. import akka.util.Timeout
  7. import cats.effect.ExitCode
  8. import cats.effect.Resource
  9. import cats.implicits._
  10. import com.softwaremill.macwire._
  11. import io.odin._
  12. import io.odin.json.Formatter
  13. import io.odin.syntax._
  14. import scalafx.scene.control.TextArea
  15. import wow.doge.mygame.game.GameAppResource
  16. import wow.doge.mygame.utils.GenericConsoleStream
  17. object Main extends BIOApp with MainModule {
  18. import java.util.logging.{Logger => JLogger, Level}
  19. JLogger.getLogger("").setLevel(Level.SEVERE)
  20. implicit val timeout = Timeout(1.second)
  21. def appResource(consoleStream: GenericConsoleStream[TextArea]) =
  22. for {
  23. logger <-
  24. consoleLogger().withAsync(
  25. timeWindow = 1.milliseconds,
  26. maxBufferSize = Some(2000)
  27. ) |+|
  28. fileLogger(
  29. "application-log-1.log",
  30. Formatter.json
  31. ).withAsync(timeWindow = 1.milliseconds, maxBufferSize = Some(2000))
  32. jmeScheduler <- jMESchedulerResource
  33. actorSystem <- actorSystemResource(logger)
  34. gameApp <- {
  35. // new BulletAppState()
  36. // bas.setThreadingType(Thr)
  37. // gameAppResource(new StatsAppState())
  38. wire[GameAppResource].get
  39. }
  40. _ <- Resource.liftF(
  41. new MainApp(
  42. logger,
  43. gameApp,
  44. actorSystem,
  45. jmeScheduler,
  46. schedulers,
  47. consoleStream
  48. )(
  49. timeout,
  50. actorSystem.scheduler
  51. ).program
  52. )
  53. } yield ()
  54. def run(args: List[String]): UIO[ExitCode] = {
  55. lazy val consoleStream = GenericConsoleStream.textAreaStream()
  56. Console.withOut(consoleStream)(
  57. appResource(consoleStream)
  58. .use(_ => Task.unit >> Task(consoleStream.close()))
  59. .onErrorHandle(_.printStackTrace())
  60. .as(ExitCode.Success)
  61. )
  62. }
  63. }