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.

63 lines
1.9 KiB

4 years ago
3 years ago
4 years ago
3 years ago
3 years ago
4 years ago
4 years ago
3 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 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 _root_.monix.execution.Scheduler
  7. import akka.util.Timeout
  8. import cats.effect.ExitCode
  9. import cats.effect.Resource
  10. import cats.implicits._
  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.utils.GenericConsoleStream
  16. object Main extends BIOApp with MainModule {
  17. import java.util.logging.{Logger => JLogger, Level}
  18. JLogger.getLogger("").setLevel(Level.SEVERE)
  19. implicit val timeout = Timeout(1.second)
  20. override def scheduler: Scheduler = schedulers.async
  21. def appResource(consoleStream: GenericConsoleStream[TextArea]) =
  22. for {
  23. logger <-
  24. consoleLogger().withAsync(
  25. timeWindow = 1.milliseconds,
  26. maxBufferSize = Some(100)
  27. ) |+|
  28. fileLogger(
  29. "application-log-1.log",
  30. Formatter.json
  31. ).withAsync(timeWindow = 1.milliseconds, maxBufferSize = Some(2000))
  32. jmeScheduler <- jMESchedulerResource
  33. // backend <- Resource.make(toIO(HttpClientMonixBackend()))(backend =>
  34. // toIO(backend.close())
  35. // )
  36. actorSystem <- actorSystemResource(logger, schedulers.async)
  37. _ <- Resource.liftF(
  38. new MainApp(
  39. logger,
  40. jmeScheduler,
  41. schedulers,
  42. consoleStream
  43. )(actorSystem, timeout, actorSystem.scheduler).program
  44. )
  45. } yield ()
  46. def run(args: List[String]): UIO[ExitCode] = {
  47. val consoleStream = GenericConsoleStream.textAreaStream()
  48. Console.withOut(consoleStream)(
  49. appResource(consoleStream)
  50. .use(_ => Task.unit)
  51. .flatMap(_ => Task(consoleStream.close()))
  52. .onErrorHandleWith(ex => UIO(ex.printStackTrace()))
  53. .as(ExitCode.Success)
  54. )
  55. }
  56. }