FuncSug: to make GUI (and so game) programming easier

2 years ago by cli345 to c/gamedev

Program like the event loop doesn't exist! FuncSug is a language that simplifies programming the reaction to events in browser. It aims to make more linear code in line with async/await and str...

Hello, 🙂

I created a new language called FuncSug. Its purpose is to make GUI programming in the browser easier and so game programming. The facility consists on eliminating asynchronism: In FuncSug, the code is no longer managed by an implicit/explicit global loop (I don't speak about implementation).

I intend, if I have time, to implement it for Godot as well. In FuncSug, the first tutorial of Godot would be roughly coded as this:

func showMessage(p_message):
    parallel exitWith branch 2 ||
        showIn(p_message, $MessageLabel)
    ||
        waitSeconds(2)

parallel ||
    while true:
        # Start of game
        parallel exitWith branch 2 ||
            showMessage('Dodge the\nCreeps')
        ||
            waitSeconds(1)
            awaitPressed($StartButton)
        get_tree().call_group(&"mobs", &"queue_free")
        score := 0
        $Player.start($StartPosition.position)
        
        # Middle of game
        parallel exitWith branch 1 ||
            awaitSignal('hit')
        ||
            while true:
                playSoundFile('House In a Forest Loop.ogg')
        ||
            showMessage('Get Ready')
            parallel ||
                while true:
                    waitSeconds(1)
                    score += 1
            ||
                while true:
                    waitSeconds(0.5)
                    callgd spawnMob()
        
        # End of game
        parallel ||
            showMessage('Game Over')
        ||
            playSoundFile('gameover.wav')
||
    while true:
        await score
        $ScoreLabel.text := score

The 'player.gd' and 'mob.gd' files would be keeped as they are. The "_on_MobTimer_timeout" function would be renamed as "spawnMob" and moved to 'mob.gd'. The timers wouldn't be needed any more.

Can you tell me what you think about it?

Reptorian 2 points 2 years ago

I don't understand the code, but it's good to see you doing things.

path: 0 15518809, hotness: undefined, score: 2, children: 2
cli345 2 points 2 years ago

Here, for example, is how the showMessage function would work:

  • $MessageLabel is a field defined by the programmer in Godot.
  • The showIn(p_message, p_place) function shows the message p_message in the field p_place.
  • waitSeconds(2) waits 2 seconds.
  • When the 2 seconds are elapsed, the second branch waitSeconds(2) is finished and so the parallel block is exited (because of exitWith branch 2) and the other branch (the first one) is definitely interrupted (because my parallel exitWith branch N does so).
  • The interruption of the first branch showIn(p_message, $MessageLabel) makes the $MessageLabel invisible.
path: 0 15518809 15519620, hotness: undefined, score: 2, children: 0
cli345 1 point 2 years ago

Yes, it's very different from what is done in G'MIC. Here, the language is preferably adapted to user interactions. There aren't many in G'MIC. 🙂

path: 0 15518809 15519086, hotness: undefined, score: 1, children: 0
obbeel 2 points 2 years ago

Anything that makes Godot better is a good thing.

path: 0 15519199, hotness: undefined, score: 2, children: 1
cli345 2 points 2 years ago

Thanks 🙂

path: 0 15519199 15519684, hotness: undefined, score: 2, children: 0
Valmond 2 points 2 years ago

I think it's a good learning experience, but a language isn't built over night...

path: 0 15516435, hotness: undefined, score: 2, children: 3
cli345 2 points 2 years ago

Yes, that's why I hope others will be able to join me. In the meantime, you can try FuncSug in the Playground. 🙂

path: 0 15516435 15518855, hotness: undefined, score: 2, children: 2
Valmond 2 points 2 years ago

I have written GUI from scratch at least 2 times (rendering open gl and up) so I'll skip this time, I do wish you all luck though!

path: 0 15516435 15518855 15523663, hotness: undefined, score: 2, children: 1
cli345 2 points 2 years ago

Thank you for your kind wish! 🙂

path: 0 15516435 15518855 15523663 15524712, hotness: undefined, score: 2, children: 0
gamedev
gamedev

@programming.dev

login for more options
6440
731
332

Welcome to the game development community! This is a place to talk about and post anything related to the field of game development.

Community Wiki

go to feed...