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.

69 lines
1.9 KiB

4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
3 years ago
3 years ago
4 years ago
3 years ago
4 years ago
4 years ago
4 years ago
3 years ago
4 years ago
4 years ago
4 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
4 years ago
4 years ago
4 years ago
  1. package wow.doge.mygame
  2. import scala.concurrent.duration._
  3. import akka.util.Timeout
  4. import cats.effect.ExitCode
  5. import cats.implicits._
  6. import com.softwaremill.macwire._
  7. import io.odin._
  8. import io.odin.json.Formatter
  9. import io.odin.syntax._
  10. import wow.doge.mygame.game.GameAppResource
  11. import _root_.monix.bio.BIOApp
  12. import _root_.monix.bio.Task
  13. import _root_.monix.bio.UIO
  14. import cats.effect.Resource
  15. import scalafx.scene.control.TextArea
  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(timeWindow = 1.milliseconds) |+|
  25. fileLogger(
  26. "application-log-1.log",
  27. Formatter.json
  28. ).withAsync(timeWindow = 1.milliseconds)
  29. jmeScheduler <- jMESchedulerResource
  30. actorSystem <- actorSystemResource2(logger)
  31. // consoleTextArea <- Resource.liftF(Task(new TextArea()))
  32. // consoleStream <- wireWith(JFXConsoleStream.textAreaStream _)
  33. gameApp <- {
  34. // new BulletAppState()
  35. // bas.setThreadingType(Thr)
  36. // gameAppResource(new StatsAppState())
  37. wire[GameAppResource].get
  38. }
  39. _ <- Resource.liftF(
  40. new MainApp(
  41. logger,
  42. gameApp,
  43. actorSystem,
  44. jmeScheduler,
  45. schedulers,
  46. consoleStream
  47. )(
  48. timeout,
  49. actorSystem.scheduler
  50. ).program
  51. )
  52. } yield ()
  53. def run(args: List[String]): UIO[ExitCode] = {
  54. lazy val consoleStream = GenericConsoleStream.textAreaStream()
  55. Console.withOut(consoleStream)(
  56. appResource(consoleStream)
  57. .use(_ => Task.unit)
  58. .onErrorHandle(_.printStackTrace())
  59. .as(ExitCode.Success)
  60. )
  61. }
  62. }