Choosing characters at the start of the game

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
MisterHarold
Newbie
Posts: 18
Joined: Tue Jul 17, 2018 10:32 am
Location: Philippines
Contact:

Choosing characters at the start of the game

#1 Post by MisterHarold » Wed Jan 09, 2019 3:13 am

I would like a game that will let you choose your character at the beginning. For example, a male and a female, each assigned with their own character sprites. How will I do that?

User avatar
Nagibator
Newbie
Posts: 16
Joined: Wed Jan 09, 2019 2:42 am
Contact:

Re: Choosing characters at the start of the game

#2 Post by Nagibator » Wed Jan 09, 2019 4:07 am

Well, there are definitely multiple ways of doing that. But if I had to, I would start by making a character with a name that is based off of a variable and an image.

Code: Select all

define p = Character("[player]", image = "playerImage")
default player = "Example"
You'll then want to predefine the image "playerImage" with another variable.

Code: Select all

default gender = ""

image side playerImage = "[gender]"
After that, you can set up a menu either using the "menu:" option or through screens. I used a simple menu that changes the name and the image's file destination depending on which option you chose.

Code: Select all

menu:
	"Male":
		$ player = "Tom"
		$ gender = "player/male.png"
	"Female":
		$ player = "Eileen"
		$ gender = "player/female.png"
I wouldn't doubt that there's a more efficient way of doing it, but that's the first thought that came to my head.
Image

Post Reply

Who is online

Users browsing this forum: LateWhiteRabbit