I have a lot of things to say about how you are writing your code. Basically, you need to use functions. Let's ask about the question, "how would you go about finding the current love point count and maximum in order to determine the average as the game was played?"
Following on morrie,
You need to declare a max_love and a current_love variable--which should be done using default. And everytime a situation comes up where points could be gained you should add the max to the max_love and add whatever points they earned to current_love.
This does that:
Code: Select all
default max_love = 0
default current_love = 0
default average_love = 0
label start:
scene black
"You are walking down the street."
"You see a rose."
menu:
"What do you do?"
"Pick up the rose":
$current_love+= 10
"Ignore the rose":
$current_love+= 5
"Stomp on the rose":
$current_love+= 0
$max_love +=10
"A friend tells you it is Valentines day."
menu:
"How do you respond?"
"Explain how much you love Valentine's Day":
$current_love+= 10
"Thinks that's cool, but it is no big deal.":
$current_love+= 5
"Yell about how terrible Valentine's Day is":
$current_love+= 0
$max_love +=10
So after the first menu, the max number of points you could have is 10; after the second menu, the max number of points you could have is 20.
Let's get to the second question I have. I don't really know what you want to do with calculating your average...especially if you want to do a check where current_love being over average means a passed check.
Let's look at every possibility for what you've laid out in your initial post:
After Menu 1:
a) max_love (10)/current_love (10) = 1. Is current love greater than 1? Yes. Check Passed.
b) max_love (10)/current_love (5) = 2. Is current love greater than 2? Yes. Check Passed.
c) max_love (10)/current_love (0) = ERROR.
After Menu 2:
a1) max_love (20)/current_love (20) = 1. Is current love greater than 1? Yes. Check Passed.
a2) max_love (20)/current_love (15) = 1.3 Is current love greater than 1.3? Yes. Check Passed.
a3) max_love (20)/current_love (10) = 2. Is current love greater than 2? Yes. Check Passed.
b1) max_love (20)/current_love (15) = 1.3 Is current love greater than 1.3? Yes. Check Passed.
b2) max_love (20)/current_love (10) = 2. Is current love greater than 2? Yes. Check Passed.
b3) max_love (20)/current_love (5) = 4. Is current love greater than 4? Yes. Check Passed.
c1) max_love (20)/current_love (10) = 2. Is current love greater than 2? Yes. Check Passed.
c2) max_love (20)/current_love (5) = 4. Is current love greater than 4? Yes. Check Passed.
c3) max_love (20)/current_love (0) = ERROR.
So you are either always going to pass the check or get an error. So what you are doing isn't going to be useful. Also, that isn't how you calculate an average.
How do you calculate the average? You add all the numbers together and then divide by how many numbers there are.
The average of 10+5+0 (the number of point choices for the first menu) is: 10+5+0 = 15/3 = 5.
The average of 10+5+0+10+5+0 (the number of choices for both menus) is: 10+5+0+10+5+0 = 30/6 = 5
If you went by average...then it would be useful after the first menu...but not that useful after the second menu and later menus...because with each subsequent set of choices, you will have a better chance of beating it.
So, if you really want to do this thing you are thinking of, I think you should go with percentages. Decide what is a passing percentage and check to see if your person hast that at any given time.
So how to calculate percentages? x = current_love * 100 / max_love
After Menu 1:
a) current_love (10) * 100 / max_love (10) = 100%
b) current_love (5) * 100 / max_love (10) = 50%
c) current_love (0) * 100 / max_love (10) = 0%
After Menu 2:
a1) current_love (20) * 100 / max_love (20) = 100%.
a2) current_love (15) * 100 / max_love (20) = 75%.
a3) current_love (10) * 100 / max_love (20) = 50%.
b1) current_love (15) * 100 / max_love (20) = 75%.
b2) current_love (10) * 100 / max_love (20) = 50%.
b3) current_love (5) * 100 / max_love (20) = 25%.
c1) current_love (10) * 100 / max_love (20) = 50%.
c2) current_love (5) * 100 / max_love (20) = 25%.
c3) current_love (0) * 100 / max_love (20) = 0%.
So if you go with percentages, you have to decide what a passing percentage is. Let's say that you decide 70% is passing. So you make a percentage and then check to see if it is greater than 70%.
All of this can be done with a function, not any of this strange label thing you've got going on.
Check out this code that is just an example of something you could do on this concept using a function and the renpy.notify function:
Code: Select all
init -1 python:
def love_check():
global max_love
global current_love
percent = (current_love * 100)/max_love
if percent >= 70:
renpy.notify("Love Check Passed")
return True
else:
renpy.notify("Love Check Failed")
return False
# The game starts here.
default max_love = 0
default current_love = 0
label start:
scene black
"You are walking down the street."
"You see a rose."
menu:
"What do you do?"
"Pick up the rose":
$current_love+= 10
"Ignore the rose":
$current_love+= 5
"Stomp on the rose":
$current_love+= 0
$max_love +=10
$love_check()
"A friend tells you it is Valentines day."
menu:
"How do you respond?"
"Explain how much you love Valentine's Day":
$current_love+= 10
"Thinks that's cool, but it is no big deal.":
$current_love+= 5
"Yell about how terrible Valentine's Day is":
$current_love+= 0
$max_love +=10
$love_check()
"Now let's say you want to do something in terms of using that True/False that is returned from your function."
$result = love_check()
"You see an attractive sort of person walking down the street."
menu:
"What do you do?"
"Ignore the person.":
jump alone
"Say Hello.":
jump friendship
"Flirt" if result:
jump romance
label alone:
"You walk past the attractive sort of person and think...whatever."
"You go home and hang out with your freinds. You are happy and have no drama."
"The end."
label friendship:
"The attractive person says 'hi' back to you. They say their name is Jess and that they are new in town."
menu:
"What do you say?"
"You flirt a bit and say you could give them a tour of the city":
$current_love += 7
"You keep it friendly and offer to invite them to to your game night with freinds.":
$current_love += 3
$max_love += 10
$love_check()
"The story continues on."
jump test_end
label romance:
"The attractive person blushes and smiles. They say their name is Jess and that they are new in town."
menu:
"What do you say?"
"You flirt a bit and say you could give them a tour of the city":
$current_love += 10
"You keep it friendly and offer to invite them to to your game night with freinds.":
$current_love += 5
$max_love += 10
$love_check()
"The story continues on."
jump test_end
label test_end:
"Test over"
return
If you have never taken the Basic Python course at codeacademy.com, you really should try that course.