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.

32 lines
889 B

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.game.subsystems.level
  2. import com.jme3.bullet.PhysicsSpace
  3. import com.jme3.bullet.control.RigidBodyControl
  4. import com.jme3.light.AmbientLight
  5. import com.jme3.light.DirectionalLight
  6. import com.jme3.scene.Node
  7. import com.jme3.scene.Spatial
  8. import com.softwaremill.tagging._
  9. import monix.bio.Task
  10. import wow.doge.mygame.game.GameAppTags
  11. import wow.doge.mygame.implicits._
  12. class GameLevel(
  13. model: Spatial,
  14. physicsControl: RigidBodyControl,
  15. ambientLight: AmbientLight,
  16. directionalLight: DirectionalLight
  17. ) {
  18. def addToGame(
  19. rootNode: Node @@ GameAppTags.RootNode,
  20. physicsSpace: PhysicsSpace
  21. ) = {
  22. for {
  23. _ <- Task(rootNode += model)
  24. _ <- Task(rootNode :+ ambientLight)
  25. _ <- Task(rootNode :+ directionalLight)
  26. _ <- Task(physicsSpace += model)
  27. _ <- Task(physicsSpace += physicsControl)
  28. } yield ()
  29. }
  30. }