Renpy Tutorial【#10】Let's write a visual novel together【Part 1】

In this article I will introduce the various basic functions of Renpy, which is basically something you can use to make a visual novel. Don't talk nonsense, just start right away

    1. Step (Prepare beforehand)

    Download Renpy it is the most important thing to prepare without Renpy you cant start using Renpy 

    Click Download Latest Version to start downloading 
    After having Renpy, you still need an editor to edit the code 
    Renpy recommends we to use Atom, so I also use Atom to write code
    If you dont have Atom you can Click here to download Atom

    Just click Download 

    After that open your renpy.exe and create a new project

    If you want to change Language - For example to Chinese you can go to
    - Preference - Language - find Traditional Chinese (where Taiwan and HongKong use) or Simplified Chinese (where China use)

    After you created a new project, you can find script.rpy from the row on the right
    After clicking down, Atom will automatically open (If you have downloaded Atom, you can also use other editors)
     After you click in, you will see this screen (I changed the theme so it is a different color, generally it should be black (( the screen



    2. Step (Define your Characters )

    I believe you must have a plot, right(?
    So the second step is to define characters that will appear in the plot into the script
    像這樣
    After define is the code name of the character

    After Character is the name of the character - If you for example type Nin then Ning Ning will automatically appear (because I wrote Ning Ning between " " )

    color is the color that display in the game when showing this character

    Only 2 characters will appear in this project so I define 2 characters now 
    define m = Character('Mika', color="#000000")
    define l = Character('Lia', color="#9e3bad")

    After defining the Character , give them an image
    First put the pictures you want to use into a folder in the project (I will put them in images/character) After the pictures are put in, the pictures can be defined in the script (script.rpy)

    Like this:
    - image lia = "images/character/lia.png"
    - image mika = "images/character/mika.png"

    After that, just type lia or mika and the picture you defined will be displayed.
    like this:
    The screen will be displayed like this:

    At is followed by the position of the character (position of the picture) I used topleft because my picture is too big, so if  I don’t use top... then the face can’t be seen in the mirror ((Actually, it’s just that I am lazy hehe, you can also crop the image to solve this problem

    3. Step ( Scene Background)

    I will give my background a folder (in images) 
    I only put a background image for this project
    - park.jpg
    Because it is a picture in images/bg, its path is "images/bg/park.jpg"
    So my code looks like this: 
    image park = "images/bg/park.jpg" 

    Now renpy can use pictures without definition, but I will still define first ((Afterwards, it will be more convenient if you want to change the picture 

    The following is the code used directly without pre-defined pictures:
    Scene that display:
    So if your project is not very big/the pictures are few or you are sure that you will not make changes to the pictures, there is actually no need to define the pictures in advance.

    4. Step (Add Dialogue)

    There are characters, and after there are pictures, now there should have some dialogues. 
    So here is the dialogue I want to present - Preview here
    How to make such a dialogue- read the step below! (( it starts with 4-1

    4-1. Let Player enter their own name

    First, we need a screen/label to ask the player what name they want to use
    Example:
    label name:
    $ pn = renpy.input("plz enter your name~", length=20)

    $ player_name = pn.strip()
    if pn =="":
        "Give yourself a wonderful name"
        jump name


    label XX:  -  The text following label can be replaced at will, but please note that it must be the same as jump XX.
    $ XX = renpy.input("XXX", length=XX)
    $ XX - The words after $ can be changed at will, and the words are used as the character code (if you write main and type main before the sentence, it will automatically be replaced by the name entered by the player.
    "plz enter your name~"- You can change the text in "", if you write "Please enter your name here", then it will display Please enter your name here instead of plz enter your name~


     length=20)- You can change the following numbers or delete this line directly. This is used to tell renpy that players can enter a few words at most. If it is set to 30, the player cannot input more than 30 characters/letters as the name. / If you delete this line There is no upper limit for the characters/letters that the player can enter

    if pn =="": -If the player doesn’t type anything, just continue/press Enter
        "Give yourself a wonderful name" -Then this paragraph will be displayed jump name It is to make the screen jump back to the label name, so the text after the jump must be the same as the text of the label at the beginning

    This completes the name input part~ Clap Clap 

    4-2 Set up the Affection system

    You can use this code to set the affection system/other values:
    $Variable name = 0

    $- The word after this symbol can be changed at will, you can call him Affection, Intelligent... etc. Note! There is no space between $ and the name of the value((I have been getting Error because of the space for a long time before I found out QQ

    Example:
    $lia_aff = 0
    $mika_aff = 0
    The above 2 lines are the code I used in this project

    So from Step 4-1 to 4-2, you should have code that looks like this (the word behind # is an explanation of that line of code):

    #Character that will be display in the plot
    define m = Character('Mika', color="#000000") # white hair girl
    define l = Character('Lia', color="#9e3bad") #black hair girl
    define pn = Character("[player_name]", color="#88b2c2) #main character


    label start: 
    $lia_aff = 0 # Lia's affection to the player
    $mika_aff = 0 # Mika's affection to the player

    scene park #Background image called park

    label name:  # new label called name 
    $ pn = renpy.input(" plz enter your name~", length=10) 

    $ player_name = pn.strip()
    if pn =="":
        "Give yourself a wonderful name"
        jump name

    show lia at topleft #let lia be showed in the screen (( left side
    show mika at topright # let mika be showed in the screen (( right side


    m "hello, [player_name]!"  #Say hello and let mika to say the player's name
    l "hello~ " #let lia say hello to the player
    m "Welcome Welcome~"
    l "To keep going you need to answer some question"
    m "Depends on your answer one of us will walk with you"
    pn "okay" #your answer

    4-3 Setting options (options that will affect the subsequent plot)

    According to the player's choice, it will affect the subsequent plot (This project will affect which character the player will go with afterwards) 
    Below is the code I used in this project

    m "Question 1 - Apple or Banana?"" #The first question raised by mika
    menu: #Let renpy know that the following code belongs to this option
        "apple": #Text the player can see (Choice1
            $ lia_aff += 1 #The impact of this option ((lia's favor plus 1
            jump q2 #If the player chooses Apple, it will skip to q2 (Question 2
        "banana":#Text the player can see (Choice 2
            $ mika_aff += 1 #The impact of this option ((mika's favor plus 1
            jump q2 #If the player chooses a banana it will also jump to q2 (question 2 - you can also choose to let the player jump to other labels

    For more stuff about Choice, you can click here

    So my code for all options in this project looks like this:
    m "Question 1 - Apple or Banana?"
    menu:
        "Apple":
            $ lia_aff += 1
            jump q2
        "Banana":
            $ mika_aff += 1
            jump q2

    label q2:
    m "Question 2 - Do you prefer black or white?"
    menu:
        "black":
            $ lia_aff += 1
            jump q3
        "white":
            $ mika_aff += 1
            jump q3
    label q3:
    m "Question 3 - Do you prefer movie or series?"
    menu:
        "movie":
            $ lia_aff += 1
            jump final
        "series":
            $ mika_aff += 1
            jump final

    --------------------------------------- Divider -----------------------------------------------------

    renpy will remember the player's choice and remember the impact of the choice . When the player chooses the option of the last question (question 3), it will jump to the label called final

    label final:
    if lia_aff >= mika_aff: #If lia's favor is greater than mika's favor
        jump lia #Then jump to a label called lia
    else: #else if the above if sentence does not right((lia's favor is less than mika's)
        jump mika  #Then jump to a label called mika

    The last thing is to create a label called mika and a label called lia.
    Here is the code/dialogue I used in this project:

    label lia:
        hide mika
        l "hello"
        return
    label mika:

    hide lia
    m "hello~"
    return


    So its's finish here~!
    -According to the picture that will be presented at the end of this tutorial - You can preview the video here
    Renpy Tutorial【#10】Let's write a visual novel together【Part 1】 Renpy Tutorial【#10】Let's write a visual novel together【Part 1】 Reviewed by NingNing on September 05, 2021 Rating: 5

    No comments:

    Leave A Message!

    Powered by Blogger.