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.
|
|
package wow.doge.mygame
import com.jme3.app.StatsAppState
import monix.bio.Task import cats.effect.Resource import io.odin.syntax._
// import io.odin.monix._
import cats.effect.ExitCode import cats.implicits._ import com.softwaremill.macwire._ import scala.concurrent.duration._ import monix.bio.BIOApp import monix.bio.UIO import monix.bio.IO import io.odin._ import wow.doge.mygame.executors.JMERunner import com.jme3.bullet.BulletAppState import wow.doge.mygame.implicits._
// import wow.doge.mygame.implicits._
// object Main extends App {
// import java.util.logging.{Logger, Level}
// Logger.getLogger("").setLevel(Level.SEVERE)
// // runner.runCode("""|println("starting scala script engine")""".stripMargin)
// val gameApp = new GameApp(
// // new EntityDataState(),
// // new TestAppState(),
// // new PlayerMovementState(),
// // new FlyCamAppState(),
// new StatsAppState()
// )
// val settings = new AppSettings(true)
// // settings.setVSync(true)
// settings.setFrameRate(144)
// gameApp.setSettings(settings)
// val actorSystem = ActorSystem(RootActor(gameApp), "rootActor")
// // actorSystem.eventStream
// // gameApp.start()
// println("here 1")
// // actorSystem.terminate()
// // JMEExecutorService.shutdown()
// // println("here 2")
// //FIXME remove this
// // System.exit(0)
// }
object Main extends BIOApp with MainModule { import java.util.logging.{Logger => JLogger, Level} JLogger.getLogger("").setLevel(Level.SEVERE)
def run(args: List[String]): UIO[ExitCode] = {
lazy val appResource = for { logger <- consoleLogger().withAsync(timeWindow = 1.seconds) |+| fileLogger( "log.log" ).withAsync(timeWindow = 1.seconds) jmeScheduler <- jMESchedulerResource // consoleTextArea <- Resource.liftF(Task(new TextArea()))
// consoleStream <- wireWith(JFXConsoleStream.textAreaStream _)
gameApp <- { new BulletAppState() // bas.setThreadingType(Thr)
gameAppResource(new StatsAppState()) } _ <- Resource.liftF(IO(JMERunner.runner = gameApp)) actorSystem <- wireWith(actorSystemResource _) // _ <- Resource.liftF(
// Task(gameApp.start()).asyncBoundary
// .executeOn(Scheduler(JMEExecutorService))
// )
_ <- Resource.liftF(gameApp.enqueueT(actorSystem ! RootActor.Start)) _ <- Resource.liftF { IO(gameApp.start()) .executeOn(jmeScheduler) } // (_ => IO(gameApp.stop(() => actorSystem ! RootActor.Stop)))
} yield ()
// Console.withOut(
// new JFXConsoleStream(
// new scalafx.scene.control.TextArea(),
// new ByteArrayOutputStream(35)
// )
// )(())
appResource .use(_ => // Task(gameApp.start())
// .executeOn(Scheduler(JMEExecutorService))
// .asyncBoundary
// Task.never
Task.unit // >>
// .executeOn(Scheduler(JMEExecutorService))
) .onErrorHandle(_.printStackTrace()) .as(ExitCode.Success) } }
|