diff --git a/indigo/build.sbt b/indigo/build.sbt index 0f3621c59..bbe8d16a8 100644 --- a/indigo/build.sbt +++ b/indigo/build.sbt @@ -131,11 +131,11 @@ lazy val sandbox = .embedFont( "TestFont", os.pwd / "sandbox" / "assets" / "fonts" / "pixelated.ttf", - FontOptions( - "test font", - 32, - CharSet.fromUniqueString("The quick brown fox\njumps over the\nlazy dog.") - ) + FontOptions( + "test font", + 32, + CharSet.fromUniqueString("The quick brown fox\njumps over the\nlazy dog.") + ) .withColor(RGB.White) .withMaxCharactersPerLine(16) .noAntiAliasing, @@ -275,13 +275,11 @@ lazy val jsdocs = project organization := "io.indigoengine", libraryDependencies ++= Dependencies.jsDocs.value, libraryDependencies ++= Seq( - "io.indigoengine" %%% "indigo-json-circe" % indigoDocsVersion, - "io.indigoengine" %%% "indigo" % indigoDocsVersion, - "io.indigoengine" %%% "indigo-extras" % indigoDocsVersion, - // TODO: After next release (>0.15.2), should be Dependencies.Versions.tyrianVersion - "io.indigoengine" %%% "tyrian-io" % tyrianDocsVersion, - // TODO: After next release (>0.15.2), should be indigoDocsVersion - "io.indigoengine" %%% "tyrian-indigo-bridge" % tyrianDocsVersion + "io.indigoengine" %%% "indigo-json-circe" % indigoDocsVersion, + "io.indigoengine" %%% "indigo" % indigoDocsVersion, + "io.indigoengine" %%% "indigo-extras" % indigoDocsVersion, + "io.indigoengine" %%% "tyrian-io" % tyrianDocsVersion, + "io.indigoengine" %%% "tyrian-indigo-bridge" % indigoDocsVersion ), Compile / tpolecatExcludeOptions ++= Set( ScalacOptions.warnValueDiscard, diff --git a/indigo/docs/01-quickstart/hello-indigo.md b/indigo/docs/01-quickstart/hello-indigo.md index 10dae5912..9b7455447 100644 --- a/indigo/docs/01-quickstart/hello-indigo.md +++ b/indigo/docs/01-quickstart/hello-indigo.md @@ -435,7 +435,7 @@ val model = Model.initial(Point.zero) def drawDots( center: Point, dots: Batch[Dot] -): Batch[Graphic[_]] = +): Batch[Graphic[?]] = dots.map { dot => val position = Point( x = (Math.sin(dot.angle.toDouble) * dot.orbitDistance + center.x).toInt, diff --git a/indigo/docs/02-guides/howto-custom-entity.md b/indigo/docs/02-guides/howto-custom-entity.md index 90da4d895..2b285252b 100644 --- a/indigo/docs/02-guides/howto-custom-entity.md +++ b/indigo/docs/02-guides/howto-custom-entity.md @@ -122,7 +122,7 @@ First, tell indigo about the new shader: In the sandbox this would be a game field just like assets and fonts, i.e. `val shaders: Set[Shader] = Set(MyColoredEntity.shader)`, and there is an equivalent for the `BootResult` type as follows: ```scala mdoc:js -def boot(flags: Map[String, String]): Outcome[BootResult[Unit]] = +def boot(flags: Map[String, String]): Outcome[BootResult[Unit, Unit]] = Outcome( BootResult .noData(GameConfig.default) diff --git a/indigo/docs/03-gameloop/outcome.md b/indigo/docs/03-gameloop/outcome.md index 4453a81a0..8d7f09fd8 100644 --- a/indigo/docs/03-gameloop/outcome.md +++ b/indigo/docs/03-gameloop/outcome.md @@ -51,7 +51,7 @@ Outcome(10).map(_ * 20) // Outcome(200) Outcome(10).ap(Outcome((i: Int) => i * 5)) // Outcome(50) Outcome(10).flatMap(i => Outcome(i * 20)) // Outcome(200) Outcome(10).merge(Outcome(20))(_ + _) // Outcome(30) -Outcome("a") combine Outcome("b") // Outcome(("a", "b")) +Outcome("a") `combine` Outcome("b") // Outcome(("a", "b")) ``` As mentioned, `Outcome`'s map function is bias towards the state, but you can also modify the events with `mapGlobalEvents`. diff --git a/indigo/docs/04-organisation/boot-and-start-up.md b/indigo/docs/04-organisation/boot-and-start-up.md index ec33ed045..e5dc701d3 100644 --- a/indigo/docs/04-organisation/boot-and-start-up.md +++ b/indigo/docs/04-organisation/boot-and-start-up.md @@ -28,7 +28,7 @@ import indigo.* final case class BootData(myData: String) -def boot(flags: Map[String, String]): Outcome[BootResult[BootData]] = ??? +def boot(flags: Map[String, String]): Outcome[BootResult[BootData, Unit]] = ??? ``` #### Flags @@ -46,7 +46,7 @@ Well we use a flag, like this: ```scala mdoc:js import indigo.* -def boot(flags: Map[String, String]): Outcome[BootResult[GameViewport]] = { +def boot(flags: Map[String, String]): Outcome[BootResult[GameViewport, Unit]] = { val assetPath: String = flags.getOrElse("baseUrl", "") diff --git a/indigo/docs/04-organisation/scene-management.md b/indigo/docs/04-organisation/scene-management.md index 688b6a18c..4326d69ec 100644 --- a/indigo/docs/04-organisation/scene-management.md +++ b/indigo/docs/04-organisation/scene-management.md @@ -65,7 +65,7 @@ trait Scene[StartUpData, GameModel, ViewModel] derives CanEqual { def modelLens: Lens[GameModel, SceneModel] def viewModelLens: Lens[ViewModel, SceneViewModel] def eventFilters: EventFilters - def subSystems: Set[SubSystem] + def subSystems: Set[SubSystem[GameModel]] def updateModel(context: SceneContext[StartUpData], model: SceneModel): GlobalEvent => Outcome[SceneModel] def updateViewModel(context: SceneContext[StartUpData], model: SceneModel, viewModel: SceneViewModel): GlobalEvent => Outcome[SceneViewModel] @@ -164,7 +164,7 @@ object LevelScene extends Scene[Unit, DungeonGameModel, Unit]: def modelLens: Lens[DungeonGameModel, LevelModel] = Lens(_.level, (m, lvl) => m.copy(level = lvl)) def viewModelLens: Lens[Unit, Unit] = Lens.unit def name: SceneName = SceneName("level") - def subSystems: Set[SubSystem] = Set() + def subSystems: Set[SubSystem[DungeonGameModel]] = Set() def updateModel(context: SceneContext[Unit], model: LevelModel): GlobalEvent => Outcome[LevelModel] = _ => Outcome(model.copy(health = model.health + 1)) // On any event, increase health! @@ -228,7 +228,7 @@ val inventory = Inventory(Weapons(Sword(1))) val betterSword = Sword(2) val mySwordLens = - inventoryLens andThen weaponsLens // Composing lenses! + inventoryLens `andThen` weaponsLens // Composing lenses! mySwordLens.get(inventory) // a sword mySwordLens.set(inventory, betterSword) // an inventory with a better sword in it diff --git a/indigo/docs/04-organisation/subsystems.md b/indigo/docs/04-organisation/subsystems.md index 790d3d87c..161ecded6 100644 --- a/indigo/docs/04-organisation/subsystems.md +++ b/indigo/docs/04-organisation/subsystems.md @@ -16,9 +16,10 @@ As an example, consider this simple (and arguably unhelpful) subsystem that trac ```scala mdoc:js import indigo.* -final case class PointsTrackerExample(startingPoints: Int) extends SubSystem: +final case class PointsTrackerExample(startingPoints: Int) extends SubSystem[Unit]: type EventType = PointsTrackerEvent type SubSystemModel = Int + type ReferenceData = Unit val id: SubSystemId = SubSystemId("points tracker") @@ -27,10 +28,12 @@ final case class PointsTrackerExample(startingPoints: Int) extends SubSystem: case _ => None } + def reference(model: Unit): Unit = () + def initialModel: Outcome[Int] = Outcome(startingPoints) - def update(context: SubSystemFrameContext, points: Int): PointsTrackerEvent => Outcome[Int] = { + def update(context: SubSystemFrameContext[Unit], points: Int): PointsTrackerEvent => Outcome[Int] = { case PointsTrackerEvent.Add(pts) => Outcome(points + pts) @@ -39,7 +42,7 @@ final case class PointsTrackerExample(startingPoints: Int) extends SubSystem: .addGlobalEvents(GameOver) } - def present(context: SubSystemFrameContext, points: Int): Outcome[SceneUpdateFragment] = + def present(context: SubSystemFrameContext[Unit], points: Int): Outcome[SceneUpdateFragment] = Outcome( SceneUpdateFragment(Text(points.toString, FontKey(""), Material.Bitmap(AssetName("font")))) ) diff --git a/indigo/docs/05-platform/assets.md b/indigo/docs/05-platform/assets.md index e35352b90..4e1a746fc 100644 --- a/indigo/docs/05-platform/assets.md +++ b/indigo/docs/05-platform/assets.md @@ -64,7 +64,7 @@ val assets: Set[AssetType] = ) // Or if you're using the IndigoDemo` or `IndigoGame` entry points -def boot(flags: Map[String, String]): BootResult[Unit] = +def boot(flags: Map[String, String]): BootResult[Unit, Unit] = BootResult.noData(GameConfig.default) .withAssets( Set( diff --git a/indigo/docs/06-presentation/cameras.md b/indigo/docs/06-presentation/cameras.md index 5535a5f5e..8aa0462a1 100644 --- a/indigo/docs/06-presentation/cameras.md +++ b/indigo/docs/06-presentation/cameras.md @@ -43,7 +43,7 @@ Camera.LookAt(Point(10, 10), Zoom.x2, Radians.fromDegrees(45)) Cameras can be optionally added to your `SceneUpdateFragment`s or `Layer`s, e.g.: ```scala mdoc:js -Layer(BindingKey("my layer")) +Layer.empty .withCamera(Camera.LookAt(Point(10, 10), Zoom.x2, Radians.fromDegrees(45))) ``` @@ -72,8 +72,8 @@ val sceneB = SceneUpdateFragment.empty.withCamera(Camera.LookAt(Point(20, 20))) ..where as here, the camera in `layerA` looking at position `Point(10, 10)` is selected. ```scala mdoc:js -val layerA = Layer(BindingKey("Layer A")).withCamera(Camera.LookAt(Point(10, 10))) -val layerB = Layer(BindingKey("Layer B")).withCamera(Camera.LookAt(Point(20, 20))) +val layerA = Layer.empty.withCamera(Camera.LookAt(Point(10, 10))) +val layerB = Layer.empty.withCamera(Camera.LookAt(Point(20, 20))) ``` ```scala diff --git a/indigo/docs/06-presentation/layers.md b/indigo/docs/06-presentation/layers.md index 103952d31..33beef0b8 100644 --- a/indigo/docs/06-presentation/layers.md +++ b/indigo/docs/06-presentation/layers.md @@ -70,10 +70,10 @@ However, you may want to merge scenes and have all the elements end up on the sa ```scala mdoc:js val c = SceneUpdateFragment( - Layer(BindingKey("my layer"), graphicA, graphicA, graphicA) + BindingKey("my layer") -> Layer(graphicA, graphicA, graphicA) ) val d = SceneUpdateFragment( - Layer(BindingKey("my layer"), graphicB, graphicB, graphicB) + BindingKey("my layer") -> Layer(graphicB, graphicB, graphicB) ) c |+| d @@ -83,10 +83,10 @@ Results in: ```scala mdoc:js SceneUpdateFragment( - Layer( - BindingKey("my layer"), - Batch(graphicA, graphicA, graphicA, graphicB, graphicB, graphicB) - ) + BindingKey("my layer") -> + Layer.Content( + Batch(graphicA, graphicA, graphicA, graphicB, graphicB, graphicB) + ) ) ``` diff --git a/indigo/docs/06-presentation/lighting.md b/indigo/docs/06-presentation/lighting.md index a42d25e1a..8ec0e9b1c 100644 --- a/indigo/docs/06-presentation/lighting.md +++ b/indigo/docs/06-presentation/lighting.md @@ -49,7 +49,7 @@ Dynamic lighting changes the scene's lighting as the light moves around. It high ```scala mdoc:js SceneUpdateFragment( - Layer(BindingKey("my layer")).withLights(PointLight(Point(100, 100), RGBA.Green)) + Layer.empty.withLights(PointLight(Point(100, 100), RGBA.Green)) ).withLights(AmbientLight(RGBA.Blue.withAlpha(0.2))) ``` diff --git a/indigo/docs/06-presentation/scene-update-fragment.md b/indigo/docs/06-presentation/scene-update-fragment.md index 8d113b178..92bbc43b3 100644 --- a/indigo/docs/06-presentation/scene-update-fragment.md +++ b/indigo/docs/06-presentation/scene-update-fragment.md @@ -12,7 +12,7 @@ val graphic = .withLighting(LightingModel.Lit.flat)) SceneUpdateFragment( - Layer(BindingKey("game layer"), graphic) + BindingKey("game layer") -> Layer(graphic) ) .withLights( AmbientLight(RGBA.White.withAmount(0.25)),