Is it possible to customize the Character class ?
Posted: Sun Mar 01, 2020 11:38 am
Hi,
Is there a possibility to customize the Character class in Ren'Py ? When we start the game, we define the class Character to assign some parameters like the name, the color text, the image side. I want to go forward with my character. I would like to create a child class of Character() to define more parameters like the HP, the Level, the strength etc.
Generally I define the class Character (name, color text, image side), and I create a Player class to add more features.
Must create 2 variables for each character, and I want to simplify the task and put together all the parameters in only one variable.
Is it possible to customize the Character class or create a child class ?
Thanks
Is there a possibility to customize the Character class in Ren'Py ? When we start the game, we define the class Character to assign some parameters like the name, the color text, the image side. I want to go forward with my character. I would like to create a child class of Character() to define more parameters like the HP, the Level, the strength etc.
Generally I define the class Character (name, color text, image side), and I create a Player class to add more features.
Code: Select all
init python:
class Player:
def __init__(self, name, hp = 0, money = 0):
self.name = name
self.hp = hp
def addHP(self, points):
self.hp += points
def subHP(self, points):
if self.hp < 0:
self.hp = 0
else:
self.hp -= points
define e = Character('Eileen', color="#c8ffc8")
define eileen = Player("Eileen", 10)
label start:
e "Hello my name is [eileen.name] and I have [eileen.hp] HP " # I want to replace eileen.name by e.name
# I would like something like this: e "Hello my name is [e.name] and I have [e.hp] HP "
Is it possible to customize the Character class or create a child class ?
Thanks