Skip to content

Commit

Permalink
Fix screenshot not working with camera
Browse files Browse the repository at this point in the history
  • Loading branch information
dwursteisen committed Mar 18, 2024
1 parent d105f6c commit f04767e
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class CtrlLib(
"- 1: right click or two fingers\n" +
"- 2: middle click or three fingers\n\n" +
"If you need to check that the touch/mouse button is still active, see `ctrl.touching` instead.",
CTRL_TOUCHED_EXAMPLE
CTRL_TOUCHED_EXAMPLE,
)
inner class touched : OneArgFunction() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ class SfxLib(
fun LuaTable.toWave(mod: Modulation?, env: Envelope): SoundGenerator {
val noteIndex = this["note"].toint()
val volume = this["volume"].toint() / 255f
if(noteIndex == 0 || volume <= 0) {
if (noteIndex == 0 || volume <= 0) {
return Silence2(Note.C0, null, null, 0f)
}
return when (this["type"].tojstring()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ class SprLib(val gameOptions: GameOptions, val resourceAccess: GameResourceAcces
"Switch to another spritesheet. " +
"The index of the spritesheet is given by it's position in the spritesheets field from the `_tiny.json` file." +
"The first spritesheet is at the index 0. It retuns the previous spritesheet. " +
"The spritesheet can also be referenced by its filename.",
example = SPR_SHEET_EXAMPLE
"The spritesheet can also be referenced by its filename.",
example = SPR_SHEET_EXAMPLE,
)
internal inner class sheet : OneArgFunction() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,6 @@ class GlfwPlatform(
}

override fun screenshot() {
// FIXME: it doesn't play well with camera
// FIXME: debug and camera doesn't play well also.
val buffer = lastBuffer ?: return

recordScope.launch {
Expand All @@ -273,7 +271,12 @@ class GlfwPlatform(

for (y in 0 until height) {
for (x in 0 until width) {
val colorData = buffer.gamePalette.getRGBA(buffer.pixel(x, y))
val colorData = buffer.gamePalette.getRGBA(
buffer.pixel(
x = buffer.camera.x + x,
y = buffer.camera.y + y,
),
)
val r = colorData[0].toInt() and 0xff
val g = colorData[1].toInt() and 0xff
val b = colorData[2].toInt() and 0xff
Expand Down

0 comments on commit f04767e

Please sign in to comment.