Displaying Earned Points?

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
JimPanse
Newbie
Posts: 13
Joined: Wed Apr 28, 2021 1:36 pm
Contact:

Displaying Earned Points?

#1 Post by JimPanse »

Hey there guys,

so here's the problem (well, not really a problem, but something I'd like to do :-)) In my game, I got the menus where the player can make a choice and gets/loses points according to that decision, the usual stuff. You know, just like this

Code: Select all

    menu:
        "Compliment her":
            $ char1 += 2
            jump choice48_yes

        "Be blunt about it":
            $ char1 -= 2
            jump choice48_no
It's all fine and dandy and works as intended. I can create different events happening on the basis of the points count with if/else contitions, all good.
Now I was thinking, it would be kinda nice if the player could see how many points he's earned. For example, like a little icon in the top right corner of the screen for each of the characters with a counter which displays the points the player has earned for each character. So when the player makes a decision the corresponding points are added/substracted in real-time basically.

Is something like that doable with renpy and if so, could you please point me in the right direction on how to achieve this? I'd really appreciate it.

Kind Regards

User avatar
m_from_space
Miko-Class Veteran
Posts: 941
Joined: Sun Feb 21, 2021 3:36 am
Contact:

Re: Displaying Earned Points?

#2 Post by m_from_space »

Whenever you want to show something to the player you just need to create a screen.

Here you can find all you need to know: https://www.renpy.org/doc/html/screens.html

Code: Select all

default points = 0

screen points:
    text "[points]"

label start:
    show screen points
    "Hello. I will give you some points."
    $ points += 100
    "See? But, not I am reducing them again."
    $ points -= 50
    "Done."

JimPanse
Newbie
Posts: 13
Joined: Wed Apr 28, 2021 1:36 pm
Contact:

Re: Displaying Earned Points?

#3 Post by JimPanse »

Hi m_from_space,

thanks a lot for your reply.
I see what you're doing there, but just to make sure I undestand correctly. Am I correct in saying that your proposed method would show the player that he's earned some points just at the point where the corresponding label starts? And after that the screen disappears again?

If I'm correct then this is not what I'm trying to achieve. Imagine you're playing the game which has, let's say 5 different characters, and while you're playing there are 5 little icons in the top left corner of the screen, one for each of the characters. These icons are there permanently and a little counter under these icons shows the points the player has earned with each character. These counters are updated automatically when the player makes a choice for a character.

I found a game where it's doing just that. I've attached a screenshot for you to see what I mean.

Image

It doesn't have to be that fancy, but in general this is what I'm trying to do :-)
Also it doesn't really have to be on-screen all the time. I think I remember seeing games that put these stuff behind a button somewhere which basically opened some sort of stats screen where you could check your earned points.

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2384
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Displaying Earned Points?

#4 Post by Ocelot »

Did you test it?

That example project will display amount of points in the top left corner from very start to very end of that project.

You can do everyt hing you mentioned in your post and more. You just need to learn, how to make a screen. Start with the link m_from_space provided.
< < insert Rick Cook quote here > >

JimPanse
Newbie
Posts: 13
Joined: Wed Apr 28, 2021 1:36 pm
Contact:

Re: Displaying Earned Points?

#5 Post by JimPanse »

Hey there Ocelot,

you are absolutely right. I just tested it and it does. Sorry, my bad :(

I had to fiddle around a little to get the hang of it (also with positions and stuff) but now I think it's working as it should be. Here is what I did now:

Code: Select all

default points = 0

screen MegP:
      image "megan_small.png"

      vbox:
          pos(0.005, 35)
          text "[Megan]"

screen LilP:
      image "lily_small.png" pos(0.025, 1)

      vbox:
          pos(0.03, 35)
          text "[Lily]"

screen NinP:
      image "nina_small.png" pos(0.05, 1)

      vbox:
          pos(0.055, 35)
          text "[Nina]"
One more question though: is the default points = 0 in the beginning necessary, when I have already defined the points like this before?

Code: Select all

default Megan = 0
default Lily = 0
default Nina = 0

init:
    $ Megan = 0
    $ Lily = 0
    $ Nina = 0
Seems a little redundant. But thanks a lot again to you and m_from_space for pointing me in the right direction :D

rayminator
Miko-Class Veteran
Posts: 793
Joined: Fri Feb 09, 2018 12:05 am
Location: Canada
Contact:

Re: Displaying Earned Points?

#6 Post by rayminator »

it's best to use default instead of init if you insist of using init then I would suggest using class

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot]