Point and Click Adventure Coding Questions + Help [SOLVED]
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.
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.
- aussieducky
- Regular
- Posts: 31
- Joined: Sat Dec 27, 2014 8:43 pm
- Projects: =
- Tumblr: aussiebunny
- Contact:
Point and Click Adventure Coding Questions + Help [SOLVED]
What I want in my game is for it to be a visual novel until the player needs to solve some puzzles.
I don't want an inventory or anything like that - just the ability to click on the screen to either read text in the text box, have an image appear on screen or move into a different room.
Thing is, being very new to coding and ren'py, I don't have any idea how to do this. I've looked at examples but I'm still confused. I know screen language is involved and lots of xpos/ypos positioning.
I guess my questions are: how would I start? When I use screen language, can I put it in the Script, or does it have to go under Screens?
I'm sorry this is such a broad question ~_~
I don't want an inventory or anything like that - just the ability to click on the screen to either read text in the text box, have an image appear on screen or move into a different room.
Thing is, being very new to coding and ren'py, I don't have any idea how to do this. I've looked at examples but I'm still confused. I know screen language is involved and lots of xpos/ypos positioning.
I guess my questions are: how would I start? When I use screen language, can I put it in the Script, or does it have to go under Screens?
I'm sorry this is such a broad question ~_~
Last edited by aussieducky on Wed May 20, 2015 8:13 am, edited 1 time in total.
I am a teenager who would like, very much, to finish a visual novel ;D
I don't know much about coding, but I'll try not to be a bother.
Currently working on: "Blackout"
I don't know much about coding, but I'll try not to be a bother.
Currently working on: "Blackout"
- Alera
- Miko-Class Veteran
- Posts: 651
- Joined: Sun Mar 21, 2010 3:20 am
- Completed: Tortichki // Zayay // Hero's Spirit
- Deviantart: psyalera
- itch: psyalera
- Location: UK
- Contact:
Re: Point and Click Adventure Coding Questions + Help
There's a lot of discussions on the topic. The simplest way to do a simple point and click would be with imagemaps. http://www.renpy.org/doc/html/screens.h ... statements
Here's another topic that talks about similar things: http://lemmasoft.renai.us/forums/viewto ... =8&t=31949
Screen language doesn't have to go under screen. It can be under your main script, usually defined before the Start label. Or you could even have a separate script file containing all your screens, if you have quite a few, for the sake of keeping it clean. Don't be afraid, it's not hard at all.
Here's a simple example. Rather than using an imagemap though, I've used imagebuttons. http://www.renpy.org/doc/html/screens.html#imagebutton They're more flexible than imagemaps because imagemaps can only have clickable areas that are squares so if you have an object that is an odd shape, imagebuttons are for you. The only thing that makes them 'harder' is that you need to position them yourself. That's why it involves all the xpos/ypos.
I hope that's enough to get you started! The rest should be easy to figure out. Just fill in the labels with what you want to happen next.
Here's another topic that talks about similar things: http://lemmasoft.renai.us/forums/viewto ... =8&t=31949
Screen language doesn't have to go under screen. It can be under your main script, usually defined before the Start label. Or you could even have a separate script file containing all your screens, if you have quite a few, for the sake of keeping it clean. Don't be afraid, it's not hard at all.
Here's a simple example. Rather than using an imagemap though, I've used imagebuttons. http://www.renpy.org/doc/html/screens.html#imagebutton They're more flexible than imagemaps because imagemaps can only have clickable areas that are squares so if you have an object that is an odd shape, imagebuttons are for you. The only thing that makes them 'harder' is that you need to position them yourself. That's why it involves all the xpos/ypos.
Code: Select all
screen room:
add "roomBackground.jpg" #This is your complete image of the scene. The imagebuttons are separate images of things in your scene that you want the player to interact with, such as doors,photos, etc. I used your example to create 3.
imagebutton auto "journal_%s.png" xpos 100 ypos 555 action Jump("readText") focus_mask True
imagebutton auto "photo_%s.png" xpos 200 ypos 400 action Jump("imageAppear") focus_mask True
imagebutton auto "door_%s.png" xpos 50 ypos 350 action Jump("moveRoom") focus_mask True
label start:
call screen room
label readText:
"Text goes here!"
label imageAppear:
show imageyouwant
label moveRoom:
call screen room2
- aussieducky
- Regular
- Posts: 31
- Joined: Sat Dec 27, 2014 8:43 pm
- Projects: =
- Tumblr: aussiebunny
- Contact:
Re: Point and Click Adventure Coding Questions + Help
@Alera Thank you so much for replying
About the imagebuttons - if I'm understanding right, they're images that I position on top of the background. So "journal_%s.png"/"photo_%s.png"/"door_%s.png" are all names of the separate images?
I copied the code into my script, but it's not working.
My code:
I made little images with the names you used, so all I changed was the scene image.
Again, I'm sorry for my slowness :<
About the imagebuttons - if I'm understanding right, they're images that I position on top of the background. So "journal_%s.png"/"photo_%s.png"/"door_%s.png" are all names of the separate images?
I copied the code into my script, but it's not working.
My code:
Code: Select all
screen room:
add "TestBG.png" #This is your complete image of the scene. The imagebuttons are separate images of things in your scene that you want the player to interact with, such as doors,photos, etc. I used your example to create 3.
imagebutton auto "journal_%s.png" xpos 100 ypos 555 action Jump("readText") focus_mask True
imagebutton auto "photo_%s.png" xpos 200 ypos 400 action Jump("imageAppear") focus_mask True
imagebutton auto "door_%s.png" xpos 50 ypos 350 action Jump("moveRoom") focus_mask True
screen room2:
add "TestBG2.png"
label start:
call screen room
label readText:
"This is a thing you can interact with, but can't see."
label imageAppear:
show oz with dissolve
"This is an item you can look at."
label moveRoom:
call screen room2
m "Huh. What a nasty room."
m "This doesn't even look real."
Again, I'm sorry for my slowness :<
I am a teenager who would like, very much, to finish a visual novel ;D
I don't know much about coding, but I'll try not to be a bother.
Currently working on: "Blackout"
I don't know much about coding, but I'll try not to be a bother.
Currently working on: "Blackout"
- Alera
- Miko-Class Veteran
- Posts: 651
- Joined: Sun Mar 21, 2010 3:20 am
- Completed: Tortichki // Zayay // Hero's Spirit
- Deviantart: psyalera
- itch: psyalera
- Location: UK
- Contact:
Re: Point and Click Adventure Coding Questions + Help
Oh, I can guess what the problem is!
auto "journal_%s.png" - this bit. Let me explain it to you. This is a function that automatically, as its name suggests, creates an 'idle' and 'hover' state for your imagebutton. Let's say your idle is just the basic image but you want the hover to have a glow around it or something else to indicate to the player that they can interact with the object. So to make it work, you need 2 images, instead of one. And their file names need to be: journal_idle and journal_hover for example. "_%s" -this bit of the code finds these files out and does the magic.
So all you need to do is just create a second version of your images and change their file names, there's no need to change the code.
auto "journal_%s.png" - this bit. Let me explain it to you. This is a function that automatically, as its name suggests, creates an 'idle' and 'hover' state for your imagebutton. Let's say your idle is just the basic image but you want the hover to have a glow around it or something else to indicate to the player that they can interact with the object. So to make it work, you need 2 images, instead of one. And their file names need to be: journal_idle and journal_hover for example. "_%s" -this bit of the code finds these files out and does the magic.
So all you need to do is just create a second version of your images and change their file names, there's no need to change the code.
- aussieducky
- Regular
- Posts: 31
- Joined: Sat Dec 27, 2014 8:43 pm
- Projects: =
- Tumblr: aussiebunny
- Contact:
Re: Point and Click Adventure Coding Questions + Help
Thank you, it worked perfectly
If I could just ask one more question, is there a way to trigger an event after the player looks at, say, 3 buttons? What I wanted to do was have the player read some things, then have the MC talk to himself about what he noticed.
I know how to use if statements with menu choices, if that helps at all :V
If I could just ask one more question, is there a way to trigger an event after the player looks at, say, 3 buttons? What I wanted to do was have the player read some things, then have the MC talk to himself about what he noticed.
I know how to use if statements with menu choices, if that helps at all :V
I am a teenager who would like, very much, to finish a visual novel ;D
I don't know much about coding, but I'll try not to be a bother.
Currently working on: "Blackout"
I don't know much about coding, but I'll try not to be a bother.
Currently working on: "Blackout"
- Alera
- Miko-Class Veteran
- Posts: 651
- Joined: Sun Mar 21, 2010 3:20 am
- Completed: Tortichki // Zayay // Hero's Spirit
- Deviantart: psyalera
- itch: psyalera
- Location: UK
- Contact:
Re: Point and Click Adventure Coding Questions + Help
I'm glad it worked!
Hm, there's several ways you could do that. For example you could have a variable that serves like a counter and you add +1 to it every time the player looks at something and when it reacher 3, use an if statement to trigger an event. However, this could be a problem if the player can look at something more than once, then they would get double the points and trigger the event early, even if they haven't looked at everything yet. So if that's the case, a solution would be to use multiple booleans (These are just variables that can only be set to True or False) I guess. Like this:
And that's the basis of it. This code can be simplified a bit by including the variable in the button itself, then you don't need it at the beginning of your labels. Like so for example:
But it works exactly the same in the end.
I hope that solution works for you!
Hm, there's several ways you could do that. For example you could have a variable that serves like a counter and you add +1 to it every time the player looks at something and when it reacher 3, use an if statement to trigger an event. However, this could be a problem if the player can look at something more than once, then they would get double the points and trigger the event early, even if they haven't looked at everything yet. So if that's the case, a solution would be to use multiple booleans (These are just variables that can only be set to True or False) I guess. Like this:
Code: Select all
label start:
#It's a good idea to declare your variables at the start of the game.
$ seenhis1 = False
$ seenthis2 = False
$ seenthis3 = False
label buttons:
#Let's pretend this label calls a screen with buttons that link to the next labels that are button1/2/3
if seenthis1 == True and seenthis2 == True and seenthis3 = True:
"Mc talks to himself about what he noticed."
else:
call screen buttons
label button1:
$ seenthis1 = True
jump buttons
label button2:
$ seenthis2 = True
jump buttons
label button3:
$ seenthis3 = True
jump buttons
Code: Select all
imagebutton auto "button1_%s.png" xpos 200 ypos 100 action SetVariable('seenthis1', True), Jump("button1") focus_mask True
I hope that solution works for you!
- aussieducky
- Regular
- Posts: 31
- Joined: Sat Dec 27, 2014 8:43 pm
- Projects: =
- Tumblr: aussiebunny
- Contact:
Re: Point and Click Adventure Coding Questions + Help
I'm sorry for the late reply, but thank you! I fiddled for a while and it all works
Thanks so much for all the help! I really appreciate it.
Thanks so much for all the help! I really appreciate it.
I am a teenager who would like, very much, to finish a visual novel ;D
I don't know much about coding, but I'll try not to be a bother.
Currently working on: "Blackout"
I don't know much about coding, but I'll try not to be a bother.
Currently working on: "Blackout"
Who is online
Users browsing this forum: Kocker, Semrush [Bot]