Game Interface 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
Oragnic
Newbie
Posts: 1
Joined: Sat Dec 14, 2019 12:11 pm
Contact:

Game Interface Help

#1 Post by Oragnic » Sat Dec 14, 2019 12:23 pm

I'm relatively new to Ren'py. I'm trying to mess around and learn various things. I noticed that some games will have icons that you can click on the screen such as a map or a cellphone. I'm trying to replicate this process but it seems I'm in over my head. I'm able to program an "interface" button which takes me to the mapscreen and I have 3 location buttons. However when I call the location in my script it quickly flashes the location and then goes back to the main menu. I was curious as to how I could something like click "home" which will take me to the home location, Then I could click the interface/map button and go back to the map, once at the map I can click a new location like "school" and basically repeat this process as many times as I want without going back to the title screen. I tried adding a pause statement but it just made it so I had to double click my icons. I put the code below to try and help figure it out. Any help is super appreciated!

Script

Code: Select all

image Home = im.Scale("home.png", 1280, 720)
image Park = im.Scale("park.png", 1280, 720)
image School = im.Scale("school.png", 1280, 720)
default Location = "Home"

label start:
    #$ GameRunning = True
    #while GameRunning:
    #menu:
        #"Map":
            #$ Location = renpy.call_screen("MapScreen", _layer="screens")
            if renpy.has_image(Location.lower(), exact = True):
                scene expression Location
return
MapScreen

Code: Select all

screen MapScreen():
    frame:
        xalign 0.0
        yalign 0.0
        xsize 1280
        ysize 720
        background im.Scale("map.png", 1280, 720)
        for q in Places:
            if q.IsActive:
                imagebutton:
                    xpos q.x
                    ypos q.y
                    hover q.havatar
                    idle q.avatar
                    action Return(q.name)
Screen code /interface button

Code: Select all

screen interface_menu():

    zorder 100
    if interface_menu:
        hbox:
            style_prefix "interface"
            xalign 0
            yalign 0

            imagebutton:
                xpos 20
                ypos 20
                hover "mhover"
                idle "mmm"
                action Show ("MapScreen", _layer="screens")
init python:
    config.overlay_screens.append("interface_menu")

default interface_menu = True

screen quick_menu():
Thanks again for any help!

User avatar
Per K Grok
Miko-Class Veteran
Posts: 774
Joined: Fri May 18, 2018 1:02 am
Completed: the Ghost Pilot, Sea of Lost Ships, Bubbles and the Pterodactyls, Defenders of Adacan Part 1 & 2
Projects: the Phantom Flier
itch: per-k-grok
Location: Sverige
Contact:

Re: Game Interface Help

#2 Post by Per K Grok » Sat Dec 14, 2019 1:10 pm

Oragnic wrote:
Sat Dec 14, 2019 12:23 pm
I'm relatively new to Ren'py. I'm trying to mess around and learn various things. I noticed that some games will have icons that you can click on the screen such as a map or a cellphone. I'm trying to replicate this process but it seems I'm in over my head. I'm able to program an "interface" button which takes me to the mapscreen and I have 3 location buttons. However when I call the location in my script it quickly flashes the location and then goes back to the main menu. I was curious as to how I could something like click "home" which will take me to the home location, Then I could click the interface/map button and go back to the map, once at the map I can click a new location like "school" and basically repeat this process as many times as I want without going back to the title screen. I tried adding a pause statement but it just made it so I had to double click my icons. I put the code below to try and help figure it out. Any help is super appreciated!

------
This is a simple example using just text, that does what I think you are trying to do.

Code: Select all

screen openmap():

    textbutton "Open map" action Show("map") pos (5, 10)


screen map():
    textbutton "Home" action Jump("home") pos (5, 30)
    textbutton "Park" action Jump("park") pos (5, 50)
    textbutton "School" action Jump("school") pos (5, 70)


label start:
    show screen openmap


label home:
    hide screen map
    "Welcome home."

    pause

label park:
    hide screen map
    "Welcome to the park."

    pause

label school:
    hide screen map
    "Welcome to the school."

    pause



User avatar
Ibitz
Regular
Posts: 63
Joined: Thu Jul 27, 2017 4:47 pm
Projects: Magical Disarray (WIP)
Organization: Ibitz Visual Novels
Deviantart: http://ibitz.deviant
itch: ibitz
Contact:

Re: Game Interface Help

#3 Post by Ibitz » Wed Dec 18, 2019 10:04 pm

I kind of did an imagemap similar to this and can basically be repeated over and over. You pick berries in each screen until you get down to one main berry and start all over again or jump to the next screen by clicking the main berry. Maybe this might help you out?

What my screens file lists:

Code: Select all

################################################################################
screen Berries_all:
    tag menu
    imagemap:
        ground "Cutscenes/BERRY BUSH_IDLE.jpg"
        idle "Cutscenes/BERRY BUSH_IDLE.jpg"
        hover "Cutscenes/BERRY BUSH_Hover.jpg"
        
        alpha False
         
        hotspot(48,147,80,25) action ShowMenu ('Berries_6') 
        hotspot(474,245,82,25) clicked Return ("Purple Berry") 
        hotspot(712,195,80,26) action ShowMenu ('Berries_1') 
        hotspot(181,522,80,26) action ShowMenu ('Berries_2')                                                

################################################################################
screen Berries_1:
    tag menu
    imagemap:
        ground "screens/BERRY BUSH2_idle.jpg"
        idle "screens/BERRY BUSH2_idle.jpg"
        hover "screens/BERRY BUSH2_hover.jpg"
        
        alpha False
         
        hotspot(48,147,80,25) action ShowMenu ('Berries_5') 
        hotspot(474,245,82,25) clicked Return ("Purple Berry") 
        hotspot(181,522,80,26) action ShowMenu ('Berries_3') 
################################################################################
screen Berries_2:
    tag menu
    imagemap:
        ground "screens/BERRY BUSH3_idle.jpg"
        idle "screens/BERRY BUSH3_idle.jpg"
        hover "screens/BERRY BUSH3_hover.jpg"
        
        alpha False
         
        hotspot(48,147,80,25) action ShowMenu ('Berries_4') 
        hotspot(474,245,82,25) clicked Return ("Purple Berry") 
        hotspot(712,195,80,26) action ShowMenu ('Berries_3') 
################################################################################
screen Berries_3:
    tag menu
    imagemap:
        ground "screens/BERRY BUSH4_idle.jpg"
        idle "screens/BERRY BUSH4_idle.jpg"
        hover "screens/BERRY BUSH4_hover.jpg"
        
        alpha False
         
        hotspot(48,147,80,25) action ShowMenu ('Berries_7') 
        hotspot(474,245,82,25) clicked Return ("Purple Berry")   
################################################################################
screen Berries_4:
    tag menu
    imagemap:
        ground "screens/BERRY BUSH5_idle.jpg"
        idle "screens/BERRY BUSH5_idle.jpg"
        hover "screens/BERRY BUSH5_hover.jpg"
        
        alpha False
         
        hotspot(474,245,82,25) clicked Return ("Purple Berry") 
        hotspot(712,195,80,26) action ShowMenu ('Berries_7') 
################################################################################
screen Berries_5:
    tag menu
    imagemap:
        ground "screens/BERRY BUSH6_idle.jpg"
        idle "screens/BERRY BUSH6_idle.jpg"
        hover "screens/BERRY BUSH6_hover.jpg"
        
        alpha False
         
        hotspot(474,245,82,25) clicked Return ("Purple Berry")  
        hotspot(181,522,80,26) action ShowMenu ('Berries_7')  
################################################################################
screen Berries_6:
    tag menu
    imagemap:
        ground "screens/BERRY BUSH7_idle.jpg"
        idle "screens/BERRY BUSH7_idle.jpg"
        hover "screens/BERRY BUSH7_hover.jpg"
        
        alpha False
          
        hotspot(474,245,82,25) clicked Return ("Purple Berry") 
        hotspot(712,195,80,26) action ShowMenu ('Berries_5') 
        hotspot(181,522,80,26) action ShowMenu ('Berries_4')   
################################################################################
screen Berries_7:
    tag menu
    imagemap:
        ground "screens/BERRY BUSH8_idle.jpg"
        idle "screens/BERRY BUSH8_idle.jpg"
        hover "screens/BERRY BUSH8_hover.jpg"
        
        alpha False
         
        hotspot(474,245,82,25) action Start("next")  
################################################################################
And this is what it looks like when used in my script/game:

Code: Select all

      "I make my way through the forest towards our favorite berry bushes. These {a=Marionberry - a blackberry developed by the USDA ARS breeding program in cooperation with Oregon State University.(Greetings from Oregon!)}Marionberry{/a} bushes have been here for as long as I can remember. My siblings and I used to spend a lot of time eating the berries while we played hide and seek inside the vines."
      play six "sfx/Walking Footsteps.ogg"    
      scene berry_bush with Dissolve (1.0)
      "I smile at the memory, brought out of my thoughts by the sweet scent of the berries tickling my nose. I scan the prickly vines, looking for my next \"victims.\""
      "One by one I pluck the fat; juicy berries from the bush and gently place them into my basket."
      stop music fadeout 1.0
      play one [ "sfx/pickfrombush.ogg", "<silence 7>", "sfx/pickfrombush.ogg", "<silence 7>" ] loop 
      call screen Berries_all
    
      $ result = _return
    
      if result == "Pick This One":
          "You kept picking..."
      elif result == "Pick That One":
          "You kept picking..."
      
  label next:
      $ save_name = "Chapter 1: Meet Your Enemy"
      stop one
      scene berry_bush
Hopefully it can help.
Image

Ibitz is a self-taught coder/artist who works alone on their games. All games I create are freeware. If you need any help with coding or creating your game, just let me know. I'd be more than happy to help.

Post Reply

Who is online

Users browsing this forum: No registered users