-
-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LookAt cams snap to pixels & respect magnification
- Loading branch information
1 parent
e53cc07
commit 1c62788
Showing
5 changed files
with
100 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
indigo/sandbox/src/main/scala/com/example/sandbox/scenes/CameraWithCloneTilesScene.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package com.example.sandbox.scenes | ||
|
||
import com.example.sandbox.SandboxAssets | ||
import com.example.sandbox.SandboxGameModel | ||
import com.example.sandbox.SandboxStartupData | ||
import com.example.sandbox.SandboxViewModel | ||
import indigo.* | ||
import indigo.scenes.* | ||
import indigo.syntax.* | ||
|
||
object CameraWithCloneTilesScene extends Scene[SandboxStartupData, SandboxGameModel, SandboxViewModel]: | ||
|
||
type SceneModel = Unit | ||
type SceneViewModel = Unit | ||
|
||
def eventFilters: EventFilters = | ||
EventFilters.Permissive | ||
|
||
def modelLens: Lens[SandboxGameModel, Unit] = | ||
Lens.unit | ||
|
||
def viewModelLens: Lens[SandboxViewModel, Unit] = | ||
Lens.unit | ||
|
||
def name: SceneName = | ||
SceneName("crates with camera") | ||
|
||
def subSystems: Set[SubSystem] = | ||
Set() | ||
|
||
def updateModel( | ||
context: SceneContext[SandboxStartupData], | ||
model: Unit | ||
): GlobalEvent => Outcome[Unit] = | ||
_ => Outcome(model) | ||
|
||
def updateViewModel( | ||
context: SceneContext[SandboxStartupData], | ||
model: Unit, | ||
viewModel: Unit | ||
): GlobalEvent => Outcome[Unit] = | ||
_ => Outcome(viewModel) | ||
|
||
val graphic = Graphic(64, 64, SandboxAssets.cratesMaterial.withLighting(LightingModel.Unlit)) | ||
|
||
val cloneId: CloneId = CloneId("crates") | ||
|
||
val cloneBlanks: Batch[CloneBlank] = | ||
Batch(CloneBlank(cloneId, graphic).static) | ||
|
||
val crates = | ||
(0 to 5).flatMap { row => | ||
(0 to 5).map { col => | ||
CloneTileData(col * 32, row * 32, Radians.zero, 1.0, 1.0, 0, 0, 32, 32) | ||
} | ||
}.toBatch | ||
|
||
def present( | ||
context: SceneContext[SandboxStartupData], | ||
model: Unit, | ||
viewModel: Unit | ||
): Outcome[SceneUpdateFragment] = | ||
Outcome( | ||
SceneUpdateFragment( | ||
Layer( | ||
CloneTiles(cloneId, crates) | ||
).withMagnification(2) | ||
.withCamera(Camera.LookAt(Point(96))) | ||
).addCloneBlanks(cloneBlanks) | ||
) |