Renpy Objective programming 101 help

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
shiza
Regular
Posts: 29
Joined: Wed Jun 14, 2017 12:36 pm
Contact:

Renpy Objective programming 101 help

#1 Post by shiza »

So I'm a software engineer who's take the next step in creating a visual novel. I've been sifting through the documentation and I have yet to see any class declarations or creating functions. Is it possible to use object orient programming in ren'py in regards to characters and their stats? I mean the space alone will be a benefit instead of having 10 variables that tell the same type of stat for 10 different characters.

For example every character has HP but I want to know what Bob's Hp is currently at. In java you would code a class called character with all the basic information (HP, MP, AP, etc) and create instances of that class and call it by the characters name. that way you can do something like Bob.get_HP() instead of clustering the programming file with 100's of declarations. So could anyone tell me or point me to any documentation about implementing object oriented programming in ren'py?

Also does anyone have any tips on file size management? I'm barely done creating a demo and I'm already past 1000 lines in my code. Essentially everything done in a single file which makes it a bit hard to manage when you create a full scale game.

User avatar
Divona
Miko-Class Veteran
Posts: 678
Joined: Sun Jun 05, 2016 8:29 pm
Completed: The Falconers: Moonlight
Organization: Bionic Penguin
itch: bionicpenguin
Contact:

Re: Renpy Objective programming 101 help

#2 Post by Divona »

shiza wrote:So I'm a software engineer who's take the next step in creating a visual novel. I've been sifting through the documentation and I have yet to see any class declarations or creating functions. Is it possible to use object orient programming in ren'py in regards to characters and their stats? I mean the space alone will be a benefit instead of having 10 variables that tell the same type of stat for 10 different characters.

For example every character has HP but I want to know what Bob's Hp is currently at. In java you would code a class called character with all the basic information (HP, MP, AP, etc) and create instances of that class and call it by the characters name. that way you can do something like Bob.get_HP() instead of clustering the programming file with 100's of declarations. So could anyone tell me or point me to any documentation about implementing object oriented programming in ren'py?
You have to understand that Ren'Py is script language using Python as a programming language. So nothing is stopping you from creating class or function in Python. There isn't in depth on how to code in Python in Ren'Py documentation. Just a simple thing on how to corporate Python code along side Ren'Py script like Python Statements and Screens and Python (see Python and Ren'Py). For other tutorials on how to create class or function in Python, you can find in other document regards Python language itself.

- Python Object Oriented
- Python Functions
shiza wrote: Also does anyone have any tips on file size management? I'm barely done creating a demo and I'm already past 1000 lines in my code. Essentially everything done in a single file which makes it a bit hard to manage when you create a full scale game.
You can split the script into files. It doesn't have to be all in "script.rpy". Most common one would be split script based on "label" or "chapter". When Ren'Py is launch, it would read every files into one, so it doesn't matter. You can read more about it from the old Ren'Py FAQ - How do I split my game into multiple files?.
Last edited by Divona on Sat Jun 17, 2017 5:37 am, edited 2 times in total.
Completed:
Image

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2402
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Renpy Objective programming 101 help

#3 Post by Ocelot »

RenPy is built on top of Python -> You can use Python in your game V
Python supports Object Oriented Programming -> You can use OOP in your game if you want
https://www.renpy.org/doc/html/python.html
space alone will be a benefit instead of having 10 variables that tell the same type of stat for 10 different characters
Just a question, why are you so sure that you need OOP for that? What is wrong with simple data structures and functions manipulating them?

Also there are a lot of clases in RenPy. Like, everything starting with capital letter: all screen actions, all transition classes (predefined transitions are instances of those classes)...
Essentially everything done in a single file which makes it a bit hard to manage when you create a full scale game.
Separate it into different files: https://www.renpy.org/doc/html/language ... html#files
< < insert Rick Cook quote here > >

User avatar
papiersam
Veteran
Posts: 231
Joined: Fri Aug 12, 2016 2:24 pm
Completed: Gem Hunt Beta, 1/Probably, Animunch
Projects: The Panda Who Dreamed
Contact:

Re: Renpy Objective programming 101 help

#4 Post by papiersam »

Also does anyone have any tips on file size management? I'm barely done creating a demo and I'm already past 1000 lines in my code.
Separate it into different files: https://www.renpy.org/doc/html/language ... html#files
Also, software architecture. Prolly #4 priority in Software Engineering.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot]