Skip to content
This repository was archived by the owner on May 14, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Global / onChangedBuildSource := ReloadOnSourceChanges

ThisBuild / scalafixDependencies += "com.github.liancheng" %% "organize-imports" % "0.5.0"

val scala3Version = "3.3.1"
val scala3Version = "3.4.1"

lazy val pirateOptions: IndigoOptions =
IndigoOptions.defaults
Expand Down Expand Up @@ -43,9 +43,9 @@ lazy val pirate =
.settings(
indigoOptions := pirateOptions,
libraryDependencies ++= Seq(
"io.indigoengine" %%% "indigo-json-circe" % "0.16.0",
"io.indigoengine" %%% "indigo" % "0.16.0",
"io.indigoengine" %%% "indigo-extras" % "0.16.0"
"io.indigoengine" %%% "indigo-json-circe" % "0.16.1-SNAPSHOT",
"io.indigoengine" %%% "indigo" % "0.16.1-SNAPSHOT",
"io.indigoengine" %%% "indigo-extras" % "0.16.1-SNAPSHOT"
),
Compile / sourceGenerators += Def.task {
val cachedFun = FileFunction.cached(
Expand Down
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.9.8
sbt.version=1.9.9
4 changes: 2 additions & 2 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.15.0")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.16.0")
addSbtPlugin("org.typelevel" % "sbt-tpolecat" % "0.5.0")
addSbtPlugin("io.indigoengine" % "sbt-indigo" % "0.16.0")
addSbtPlugin("io.indigoengine" % "sbt-indigo" % "0.16.1-SNAPSHOT")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.6")
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.31")
addSbtPlugin("com.github.reibitto" % "sbt-welcome" % "0.3.1")
Expand Down
14 changes: 7 additions & 7 deletions src/main/scala/pirate/CursedPirateDemo.scala
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ object CursedPirateDemo extends IndigoGame[BootInformation, StartupData, Model,
val eventFilters: EventFilters =
EventFilters.BlockAll

def boot(flags: Map[String, String]): Outcome[BootResult[BootInformation]] =
def boot(flags: Map[String, String]): Outcome[BootResult[BootInformation, Model]] =
Outcome {
val assetPath: String =
flags.getOrElse("baseUrl", "")
Expand All @@ -44,7 +44,7 @@ object CursedPirateDemo extends IndigoGame[BootInformation, StartupData, Model,
).withAssets(Assets.initialAssets(assetPath))
.withFonts(Assets.Fonts.fontInfo)
.withSubSystems(
// indigoextras.subsystems.FPSCounter(Point(10, 10), LayerKeys.fps)
indigoextras.subsystems.FPSCounter(Point(10, 10), LayerKeys.fps)
)
}

Expand Down Expand Up @@ -74,9 +74,9 @@ object CursedPirateDemo extends IndigoGame[BootInformation, StartupData, Model,
def present(context: FrameContext[StartupData], model: Model, viewModel: ViewModel): Outcome[SceneUpdateFragment] =
Outcome(
SceneUpdateFragment.empty
.addLayer(Layer(LayerKeys.background))
.addLayer(Layer(LayerKeys.bigClouds))
.addLayer(Layer(LayerKeys.smallClouds))
.addLayer(Layer(LayerKeys.game))
.addLayer(Layer(LayerKeys.fps))
.addLayer(LayerEntry(LayerKeys.background, Layer.Content.empty))
.addLayer(LayerEntry(LayerKeys.bigClouds, Layer.Content.empty))
.addLayer(LayerEntry(LayerKeys.smallClouds, Layer.Content.empty))
.addLayer(LayerEntry(LayerKeys.game, Layer.Content.empty))
.addLayer(LayerEntry(LayerKeys.fps, Layer.Content.empty))
)
2 changes: 1 addition & 1 deletion src/main/scala/pirate/scenes/level/LevelScene.scala
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ final case class LevelScene(screenWidth: Int) extends Scene[StartupData, Model,
val eventFilters: EventFilters =
EventFilters.Restricted

val subSystems: Set[SubSystem] =
val subSystems: Set[SubSystem[Model]] =
Set(
CloudsAutomata.automata,
CloudsSubSystem(screenWidth)
Expand Down
34 changes: 17 additions & 17 deletions src/main/scala/pirate/scenes/level/LevelView.scala
Original file line number Diff line number Diff line change
Expand Up @@ -87,18 +87,18 @@ object LevelView:
.map { levelAssets =>
SceneUpdateFragment.empty
.addLayer(
Layer(
LayerKeys.background,
Batch(Graphic(Rectangle(0, 0, 640, 360), 50, assets.static.bgMaterial)) ++
drawWater(levelAssets.waterReflections)
)
LayerKeys.background ->
Layer(
Batch(Graphic(Rectangle(0, 0, 640, 360), 50, assets.static.bgMaterial)) ++
drawWater(levelAssets.waterReflections)
)
)
.addLayer(
Layer(
LayerKeys.game,
drawForeground(levelAssets)
++ drawChest(chestCollider, spaceConvertors)
)
LayerKeys.game ->
Layer(
drawForeground(levelAssets)
++ drawChest(chestCollider, spaceConvertors)
)
)
.withAudio(
assets.sounds.bgmusicSceneAudio
Expand Down Expand Up @@ -151,14 +151,14 @@ object LevelView:
): SceneUpdateFragment =
SceneUpdateFragment.empty
.addLayer(
Layer(
LayerKeys.game,
respawnEffect(
gameTime,
pirate.lastRespawn,
updatedCaptain(pirate, collider, pirateViewState, captainClips, spaceConvertors)
LayerKeys.game ->
Layer(
respawnEffect(
gameTime,
pirate.lastRespawn,
updatedCaptain(pirate, collider, pirateViewState, captainClips, spaceConvertors)
)
)
)
)

val respawnFlashSignal: Seconds => Signal[(Boolean, Boolean)] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import indigo.*
import indigoextras.subsystems.*
import pirate.core.Assets
import pirate.core.LayerKeys
import pirate.core.Model

/*
An instance of a standard Automata SubSystem, you can think of this
Expand Down Expand Up @@ -52,7 +53,7 @@ object CloudsAutomata:

val poolKey: AutomataPoolKey = AutomataPoolKey("cloud")

val automata: Automata =
val automata: Automata[Model] =
Automata(
poolKey,
automaton,
Expand Down
47 changes: 26 additions & 21 deletions src/main/scala/pirate/scenes/level/subsystems/CloudsSubSystem.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,21 @@ import indigo.*
import indigoextras.subsystems.*
import pirate.core.Assets
import pirate.core.LayerKeys
import pirate.core.Model

/*
The `CloudsSubSystem` does two things:
1. Directly manages the constantly rolling big clouds on the horizon;
2. Emits periodic events telling the cloud automata system to spawn
a new small cloud.
*/
final case class CloudsSubSystem(screenWidth: Int) extends SubSystem:
final case class CloudsSubSystem(screenWidth: Int) extends SubSystem[Model]:

val verticalCenter: Int = 181

type EventType = FrameTick
type SubSystemModel = CloudsState
type ReferenceData = Unit

def id: SubSystemId = SubSystemId("clouds")

Expand All @@ -25,10 +27,13 @@ final case class CloudsSubSystem(screenWidth: Int) extends SubSystem:
case _ => None
}

def reference(model: Model): ReferenceData =
()

def initialModel: Outcome[CloudsState] =
Outcome(CloudsState.initial)

def update(context: SubSystemFrameContext, model: SubSystemModel): EventType => Outcome[SubSystemModel] =
def update(context: SubSystemFrameContext[Unit], model: SubSystemModel): EventType => Outcome[SubSystemModel] =
case FrameTick if context.gameTime.running - model.lastSpawn > Seconds(3.0) =>
Outcome(
CloudsState(
Expand Down Expand Up @@ -59,28 +64,28 @@ final case class CloudsSubSystem(screenWidth: Int) extends SubSystem:
)
)

def present(context: SubSystemFrameContext, model: SubSystemModel): Outcome[SceneUpdateFragment] =
def present(context: SubSystemFrameContext[Unit], model: SubSystemModel): Outcome[SceneUpdateFragment] =
Outcome(
SceneUpdateFragment.empty
.addLayer(
Layer(
LayerKeys.bigClouds,
Assets.Clouds.bigCloudsGraphic
.moveTo(
model.bigCloudPosition.toInt - Assets.Clouds.bigCloudsWidth,
verticalCenter
),
Assets.Clouds.bigCloudsGraphic
.moveTo(
model.bigCloudPosition.toInt,
verticalCenter
),
Assets.Clouds.bigCloudsGraphic
.moveTo(
model.bigCloudPosition.toInt + Assets.Clouds.bigCloudsWidth,
verticalCenter
)
)
LayerKeys.bigClouds ->
Layer(
Assets.Clouds.bigCloudsGraphic
.moveTo(
model.bigCloudPosition.toInt - Assets.Clouds.bigCloudsWidth,
verticalCenter
),
Assets.Clouds.bigCloudsGraphic
.moveTo(
model.bigCloudPosition.toInt,
verticalCenter
),
Assets.Clouds.bigCloudsGraphic
.moveTo(
model.bigCloudPosition.toInt + Assets.Clouds.bigCloudsWidth,
verticalCenter
)
)
)
)

Expand Down
4 changes: 2 additions & 2 deletions src/main/scala/pirate/scenes/loading/LoadingScene.scala
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ final case class LoadingScene(assetPath: String, screenDimensions: Rectangle)
val eventFilters: EventFilters =
EventFilters.Restricted

val subSystems: Set[SubSystem] =
Set(AssetBundleLoader)
val subSystems: Set[SubSystem[Model]] =
Set(AssetBundleLoader[Model])

def updateModel(
context: SceneContext[StartupData],
Expand Down