d
drikgodot

Simplified understanding for adding score to scoreboard

Hi,

I completed the practices for this lesson and appreciate how the practices build up. Thanks. 

This lesson may feel quite a step up from previous ones. The main struggle can be understanding how the important pieces all fit together. 

I came out with the below chart.

Is my understanding correct? 

Maybe this can help a newbie grasp the lesson too.


1 love
  • Nathan Lovato replied

    I agree that it's tricky when you first learn those things. The text in your diagram is correct, but the arrows with the numbers could be a source of confusion as the code doesn't exactly cycle.

    I would use perhaps more like two diagrams to represent that. One would show that you have a scoreboard that uses the score line scene. The point of such a diagram would be to show how different scenes are connected.

    We have some formal way to draw diagrams like these in code, UML, though I don't necessarily recommend learning all their rules unless you work in a company that requires it.

    Here's how it'd look like:

    The meaning of the line with a diamond that connects ScoreBoard and ScoreLine is that ScoreBoard uses ScoreLine but they're not absolutely dependent on one another (you can have a scoreboard without score lines, no problem).

    2 loves
  • Nathan Lovato replied

    Then come the steps. Code runs linearly. It gets a bit hard to understand when you start to split it into multiple files but the computer sees and executes a vertical list of instructions.

    Here, it goes like this.

    1. When the player clicks the pressed button, call the add_line function.
    2. Create a new instance (reproduction) of the ScoreLine scene.
    3. Add the new instance of the ScoreLine scene as a child of the scores column.
    4. Call the set_player_name() of the score line.
    5. ---- (Inside the scoreline script), change the text of the NameLabel
    6. (back to the scoreboard script) Call the set_player_points() function of the ScoreLine.
    7. ---- (Inside the scoreline script) change the text of the PointLabel.

    A difficulty is that the code is split across 4 functions and 2 files here. We hope to find the time to add more practices and challenges at the start of the course to help ease the learning a bit more.

    1 love
  • d
    drikgodot replied

    Thank you Nathan for the elaborate replies (shouldn't step 5 and 7 be swapped?).  

    Yes, personally I would have liked the 7 steps to be displayed at the top of the lesson for understanding how the program flow first.


  • Nathan Lovato replied

    I just swapped the two node names. And yes I think we could add a bullet list of what we need to do in lessons in this series, that'd help quite a bit. I'm taking note of this.