[PYTHON] I made a school festival introduction game using Ren’py

Introduction

I'm niya in charge of the 5th day of Kinki University Advent Calendar 2019. This time, I made a game with Ren'py that introduces the Ikoma Festival that is held every year at Kinki University, so I wish I could share the grammar I learned at that time.

The deliverables can be found at the following url. https://drive.google.com/drive/u/2/folders/1CVx17S12MDS8VLIsH4Q2Iu4C5U93vYC_

Also, github is below. https://github.com/niya1123/Short-Novel/tree/dev

The basics of making Ren'py games

This time, the DL of Ren'py itself and how to create a project are introduced in ** Previous article **, so look there. Please go.

How to write lines

To write a line, follow the steps below.

  1. Think about whether it is a character's dialogue, monologue, or narration.
  2. The former defines the character. The latter does not need to be defined.
  3. Write the definition in script.py.

Specifically, it is as follows.

script.rpy


#Character definition define character name= Character("Character name", color="Set color in hexadecimal")
#It is recommended to define the character name immediately after define with one character or a shortened name of the character name..
#color is the color of the character name displayed in the text box.
define character = Character("character", color="#c8ffc8")

#When the game starts, it starts from label start.
label start:
    #Short name of the character"Dialogue"でDialogueの表示
    character "Hello!"

    #I have to set the character name,Narration.
    "It is narrated Hello"

    #End of label with return.
    return

Character image settings

Set the character image as follows.

script.rpy


#Abbreviation
label start:
    
    show character default
    with fade
    
    character "Hello!"

    return
    

What you should pay attention to here is the character string after show. Here, the image is displayed by specifying the file name of any image.

And there is a recommended naming convention for image names, for example bg green.jpg (Bg Green.jpg is also acceptable) where "bg" is the tag and "green" is the attribute. Other possible names are as follows.

script.rpy


#bg is the tag and green and house are the attributes
show bg green house

Also, if images with the same tag are specified at the same time, the last specified image will be displayed.

Next, there is with fade, which is a transition.

Please refer to the following for details (because there are many).

https://ja.renpy.org/doc/html/quickstart.html#transitions

Using python scripts

You can use python scripts (python2 series) in Ren'py. Although it has not been officially announced yet, there is a possibility that 3 series python can be used in the future. (Reference: https: // twitter .com / renpytom / status / 1196203607252709376? s = 20)

Then, I will explain how to use it.

script.rpy



default flag = False

label start:

    menu:
        "Do you want to convey your feelings?"
        "Yes":
            $ flag = True
        "No":
    jump flag
    return

label flag:
    if not flag:
        "Bad End"
    else:
        "Good End"

    return

Various new elements have come out. I will explain them in order.

First, there is a default statement, which is for initializing the variable you want to use before the start label. It is not necessary, but in that case, if you use a variable in the label, Flase will be automatically added as the initial value.

Then there is the menu inside the start label.

script.rpy


Abbreviation
    menu:
        "Choose an option"
        "Yes":
            jump yes
        "No":
            jump no

The usage is like this, it is not necessary to have a narration part. " Choice ": I will write it. Then you can indent and write the process. This area is the same as python You can set jump to jump label name you want to skip, and the process will jump to the label you want to jump, and when that label ends with return, the process will return again.

Next, $ flag = True, but you can write python code with only one line after $. If you want to write code over multiple lines, you can write:

script.rpy


python:
    life = 100
    damage = 50
    my_life = life - damage

Next is the if statement. The if statement can be used as it is without using $ or python.

If you keep the above basics in mind, you can also make novel games using Ren'py !!!!

Ren'py game making application

From here on, it's a little application.

First, let's change the default startup screen of Ren'py.

The default screen looks like this. スクリーンショット 2019-12-05 15.49.42.png

Let's set the blue test in the lower right to Ren'py and the color to orange (# f59e11).Screenshot 2019-12-05 20.49.55.png -store.s3.ap-northeast-1.amazonaws.com/0/274354/ee736739-8a81-6410-56f6-9db2ed2cf0e8.png)

The points to change are as follows.

options.rpy(Around the 16th line)


define config.name = _("test")
#Change this to
define config.name = _("Ren'py")

gui.rpy(Around line 28)


define gui.accent_color = '#0099cc'
#Change this to
define gui.accent_color = '#f59e11'

Then change the image of the menu.

gui.rpy(Around line 96)


define gui.main_menu_background = "gui/main_menu.png "
#Change this to
define gui.main_menu_background = "gui/main_susuki.png "

If you change it, it will be like this. (This time the image size does not match, but let's match the image to the size of the game in production)

スクリーンショット 2019-12-05 20.58.10.png

Finally

To be honest, I've broken a lot, but basically, if you understand this far, I think you can make as many deliverables as you made. Everyone, please try to make something with Ren'py!

Reference site

https://ja.renpy.org/doc/html/index.html

Recommended Posts

I made a school festival introduction game using Ren’py
〇✕ I made a game
I made a Line-bot using Python!
I made a game called Battle Ship using pygame and tkinter
Beginner: I made a launcher using dictionary
I made a life game with Numpy
I made a roguelike game with Python
I tried to make a ○ ✕ game using TensorFlow
I made a bin picking game with Python
I made a login / logout process using Python Bottle.
I made a Christmas tree lighting game with Python
I made a vim learning game "PacVim" with Go
I made a falling block game with Sense HAT
[I tried using Pythonista 3] Introduction
I made a python text
I made a discord bot
I made a simple typing game with tkinter in Python
I made a quick feed reader using feedparser in Python
I made a simple book application with python + Flask ~ Introduction ~
I made a Numer0n battle game in Java (I also made AI)
I made a VGG16 model using TensorFlow (on the way)
I made a puzzle game (like) with Tkinter in Python
I made a muscle training estimation app using Qore SDK
I made a Chatbot using LINE Messaging API and Python
I made a C ++ learning site
I made a CUI-based translation script (2)
I made a wikipedia gacha bot
I made a fortune with Python.
I made a CUI-based translation script
Zura made like a life game
I made a Dir en gray face classifier using TensorFlow-④ Face extraction
I made a daemon with Python
I made a Chatbot using LINE Messaging API and Python (2) ~ Server ~
[Kaggle] I made a collection of questions using the Titanic tutorial
I made a Dir en gray face classifier using TensorFlow --⑩ Face classification test
I made a Dir en gray face classifier using TensorFlow --⑥ Learning program
I made a Dir en gray face classifier using TensorFlow --⑬ Playing (final)
I made a Dir en gray face classifier using TensorFlow --- ⑧ Learning execution
I made a Dir en gray face classifier using TensorFlow --⑫ Web release
I made a Dir en gray face classifier using TensorFlow --- ⑦ Learning model
I made an image discrimination (cifar10) model using a convolutional neural network.
I made a new AWS S3 bucket
I made a dash docset for Holoviews
I made a payroll program in Python!
I touched "Orator" so I made a note
I made a character counter with Python
I tried drawing a line using turtle
I made a conversation partner like Siri
I made a script to display emoji
I made a Hex map with Python
I made a stamp generator with GAN
I made a browser automatic stamping tool.
After studying Python3, I made a Slackbot
I tried using pipenv, so a memo
I made a simple blackjack with Python
I made a configuration file with Python
I made a library for actuarial science
I made a WEB application with Django
I made a neuron simulator with Python
I made a LINE BOT that returns a terrorist image using the Flickr API
I made a Dir en gray face classifier using TensorFlow --⑪ Web release preparation