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.

28 lines
832 B

4 years ago
4 years ago
4 years ago
  1. package wow.doge.mygame.game.subsystems.level
  2. import com.jme3.bullet.control.RigidBodyControl
  3. import com.jme3.light.AmbientLight
  4. import com.jme3.light.DirectionalLight
  5. import com.jme3.scene.Spatial
  6. import com.jme3.bullet.PhysicsSpace
  7. import cats.effect.concurrent.Ref
  8. import monix.bio.Task
  9. import com.jme3.scene.Node
  10. import wow.doge.mygame.implicits._
  11. class GameLevel(
  12. model: Spatial,
  13. physicsControl: RigidBodyControl,
  14. ambientLight: AmbientLight,
  15. directionalLight: DirectionalLight
  16. ) {
  17. def addToGame(rootNode: Ref[Task, Node], physicsSpace: PhysicsSpace) = {
  18. for {
  19. _ <- rootNode.update(_ :+ model)
  20. _ <- rootNode.update(_ :+ ambientLight)
  21. _ <- rootNode.update(_ :+ directionalLight)
  22. _ <- Task(physicsSpace += model)
  23. _ <- Task(physicsSpace += physicsControl)
  24. } yield ()
  25. }
  26. }