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

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
User avatar
Nanahs
Veteran
Posts: 297
Joined: Wed Aug 22, 2018 5:50 pm
Contact:

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

#1 Post by Nanahs » Thu Sep 06, 2018 10:42 am

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
Last edited by Nanahs on Mon Sep 10, 2018 3:57 pm, edited 2 times in total.

User avatar
TAEKO
Newbie
Posts: 21
Joined: Mon Jul 23, 2018 3:24 am
Contact:

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

#2 Post by TAEKO » 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
Don't read me...
Seriously don't.
Just kidding. I'm just an awkward potato who doesn't know what to say in my signature...

User avatar
Nanahs
Veteran
Posts: 297
Joined: Wed Aug 22, 2018 5:50 pm
Contact:

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

#3 Post by Nanahs » Thu Sep 06, 2018 2:29 pm

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 :)

User avatar
TAEKO
Newbie
Posts: 21
Joined: Mon Jul 23, 2018 3:24 am
Contact:

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

#4 Post by TAEKO » Thu Sep 06, 2018 9:23 pm

Glad to be of help :>
Don't forget to put [Solved] in the title
Don't read me...
Seriously don't.
Just kidding. I'm just an awkward potato who doesn't know what to say in my signature...

User avatar
Nanahs
Veteran
Posts: 297
Joined: Wed Aug 22, 2018 5:50 pm
Contact:

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

#5 Post by Nanahs » Fri Sep 07, 2018 8:56 am

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!

Post Reply

Who is online

Users browsing this forum: Bing [Bot]