Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

FuncSug for facilitating web development by structuring one's code in the concurrent way

cli345

Coder
Hello! 🙂

FuncSug is a new programming language to facilitate web development (specially interactive site) by structuring one's code in the concurrent way.

For example, imagine you want to code a breakout game.
You would like to code something similar to:
Code:
in_the_same_time:
    run_the_ball()
    run_the_paddle_according_to_the_mouse_move()
    verify_and_manage_collision()
In usual programming language, that is not easily possible: You have to structure your code differently.
In FuncSug, it's possible: see, my breakout example.

With this structure, some modifications of code are very easy.
For example, the number of balls for each "life" can be change just by adding a line in a 'parallel' block (cfr line 236 of breakoutPy.fg).

Here is the main part (simplified) of my breakout code:
Code:
var column := |0, 1, 2, 3, 4|
var row := |0, 1, 2|
var numberOfLives := 3

parallel:
    
    # Bricks
    #--------
    
    # usually, you don't have to specify 'sequence' because it's the default but, here, you have to (because this is in a 'parallel' block)
    sequence:
        
        # 'parallel forEachValueOf myVar' makes one parallel branch for each value of myVar
        parallel forEachValueOf column:
            parallel forEachValueOf row:
                sequence:
                    # this executes all the life of the brick
                    lifeOfBrick(column, row)
        
        # When the lives of all bricks end, you win
        js ():
            alert("YOU WIN, CONGRATS!")
            document.location.reload()
    
    # Ball(s)
    #--------
    
    sequence:
        
        while numberOfLives > 0:
            # When numberOfLives > 0, (a) new(s) ball(s) come(s) to life
            parallel:
                # comment/uncomment the following line if you want one/two ball(s) for each "life"
                lifeOfBall()
                lifeOfBall()
            # When the life of the ball(s) end(s), numberOfLives decreases
            numberOfLives -= 1
        
        # When numberOfLives=0, you loose
        js ():
            alert("GAME OVER")
            document.location.reload()
    
    # Paddle
    #--------
    lifeOfPaddle()

Enjoy!
 

New Threads

Latest posts

Buy us a coffee!

Back
Top Bottom