Ren'py is an engine used primarily to create story based games or visual novels. It is extremely powerful and has been used to create many games on steam. It is written in python and therefore shares a very similar syntax with python. We will go over the basics of Python.
If you don't immediatly get the syntax of python, don't worry, It'll make sense once you start programming.
Before we get into python lets quickly go over what a programming language is. A programming language, atleast in terms of games, is a set of instructions that the computer will follow to create interactivity between the user and the computer. Everything that is on a computer will eventually boil down to a program.
A variable is a form of storage for something like a number or letters. It is used to store information that will be used during the program. For example variables can store how many kids are in a class, the name of a specific kid in the class, and if a kid is there or not. There are many types of variables but we will be going over three types of variables we will be using in renpy. The first one is the boolean
The boolean is a variable type that stores a value of true or false. This can be used for storing if a light switch is on(true) or off(false). You could also use it to determine if a certain condition has been met in a game such as if a Player said something(true) or they didn't (false).
The next variable type we will be using is the integer. An integer is a any whole number. An integer can be used for storing things like how many cars are in a parking lot, keeping track of a certain numerical stat a person has, and many other things.
The last basic variable we will be using is the string. A string can store words and letters. A string can be used for things like names.
Python is not like other programming languages. Most other programming languages will use brackets and semi-colons to show the end of the line of code or what statements belong within certain control statements and class objects. Python is different, It uses the white space after the lines such as indents, new lines, and a few other things.
Click on the renpy application
Click Create New Project
Feel free to name your project whatever you wanted for your own project. Once we are done with the tutorial you can delete all of the text and replace it with yours.
Type in "Ice Cream Project"
The next menu will prompt you to select a language for the template for your game. Renpy has a pre built menu system. It will take care of everything from menu's, to dialouge set up, and even saving and loading.
Make sure english is selected, then click Continue
Now you will have the option to select themes. You can change the theme, which will change the U.I. design. You can also change the color Schemes to change the colors. Play around with it until you find a combination that you like.
Click Continue
Once you have done that you will be taken back to the projects menu of Ren'Py. The project that you just created should appear under the project tabs.
Click on the Ice Cream Project you have created
Now that you are sure your project is selected we can start to edit the script for the game, which is the code that will determine what happens in the game. Before we can start editing the code we need to adjust the options.rpy file first.
Click on options.rpy
A menu will pop up asking you what editor you want to use. For ease of use for everyone at the camp we will all use the same editor.
Click the text Editra
This will open up the text editor that is included in renpy. There will be a bunch of text inside. We only need to change a couple of lines. We will be changing the resolution of the screen, so that we can have a higher resolution.
change the number of config.screen_width = from 800 to 1920 and change config.screen_height = from 600 to 1080
Click script.rpy
The text editor should now start up again and should have some text already inside of it. This is some example code and we can get rid of it.
Delete the following lines:
define e = Character('Eileen', color="#c8ffc8")
also delete:e "You've created a new Ren'Py game."
e "Once you add a story, pictures, and music, you can release it to the world!"
Now that we have everything for the project set up we can now start writing our own script
Before we can get to the actual scripting of the game we need to define some variables before the run time of the game. This is called initialization.
We now want to create declare our Player character before we use it anywhere in the game.
Type in define Elena = Character()
The define can be thought of as a sign to renpy that we are defining a variable of the type character. This is not one of the variable types we went over earlier since this is a variable specific to Ren'Py. The Character variable is a variable defined inside of Ren'Py To deal with Character realted tasks such as speaking and other things.
The Elena part of the statement is the name of the variable and the name we will be using to reference it later on in the script.
Character is a type of variable that holds the character name and a whole bunch of other related things.
The "()" after the Character keyword are where we will put the neccesary variables to be transfered to the character class. We will want to put in a string variable for the name and then a hexadecimal value for the color of their name that will be dispalyed when they are speaking on the screen.
Click in the middle of the two brackets and type 'Elena' , the ' ' are required.
You now need to add a coma to let renpy know that we are seperating the name from the next value we are puting in.
Type a , after 'Elena'
Now we will add in the color of the text that will appear when elena is talking. To to do we will need a hexadecimal value. A hexadecimal value is just another for representing a value. But we do not need to worry about how it works but just how to get one that corresponds to the color we want.
For Elena we will simply just use a pre selected color value, in a couple steps you can choose your own color.
Type color = "#0000FF", the "" are required.
The hexadecimal value corresponds to blue. In a couple steps we will go through how to get this value.
define Elena = Character('Elena', color ="#0000FF")
Now that we have Elena fully defined we can now define the Player, this will be a little different from how we declared Elena since we will have a variable that will allow the Player to choose their name.
Type in the bolded text:
# Declare characters used by this game.
define Elena = Character('Elena', color ="#0000FF")
define Player = Character()
Now instead of simply putting a name inside of the parenthesis as we did with elena, we are going to put a sign to Ren'Py that we will be using a variable. To In order for renpy to know it will be a variable name, we need to put brackets around our variable name.
Type in the parenthesis, "[playerName]", the "" are required
Type in a , after "[playerName]"
Now that Ren'Py knows that the players name is a variable, we can add a color for their name text. We will be able to choose our ouwn custom color using a website that will provide us with a hexadecimal value for our color.
Open, this link. Or google hex color picker and select HTML Color Picker-W3Schools
A new tab should have appeared, that has a color picker on it.
Pick a color that you want from the color picker, and then adjust if it is Lighter/Darker
This is what the color picker looks like,
Copy the value that starts with an #, or remember the value
This is where the hex color value is located.
To copy the value click before the hash and Drag the mouse to the right until the whole value is highligted and press Ctrl+C on the keyboard. The hexadecimal value should now be copied.
The hexadecimal value starts with a # and is 6 characters in length in this case.
Now go back to your Ren'Py project, now we will add the hexadecimal color value. But before you type in the value you will need to let Ren'Py know you are putting in a color.
After the comma, type in color =
Now to add in the value.
Paste the hexdecimal value after color = , or type in the value.
to paste a value, put the cursor where you want to put the value and press Ctrl + P to paste.
Now the two lines you have created should look like this.
# Declare characters used by this game.
define Elena = Character('Elena', color ="#0000FF")
define Player = Character("[playerName]", color = "#38B09D")
The hexadecimal color does not need to be the same.
Before we start loading images into the actual Ren'Py script, lets put them into the games file directory first.
In the file explorer, navigate to your tumbdrive then into the folder called "Ren'Py_Images"
Hold shift and click all of the images. Then press ctrl + c to copy the images.
In file explorer navigate to where you saved your Ren'Py project/IceCreamProject/game/images
This is assuming you named your project "IceCreamProject"
Press ctrl + p
You have just moved all the images we need into Ren'Py's image directory, we should now be able to call them within the game. This is the place you will put all of your images for your own project.
A very important practice for programming is commenting in the program file you are editing. A comment will explain what is going on in the code below, since it is not always immediatly obvious what it does. It also helps with readability for yourself and and other working on a program with you. You delcared the Player and the other character before in a premade comment.
In python, and all the other programming langauges, you will need to specify which line you are commenting out. In python you will use the #
before any line to denote that it will be used for human reading and therfore should not be proccesed by the computer.We will create a comment above where we have declared the two characters
type in the bolded text:
- define Player = Character("[playerName]", color = "#38B09D")
-
- #Background declaration
We now need to delcare a background image so we can use it later on.
Type in:
- #Background declaration - image bg House = "House.jpg"
The image part of the statement will let Ren'Py know that we are defining an image variable.
The bg Lets Ren'Py know that this is part of the background(shortened bg here) group. Whenever an image variable is called with the letters bg before it, Ren'Py will automatically replace the most recently called image variable with bg. This is so you don't have to remove the image manually and then put up the next one.
The House part of the decleration is the variable name.
Finally the "House.jpg" is the name of the image that we will be calling from the image directory. This image is part of the images you copy and pasted into the files earlier.
Now we need to define the images for the characters in their various emotional states. This will be the same idea as declaring the background image before.
The Player image should be from what we rendered out from Photoshop earlier. If you do not have a Player image, change PlayerNormal.png to PlayerNormal_BackUp.png and PlayerHappy.png to PlayerHappy_BackUp.png
Type in:
- image bg House = "House.jpg"
-
- #Characters images
- image Player Normal = "PlayerNormal.png"
- image Player Happy = "PlayerHappy.png"
The character declerations work in the same way as the background delcerations with Player corresponding to bg. When you have Player Normal on the screen and then you call Player Happy, Ren'Py will automatically replace the two images since they are part of the smae group. The Normal or Happy are the names of the actual images, you will need to put Player infront when calling them.
Now we will import Elenas images. But one of them has a problem, they are not scaled correctly. We will fix that.
Type in:
- image Player Happy = "PlayerHappy.png"
- image Elena Normal = "ElenaNormal.png"
- image Elena Happy = "ElenaHappy.png"
Now we need to add a place for us to declare variables in our game.
Pythons syntax will now come into play. The indents, and spaces that will be shown inside of these code snippets are very important and if it is not done correctly the code will not work.
Type in the following, Make sure to press enter after "python:" if there is no indent autoamatically, press tab
- image Elena Happy = "ElenaHappy.png"
-
- #variable decleration
- init python:
- boolWantIceCream = False
The indent should have occured automatically as ":" will let Ren'Py know that the next line should automatically be indented.
The reason for the indent is to let Ren'Py know that they next line will be relating to the line before it without the indent Ren'Py will try to parse the next line as something completely seperate, and not related to it. An easy way to think about it is like a drawer, when you indent the code it is like putting the next lines of code into the drawer So that it is seperate from the rest of the code. The code within indents will be run before returning to the rest of the program
You set the boolWantIceCream to false. This will be important in a few lines
It is important that with booleans True and False are always capatalized in Ren'Py. It will cause an error if they are not capatalized.
Now we can finally get into scripting the game. We need to have add a background to the scene first. We will start right after the label start: line.
The label start: line is what Ren'Py will look for to get the game started, so it is required. A label is a way to jump to a certain part of the game. Everything we will be typing will need to be indented atelast once, since this is all contained in the "label start:" Think of the label as a scene and its name, and everyting that will happen inside of it needs to be indented.
Type in:
- # The game starts here.
- label start:
- scene bg House
scene is the command that will set the background or the scene of the game.
Now to add narrator dialouge. You do not need to put anything before it since nobody is speaking it inside of the game. Ren'Py will simply put it on the screen without any attribution to a character and will be considered a narrator
Type in:
- label start:
- scene bg House
- "This about two people getting ice cream."
Now we can test the game, to make sure that everything is working. Testing in programming is especially important because it is very easy to make mistakes and if you are not constantly checking to make sure everything is okay you may have alot of errors that will prevent you from compiling the game. Fixing a whole bunch of issues at once will drastically slow down development, so it is a better idea to fix them when there isn't so much to shift through.
Before testing, you need to save your script so that Ren'Py will be able to use it
Click File->Save, or Press CTRL + S
Click Launch Project
Ren'Py will already has a bunch of features preprogrammed for you, such as starting the game, loading the game, and some very basic settings.
Click Start Game
The game should now start, and image of inside a house should appear and the narrators text should be at the bottom.
Some common issues may be that you did not indent the code properly. You can look below to see the code of what we have so far. You may have also incorrectly spelled an image. Check the spellings of the images to see if that is the issue.
this is the code up to now:
Now we can have the game prompt the Player for their name.
Now that we are working inside of the label start: every line that we write will automatically have atleast one indent until we get to defining another label.
Type in:
- "This about two people getting ice cream."
- python:
- playerName = renpy.input("What is your name?")
Just like earlier when we used the init python we are letting Ren'Py know that we are going to be using a python to do something. We do not need init because we are not initializing values but just modifying one. In this case we are using python to assign what the Player typed in to the playerName variable.
We are now going to show one of our characters to the Player since they will soon be talking.
Type in:
- python:
- playerName = renpy.input("What is your name?")
- show Elena Normal at left
Show will simply show the character specified.
at left is a specification to where the image will appear, since we put at left the image will appear at the left. You can also have different positions such as center, right, or a custom made location.
Now we can have Elena speak.
Type in,
- show Elena Normal at left
- Elena "Hey, [playerName], I'm Elena"
We put Elena to specify that we want Elena to be the one to be speaking. In-game the dialouge menu will indicate that Elena is the one speaking.
having [playerName] will automatically print the value within the variable. So whatever the Player put in as thier name is what will appear. If you want to print variabls like bools, ints, or strings put the variable name within []. Brackets are what let Ren'Py know to print variables.
Now we are going to have Elena change to a smile and ask the Player a question.
Type in:
- Elena "Hey, [playerName], I'm Elena"
- show Elena Happy
- Elena "It's snack time, we're getting ice cream, do you like ice cream [playerName]?"
With our the show we just typed in Elena will automatically be put on the screen to the left. This is because Ren'Py knows that the Elena image is at the left and automatically replace the normal with the happy image. It knows to do it because of the Elena keyword before the emotion description.
Now that Elena has asked the question to the Player. We can now create a menu for what the Player can say.
Type in:
- Elena "It's snack time, we're getting ice cream, do you like ice cream [playerName]?"
- menu:
What we did there was declare a menu. This will create a prompt for the Player to select from options we are about to add.
Type in:
- menu:
- "Yes.":
-
- "No.":
-
- "I don't care."
The options are all indented once more from the menu. This is because the menu is its own section and each option a sub section, so they are indented. Press tab to indent.
Now that we have create options for the Player to choose yes, no, and I don't care. Now let's add what each one will do to the game.
When you are typing there will be a line begging with a $. This is letting Ren'Py know that we are using a python statement. This will have the same effect as what we did earlier with writing Python: then on the next indented line writing what we wanted it to do.
Type in:
- "Yes":
- $ boolWantIceCream = True
- show Player Happy at right
- Player "Yes, I love ice cream"
The line $ boolWantIceCream = True is a python statement with the $ signaling Ren'Py this is in python. We are setting the boolean that the Player wanted ice cream to true so that we can use it later on.
The next two lines will show the Player for the first time at the right and then have dialouge from him/her.
Now lets add what happens in the game if the Player chooses no.
Type in:
- "No":
- $ boolWantIceCream = False
- show Player Normal at right
- Player " I hate ice cream"
This baisically does the same thing as if the Player said yes but instead of setting the boolWantIceCream to true we are setting it to false. Also the Player says they hate ice cream.
Now lets add what will happen if the Player selects "I don't care"
Type in:
- show Player Normal at right
- Player " I hate ice cream"
- "I don't care":
- $ boolWantIceCream = False
- show Player Normal at right
- Player " I don't care"
We left the boolean as false becasue the Player did not say they wanted it, and it also works out for what we plan to use the boolen for.
In preperation for the next section in the game lets hide the Player and elena
Type in
- show Player Normal at right
- Player "I dont care"
- hide Player
- hide Elena
The hide commands return to the main line of the "label start:" module and are not a part of the menu they are commands that will happen regardless of what happens in the menu. So therefore the commands have only one indent(press TAB) and will execute as soon as menu is complete.
The hide command will hide the image specified. We do not need to specify where they need to be hidden since it will just hide whatever is linked to the character you chose to hide.
Now that we have this part finished.
Launch your project
If you are having issues, make sure everything is spelled right and all of the indents are correct. There were alot of indents and at some times within the Player options there were up tothreeindents
This is what the code should look like from the label start:
Now that we have our first encounter done, we will now create the ice cream parlor scene.
Type in, under the hide statemnts:
- hide Player
- hide Elena
- jump iceCreamParlor
A jump statement will jump to the label specified. since we do not have an iceCreamParlor label lets create one. Remember iceCreamParlor can be thought of as a scene.
Type in,
- hide Elena
- jump iceCreamParlor
- label iceCreamParlor:
You do not need to indent this new line. Since this is a scene within the game it does not need to be indented.
Now that we are going to be adding a new character into the scene, the ice cream guy, and a new background we need to defiene them at the top of the file.
The image to the ice cream parlor is to small for the screen so we will make it larger.
Type in the Background Decleration section:
- #Background declaration
- image bg House = "House.jpg"
- image bg Parlor = im.FactorScale("Ice_Cream_Parlor.jpg",2,2)
Putting im.FactorScale() instead of just delcaring the variable will allow us to adjust the size of the image. We first need to put in the name of the image we want and then a comma. After that we will put in the x, or horizontal scale amount. An image with it's original proportions has a scale factor of one, think of it as multiplication. In this case we want the X-scale to Be twice as much as it used to be so we put in 2(1*2 = 2). We will then put in another comma and then type in the Y-scale factor which will be the same, 2, so that the image will not look out of proportion. You can put in any values you want like for the scale like 0.5(to make it half as big).
Now we need to declare the IceCreamGuy Character
Type in the Character Decleration section:
- # Declare characters used by this game.
- define Elena = Character('Elena', color ="#0000FF")
- define Player = Character("[playerName]", color = "#38B09D")
- define IceCreamGuy = Character('IceCream Guy', color = "#ff66ff")
Now we need to define his normal image
type in the characters images section:
- image Elena Happy = "ElenaHappy.png"
- image Player Normal = "PlayerNormal.png"
- image Player Happy = "PlayerHappy.png"
- image IceCreamGuy Normal = "IceCreamMan.png"
Now we can go back to scripting the game now that we have everything we need for the scene declared
Now we want to change the background scene, and while we are at it lets add a transition.
Type in:
- label iceCreamParlor:
- scene bg parlor
- with fade
The with fade is a transition between one image to another. You must put it right after the image you want the transition to happen on. That is why it is the line right after changed the scene. There are many other transitions you can use, follow this link to see what other transitions there are. Remember to put with first, that is the part that will let Ren'py know that it is a transition.
Now lets show the IceCreamGuy, but we will specify where he will be on the screen instead of just saying at left.
Type in:
- scene bg Parlor
- with fade
-
- show IceCreamGuy Normal at Position(xpos = 0.5, ypos = 0.8)
The xpos will correspond to the x, or horizontal, position of the image inside the editor. While the ypos will correspond with y, or vertical, position of the image. Values between 0 and 0.99 will equate to screen positoins, like a percentage. 0.5 will correspond to half way through the window. Anything over 0.99 will start being specific pixles on the screen, and will take along time to get right, it is reccomended to go with the 0-0.99 values. Also the origin spot of the image is at the bottom left corner, so location we specify, the bottom left corner of the image will go there.
Now lets add a transition for him to get on the screen and have some dialouge for him.
Type in:
- with fade
-
- show IceCreamGuy Normal at Position(xpos = 0.5, ypos = 0.7)
- with moveinbottom
- IceCreamGuy "We have vanilla and chocolate Ice Cream, what can I get you two?"
moveinbottom will move the character in from the bottom to thier position.
Now Elena will answer what she wants.
Type in:
- IceCreamGuy "We have vanilla and chocolate Ice Cream, what can I get you two?"
-
- show Elena Happy at left
- with dissolve
- Elena "I'll have vanilla Ice Cream."
- hide Elena
The dissolve transition is like the fade transitions like we used for the background, but for characters.
Now lets have the Player be able to answer. In this scenario the Player will be able to gain like points for elena. This is a gameplay mechanic used in alot of games to help the Player begin a relationship with the characters in the game and adds meaning to what the Player does.
We need to add the like variable in the game first before we are able to use it.
Type in the variable decleration section:
- image IceCreamGuy Normal = "IceCreamMan.jpg"
- #variable decleration
- init python:
- boolWantIceCream = False
- intElenaLike = 0
Now that the variable is declared we can write the script for the menu. We will declare the menu, and then add what happens if the Player answeres vanilla ice cream.
We also want to give this menu a name since we might be jumping back to it later in the game.
Type in:
- Elena "I'll have vanilla Ice Cream."
- hide Elena
-
- menu IceCreamQuestion:
- IceCreamGuy "what do you want?"
- "Vanilla":
- show Player Happy at right
- Player "I'll have the vanilla Ice Cream"
- show Elena Happy at left
- Elena "Good Choice"
- hide Player
- $ intElenaLike = intElenaLike + 1
What this section does is it will create the menu and the vanilla options for the Player to choose. If the Player chooses vanilla It will show the Player, have them say they want vanilla then Elena will pop up and say "good choice". Then it will add one like point to Elenas value, which will open up opporotunities later on.
The reason that we had the question come afer the menu is because we want it to stay up while the question is being asked incase the Player forgets what was asked of them.
The line $ intElenaLike = intElenaLike + 1 is a python statement where we add one number to the intElenaLike variable. You add one to the intElenaLike value and then update and assign that value to intElenaLike, therefore adding 1 to it.
Now lets add what happens if the Player chooses chocolate, which isn't much.
Type in:
- $ intElenaLike = intElenaLike + 1
-
- "Chocolate":
- show Player Happy at right
- Player "I'll Have the chocolate Ice Cream"
All we do is show the Player and have them say he wants chocolate ice cream.
Now Lets have another option, one that will only appear if the Player did not say "yes" to the ice cream. To do this we are going to need to use an if-then-statement. An example of an if then statement is if the Player has a key card then they can get acces to a door.
Also we will jump to a special section if the Player chooses this option.
Type in:
- "Chocolate":
- show Player Happy at right
- Player "I'll Have the chocolate Ice Cream"
-
- "I Don't want ice cream" if boolWantIceCream == False:
- jump ElenaQuestion
We will create the label for ElenaQuestion later.
The option will only appear if boolWantIceCream is False, or the Player did not say "Yes to ice cream"
There are two equal signs as opposed to one this is because we are checking for if the boolean is false not setting it to false.
Now lets finish up this little scene, by hiding the Player and IceCreamGuy then jumping to the next scene and then create ElenaQuestion.
Type in :
- "Chocolate":
- show Player Happy at right
- Player "I'll Have the chocolate Ice Cream"
-
- "I Don't want ice cream" if boolWantIceCream == False:
- jump ElenaQuestion
- hide Player
- hide IceCreamGuy
- jump sitDown
Go ahead and test your game out. If something does not work, check the indentation and spelling. Here is what the Ice Cream part should look like now.
Now lets add the option that appears if the Player selects that they don't want ice cream. We will start with what happens if the Player still selects to not get any ice cream. intElenaLike will loose one point if they choose not to have it, as she really wants the Player to get some ice cream.
Type in:
- hide Player
- jump sitDown
-
- label ElenaQuestion:
- show Elena Happy at left
-
- menu:
- Elena "Are you sure you don't wan't anything, I'm buying"
- "Don't want any":
- show Player Normal at right
- Player "I really don't want Ice cream right now"
- $intElenaLike = intElenaLike - 1
We subtracted one from Elenas like instead of adding one to it. We also had the Player say that they did not want
Now will handle what happens if the Player chooses to get ice cream after Elenas offer. We will have a way to loop back around to the menu that the Player was asked if they want ice cream using a jump. This will allow the Player to choose the ice cream that they want and then move on with the story.
Type in:
- Player "I really don't want ice cream right now"
- $intElenaLike = intElenaLike - 1
-
- "I'll have some":
- show Player Normal at right
- Player "Actually, I've changed my mind, i'll have some"
- $ intElenaLike = intElenaLike + 1
- hide Player
- hide Elena
- $ boolWantIceCream = True
- jump IceCreamQuestion
The last line will send the games control back to the menu where the IceCreamGuy is asking what flavor the Player wants. The option for I don't want ice cream will dissapear because we set it to True before we gave control back to the ohter menu. We will not be able to get back to this section.
Now lets code the next step in the game. This is where the game will branch(there isn't much more, don't worry). We will have Elena ask the Player if they want to go back to the house or go downtown.
Type in
- $ boolWantIceCream = True
- jump IceCreamQuestion
-
- label sitDown:
-
- show Elena Happy at left
- Elena "Now do you want to go my home and play games or go downtown? I would prefer going home."
-
- menu:
- "Home":
- show Player Normal at right
- Player "Lets go Home."
- $ intElenaLike = intElenaLike + 1
- jump home
- "Downtown":
- Player "Lets go downtown."
- jump downtown
Notice how at the end of each options instructions they jump to different areas. Also if you choose to play games another like point will be added to Elena.
Now here comes when we will use the intElenaLike points that we have been adding during the game. We will create a new label(think of it as a scene) where depending on how much Elena likes the Player she will say something different.
First we will set up the scene up to the point we will procces intElenaLike
Type in:
- "downtown":
- Player "Lets go downtown."
- jump downtown
-
- label home:
- scene bg House
- show Elena Normal at left
We will need to use an if and else statement, since there are a few possible outcomes that can happen.
We will start of with the first if statement, you must always start an if/else statement with the if. You cannot start it with an else.
Type in:
- scene bg House
- show Elena Normal at left
- if intElenaLike == 0:
- Elena "You havent been as fun as usual [playerName]"
This if statement will check if intElenaLike is equal to zero. If it is then it will execute the next indented line which is Elena telling the Player she is not very happy with them.
Now lets move on to the other cases. These other cases are called else if's, which are abbrevidated elif in python, this is where you specify another exact condition to have thenext indented line executed.
Type in:
- if intElenaLike == 0:
- Elena "You havent been as fun as usual [playerName]"
- elif intElenaLike == 1:
- Elena "I think you're cool [playerName]"
- elif intElenaLike == 2:
- Elena "You're the coolest person in this world [playerName]"
These two elifs will check if Elenas like is one or two. If it is one it will have elena say a less enthusiastic statement than if her like integer is at two.
Now we will add an else statement, just incase something goes wrong the game narrator will let us know. you will want to use the else statement for any other conditions that you have not explicitly stated with the if or elif.
Type in:
- elif intElenaLike == 2:
- Elena "You're the coolest person in this world [playerName]"
- else:
- "Something wen't wrong"
Now that we have all the conditions covered with the intElenaLike we can add the last few parts to the game.
Now Lets have Elena acknowledge that the Player and them are home and then jump to the endgame. We have to specify to jump to the end of the game because Ren'Py will try to do the next label and we would end up doing the downtown part also when all the code is there. So to avoid wrong labels being played, always be sure to have a jump statement out over every possible outcome of a label.
Type in:
- else:
- "Something wen't wrong"
-
- Elena "Now that were home lets go play some games"
- jump endGame
Now that the home scene/label is finished lets do the downtown one. We need to load in the downtown image.
Type in under the background decleration space,
- #Background declaration
- image bg House = "House.jpg"
- image bg parlor = im.FactorScale("Ice_Cream.jpg",4,4)
- image bg Downtown = "Downtown.jpg"
scroll down to where we were working on the home scene/label
Type in,
- Elena "Now that were home lets go play some games"
- jump endGame
-
- label Downtown:
- scene bg Downtown
- Elena"I love downtown, Lets go sit on that bench!"
- jump endGame
This will simply put the backround image on and let Elena will acknowledge that they are downtown.
now lets add the final part of the game. This label will have the statement return this is the sign to renpy to end the game and go back to the main menu.
Type in
- Elena"I love downtown, Lets go sit on that bench!"
- jump endGame
- label endGame:
- "Game is over"
- return
Now we are finished test you game again and make sure that everything is working. If it is not check the spelling and indents of the game. Here is the full final code.