What would the general structure of a reactive-banana game look like?

168 views Asked by At

A simple game that runs its logic every iteration and draws to the screen 60 times per second in an imperative language might look like this:

function main() {
    player = new Player()
    lastUpdateTime, lastDrawTime = getTime()
    while (!quit) {
        deltaTime = getTime() - lastUpdateTime
        player.update(deltaTime)
        if (getTime() - lastDrawTime > 1/60) {
            player.draw()
            lastDrawTime = getTime()
        }
        lastUpdateTime = getTime()
    }
    delete player
}

I'm just not sure how that translates to reactive-banana.

0

There are 0 answers