Skip to content

Commit

Permalink
Upgrading the docs site of 0.17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
davesmith00000 committed Apr 30, 2024
1 parent b99ab69 commit 66eaf6b
Show file tree
Hide file tree
Showing 12 changed files with 36 additions and 35 deletions.
22 changes: 10 additions & 12 deletions indigo/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion indigo/docs/01-quickstart/hello-indigo.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion indigo/docs/02-guides/howto-custom-entity.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion indigo/docs/03-gameloop/outcome.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
4 changes: 2 additions & 2 deletions indigo/docs/04-organisation/boot-and-start-up.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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", "")

Expand Down
6 changes: 3 additions & 3 deletions indigo/docs/04-organisation/scene-management.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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!
Expand Down Expand Up @@ -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
Expand Down
9 changes: 6 additions & 3 deletions indigo/docs/04-organisation/subsystems.md
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand All @@ -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)

Expand All @@ -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"))))
)
Expand Down
2 changes: 1 addition & 1 deletion indigo/docs/05-platform/assets.md
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
6 changes: 3 additions & 3 deletions indigo/docs/06-presentation/cameras.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
```

Expand Down Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions indigo/docs/06-presentation/layers.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
)
)
```

Expand Down
2 changes: 1 addition & 1 deletion indigo/docs/06-presentation/lighting.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
```

Expand Down
2 changes: 1 addition & 1 deletion indigo/docs/06-presentation/scene-update-fragment.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
Expand Down

0 comments on commit 66eaf6b

Please sign in to comment.