Page 1 of 1

[solved] How do I establish a limit of points and show the score?

Posted: Thu Sep 06, 2018 10:42 am
by Nanahs
There's a part of my game where you have to compete with another character. And depending on your answers, you'll go to a different scene.
If you choose the correct answer 10 points will go to you. Otherwise it will go to Jhon.

Something like that:

Code: Select all

init:
    $ Jhon = 0
    $ You = 0
    

label start:
    scene window2
    with fade
    
    "What's the capital of US?"
    menu:
        "New York":
                $ Jhon += 10
        "Washignton":
                $ You += 10
    
    "Dolphins are"
    menu:
        "Mammals":
                $ You += 10
        "Fish":
                $ Jhon += 10
There will be many questions. Whoever makes 100 points first will win. Before jumping to the next scene, I'd like a text to show up saying "You won" or "Jhon won".
And I wanted the points to be shown like that:

Image

Does anyone know how I can display the points like that and establish a point limit?
I kind of got close to it at first, but I ended up mixing different codes and made a mess hah

What code system do you recommend me to use?

Thanks xx

Re: How do I establish a limit of points and show the score?

Posted: Thu Sep 06, 2018 12:34 pm
by TAEKO
Limiting the points:

Code: Select all

init python:
    Jhon = 0
    You = 0
    def ptlimit():
        if store.Jhon < 0:
            store.Jhon = 0
        elif store.Jhon > 100: #Let's say the max points is 100
            store.Jhon = 100
        if store.You < 0:
            store.You = 0
        elif store.You > 100:
            store.You = 100
    config.python_callbacks.append(ptlimit)
And the screens:

Code: Select all

screen Your_pts:
    vbox:
        xalign 1.0
        vbox:
            text "Your points:" xalign .5 size 30
            text "[You]" xalign 0.5

screen Jhon_pts:
    vbox:
        xalign 0.0
        vbox:
            text "Jhon's points:" xalign .5 size 30
            text "[Jhon]" xalign 0.5
Show the screens

Code: Select all

label start:
    scene window2
    with fade
    show screen Your_pts with dissolve
    show screen Jhon_pts with dissolve
    menu:
        "TESTING POINT LIMIT."
        "+101pts to You":
                $ You += 101
        "+101pts to Jhon":
                $ Jhon += 101

Re: How do I establish a limit of points and show the score?

Posted: Thu Sep 06, 2018 2:29 pm
by Nanahs
TAEKO wrote: Thu Sep 06, 2018 12:34 pm Limiting the points:

Code: Select all

init python:
    Jhon = 0
    You = 0
    def ptlimit():
        if store.Jhon < 0:
            store.Jhon = 0
        elif store.Jhon > 100: #Let's say the max points is 100
            store.Jhon = 100
        if store.You < 0:
            store.You = 0
        elif store.You > 100:
            store.You = 100
    config.python_callbacks.append(ptlimit)
And the screens:

Code: Select all

screen Your_pts:
    vbox:
        xalign 1.0
        vbox:
            text "Your points:" xalign .5 size 30
            text "[You]" xalign 0.5

screen Jhon_pts:
    vbox:
        xalign 0.0
        vbox:
            text "Jhon's points:" xalign .5 size 30
            text "[Jhon]" xalign 0.5
Show the screens

Code: Select all

label start:
    scene window2
    with fade
    show screen Your_pts with dissolve
    show screen Jhon_pts with dissolve
    menu:
        "TESTING POINT LIMIT."
        "+101pts to You":
                $ You += 101
        "+101pts to Jhon":
                $ Jhon += 101
Thank you sooo much! It really helped me.
I just couldn't make the game finish. Like, when one character got the 100 points, the game didn't finish. He winner just wouldn't get points anymore.
Where should I make the jump to the scene where you won or scene you lost, when the 100 points are reached?
Sorry, I feel like this is a stupid question, but I'm still learning this code language :)

EDIT: forget about it. It's working now hah Thanks for the code :)

Re: How do I establish a limit of points and show the score?

Posted: Thu Sep 06, 2018 9:23 pm
by TAEKO
Glad to be of help :>
Don't forget to put [Solved] in the title

Re: How do I establish a limit of points and show the score?

Posted: Fri Sep 07, 2018 8:56 am
by Nanahs
TAEKO wrote: Thu Sep 06, 2018 9:23 pm Glad to be of help :>
Don't forget to put [Solved] in the title
Thank you!