So, I didn't particularly like the way your code was set up so I changed it a bit to make it more logical. The code I have works perfectly fine. I'll show you the code, then I'll explain what I did and why.
Code: Select all
define p = Character('Player', color="#c8ffc8")
define li = Character('Love Interest', color="#c8ffc8")
default pf = PointFucker()
init python:
class PointFucker(object):
def __init__(self):
self.dp = 0
def ch_dp(self, num):
self.dp += num
renpy.notify(str(num) + " {size=12}DÍDAC POINT!!{/size}")
screen points():
frame:
xalign 1.0
text "Total Points: [pf.dp]"
# The game starts here.
label start:
show screen points
"The Game Starts"
$ pf.ch_dp(3)
p "I think I love you!"
$ pf.ch_dp(3)
p "I really love you!"
$ pf.ch_dp(-3)
p "But you are a bad person..."
$ pf.ch_dp(-3)
p "And you are smelly..."
p "I don´t know, I´m a little crazy."
menu:
"But in the end..."
"I want to marry you":
$ pf.ch_dp(5)
"I never want to see you again you":
$ pf.ch_dp(-5)
p "What do you say?"
if pf.dp > 0:
li "I want to marry you, too!"
else:
li "Well...okay then...you are smelly, too."
"The end"
return
1) In your old code, you created an instance of PointFucker in the init python block. Whenever you create an instance of a class or a variable it should be done using "default" (the old proper way was to declare it at the start of start label, but default is the new way). When you do this, the instance/variable participates properly in saving/rollback.
2) In your old code you had two different functions to deal with points: one add, one subtract. But you don't need two functions, you can just have one and pass positive and negative numbers. Also, the functions were all by themselves, but because the functions really only deal with things involving PointFucker, it makes more sense for that function to belong to PointFucker rather than belonging to the program as a whole. So I made the function part of PointFucker.
3) You were worried about rollback...However, rollback shouldn't be a problem. I made a little screen and placed it in the top right corner of the screen that shows how many points you have at any given time. If you test rolling back and forward, you will see that rollback works.
4) I personally like having the notify right before the line of text that triggers it...but that is a personal preference. See if you like it my way.
5) I also added in a menu and an if/else--two things people often want in point games.
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe:
http://lemmasoft.renai.us/forums/viewto ... 51&t=21978