Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update 2048 tutorial to KorGE 3.0 #57

Open
soywiz opened this issue Sep 22, 2022 · 3 comments
Open

Update 2048 tutorial to KorGE 3.0 #57

soywiz opened this issue Sep 22, 2022 · 3 comments
Assignees
Labels
documentation Improvements or additions to documentation

Comments

@soywiz
Copy link
Member

soywiz commented Sep 22, 2022

No description provided.

@soywiz soywiz self-assigned this Sep 22, 2022
@dfyz8-g
Copy link

dfyz8-g commented Sep 23, 2022

Hello, Korge team
Could you write how long it will take?
I'm starting to explore korge, but as I've understood, the current 2048 game tutorial is not compatible with new korge version.
I can swap non-working code to working code independently, but I'm not sure that it will be correct. I mean that code will be work, but possible I will violate some rules/principles of engine. I want to use your game engine correct.
Thanks

@idle-code
Copy link

It would be nice to have it in the repo too - so it could be updated with the rest of the code

@krisbitney
Copy link

krisbitney commented Sep 30, 2022

I've just completed the tutorial. There are two breaking changes I've encountered so far that I would say aren't minor.

  1. The tutorial code doesn't result in centered score values as pictured, which is kind of annoying. But it seems like a bug in KorGE, not in the tutorial. If it's not a bug, I think a method named centerXOn is very misleading!

  2. The whole UI Skin model has been reworked since the tutorial was written, and it took a lot of digging to learn how to get the desired behavior. Compare the tutorial code in the "Game over overlay" section to my own:

fun Container.showGameOver(onRestart: () -> Unit) = container {
    position(leftIndent, topIndent)

    fun restart() {
        this@container.removeFromParent()
        onRestart()
    }

    roundRect(fieldSize, fieldSize, 5.0, fill = Colors["#FFFFFF33"])
    text("Game Over", 60.0, Colors.BLACK, font) {
        centerBetween(0.0, 0.0, fieldSize, fieldSize)
        y -= 60
    }
    uiText("Try again", 120.0, 35.0) {
        centerBetween(0.0, 0.0, fieldSize, fieldSize)
        y += 20

        uiSkin = UISkin {
            textColor = RGBA(0, 0, 0)
            textSize = 40.0
            font = font
        }
        onOver {
            textColor = RGBA(90, 90, 90)
        }
        onOut {
            textColor = RGBA(0, 0, 0)
        }
        onDown {
            textColor = RGBA(120, 120, 120)
        }

        onClick { restart() }
    }

    keys.down {
        when (it.key) {
            Key.ENTER, Key.SPACE -> restart()
            else -> Unit
        }
    }
}

@soywiz soywiz added the documentation Improvements or additions to documentation label Oct 11, 2022
@soywiz soywiz transferred this issue from korlibs/korge Dec 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
Status: Pending
Development

No branches or pull requests

4 participants