-
-
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.
- Loading branch information
1 parent
96e7db9
commit f6560cc
Showing
14 changed files
with
98 additions
and
100 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
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
124 changes: 67 additions & 57 deletions
124
indigo/indigo/src/main/scala/indigo/shared/config/GameViewport.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 |
---|---|---|
@@ -1,57 +1,67 @@ | ||
package indigo.shared.config | ||
|
||
import indigo.shared.datatypes.Point | ||
import indigo.shared.datatypes.Rectangle | ||
import indigo.shared.datatypes.Size | ||
|
||
/** Respresents the initial size of the game's viewport. | ||
* | ||
* @param width | ||
* Width in pixels | ||
* @param height | ||
* Height in pixels | ||
*/ | ||
final case class GameViewport(size: Size) derives CanEqual: | ||
val width: Int = size.width | ||
val height: Int = size.height | ||
val horizontalMiddle: Int = width / 2 | ||
val verticalMiddle: Int = height / 2 | ||
val center: Point = Point(horizontalMiddle, verticalMiddle) | ||
|
||
@deprecated("use 'toRectangle' instead") | ||
def asRectangle: Rectangle = | ||
toRectangle | ||
def toRectangle: Rectangle = | ||
Rectangle(Point.zero, size) | ||
|
||
def toPoint: Point = | ||
size.toPoint | ||
|
||
def toSize: Size = | ||
size | ||
|
||
def bounds: Rectangle = | ||
toRectangle | ||
|
||
def giveDimensions(magnification: Int): Rectangle = | ||
Rectangle(0, 0, width / magnification, height / magnification) | ||
|
||
object GameViewport: | ||
|
||
def apply(width: Int, height: Int): GameViewport = | ||
GameViewport(Size(width, height)) | ||
|
||
val atWUXGA: GameViewport = | ||
GameViewport(1920, 1200) | ||
val atWUXGABy2: GameViewport = | ||
GameViewport(960, 600) | ||
|
||
val at1080p: GameViewport = | ||
GameViewport(1920, 1080) | ||
val at1080pBy2: GameViewport = | ||
GameViewport(960, 540) | ||
|
||
val at720p: GameViewport = | ||
GameViewport(1280, 720) | ||
val at720pBy2: GameViewport = | ||
GameViewport(640, 360) | ||
//package indigo.shared.config | ||
// | ||
//import indigo.shared.datatypes.Point | ||
//import indigo.shared.datatypes.Rectangle | ||
//import indigo.shared.datatypes.Size | ||
// | ||
////opaque type GameViewport = Size | ||
////object GameViewport: | ||
//// def apply(size: Size): GameViewport = size | ||
//// | ||
//// extension (g: GameViewport) | ||
//// def toSize: Size = g | ||
//// | ||
//// | ||
// | ||
///** Respresents the initial size of the game's viewport. | ||
// * | ||
// * @param width | ||
// * Width in pixels | ||
// * @param height | ||
// * Height in pixels | ||
// */ | ||
//final case class GameViewport(size: Size) derives CanEqual: | ||
// export size.* | ||
//// val width: Int = size.width | ||
//// val height: Int = size.height | ||
//// val horizontalMiddle: Int = width / 2 | ||
//// val verticalMiddle: Int = height / 2 | ||
//// val center: Point = Point(horizontalMiddle, verticalMiddle) | ||
// | ||
//// @deprecated("use 'toRectangle' instead") | ||
//// def asRectangle: Rectangle = | ||
//// toRectangle | ||
//// def toRectangle: Rectangle = | ||
//// Rectangle(Point.zero, size) | ||
//// | ||
//// def toPoint: Point = | ||
//// size.toPoint | ||
//// | ||
//// def toSize: Size = | ||
//// size | ||
//// | ||
//// def bounds: Rectangle = | ||
//// toRectangle | ||
//// | ||
// def giveDimensions(magnification: Int): Rectangle = | ||
// Rectangle(0, 0, width / magnification, height / magnification) | ||
// | ||
//object GameViewport: | ||
// | ||
// def apply(width: Int, height: Int): GameViewport = | ||
// GameViewport(Size(width, height)) | ||
// | ||
// val atWUXGA: GameViewport = | ||
// GameViewport(1920, 1200) | ||
// val atWUXGABy2: GameViewport = | ||
// GameViewport(960, 600) | ||
// | ||
// val at1080p: GameViewport = | ||
// GameViewport(1920, 1080) | ||
// val at1080pBy2: GameViewport = | ||
// GameViewport(960, 540) | ||
// | ||
// val at720p: GameViewport = | ||
// GameViewport(1280, 720) | ||
// val at720pBy2: GameViewport = | ||
// GameViewport(640, 360) |
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
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
Oops, something went wrong.