hovermap with changing images

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
flo617
Newbie
Posts: 2
Joined: Sat Nov 03, 2018 9:28 pm
Contact:

hovermap with changing images

#1 Post by flo617 »

Hello,

I am very new at renpy and I am trying to create scenes that change with the time of day along with a map on each scene that allows the player to navigate from a part of a town to another in a first person style.

For example, one scene is a train station and has up to four representations: dawn, dusk, day and night. From there the player can go to main street or enter the hotel across the street.

Here are two of these images:
bg trainstation day.jpg
bg trainstation night.jpg
.

Now that works very well in my code. The image gets picked depending on the time of the day. However when I hover over a "gate" to another part of the town. I will get this on the first hover:
grmbl.png
Notice that the scene is dawn as it should be here. But the hotspots are still displayed with the night image. After the first hover everything gets back to normal and the image is good again. Currently I am using the same image for the "hover" and the "ground" and it might stay that way.

-Is there a way to assign a null image to the "hover" or a blank fully transparent one that will not need to be updated?
-Is this cache related and if so can that hover be pushed out of the cache in any way?
-any other suggestion to fix this?

Here's the code:

Code: Select all

screen trainstation_map:
    #default tt = Tooltip("No button selected.")
    default map_info = ""
    imagemap: 
        ground "bg trainstation [dayperiod].jpg"
        hover "bg trainstation [dayperiod].jpg"

        hotspot (394, 333, 147, 160) hovered SetScreenVariable('map_info',"Main St") unhovered SetScreenVariable('map_info',"") clicked Return("mainstreet") 
        hotspot (209, 358, 112, 131) hovered SetScreenVariable('map_info',"Hotel") unhovered SetScreenVariable('map_info',"") clicked Return("hotel") 
    hbox:
        xalign 0.5
        yalign 0.5
        text map_info    

label train_station:

    call dayp(0.5) #increment the time and figure out if it is day or night
    $renpy.scene()
    $renpy.show('bg trainstation ' + dayperiod)
    if "trainstation" not in visited:
        "The hotel is right in front of a small deserted train station. A few steps back, running parallel to the track, is what looks like mainstreet"
        $ visited.add("trainstation")
    $ roundedtime=int(math.floor(time))
    "I am by the hotel and the train station, The time is [roundedtime], you have been here for [day] days"
    call screen trainstation_map
    $whereto = _return
    if whereto == "mainstreet":
        jump main_street
        
    jump train_station
Thank you!
Florent

User avatar
Alex
Lemma-Class Veteran
Posts: 3090
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: hovermap with changing images

#2 Post by Alex »

Just a shot in the dark - check your images not to be semitransparent and use RGB color-schem (not CMYK).

flo617
Newbie
Posts: 2
Joined: Sat Nov 03, 2018 9:28 pm
Contact:

Re: hovermap with changing images

#3 Post by flo617 »

Interesting, thank you. Are there more than one color coding that can be archived in jpeg? I did notice that hover was struggling when pointing to transparent hover zones when I was trying using fully transparent PNG images as the hover.

I just found a fix to my posted issue with a combination of two lines: $renpy.free_memory() just before the call to the imagemap and idle "bg trainstation [dayperiod].jpg" as a property to the imagemap. I'm still unsure why the idle line was necessary.

Code: Select all

screen trainstation_map:
    default map_info = ""
    imagemap: 
        ground "bg trainstation [dayperiod].jpg"
        idle "bg trainstation [dayperiod].jpg"
        hover "bg trainstation [dayperiod].jpg"
        

        hotspot (394, 333, 147, 160) hovered SetScreenVariable('map_info',"Main St") unhovered SetScreenVariable('map_info',"") clicked Return("mainstreet") 
        hotspot (209, 358, 112, 131) hovered SetScreenVariable('map_info',"Hotel") unhovered SetScreenVariable('map_info',"") clicked Return("hotel") 
    hbox:
        xalign 0.5
        yalign 0.5
        text map_info    

label train_station:
    
    call dayp(0.5) #increment the time and figure out if it is day or night
    $renpy.scene()
    $renpy.show('bg trainstation ' + dayperiod)
    
    if "trainstation" not in visited:
        "The hotel is right in front of a small deserted train station. A few steps back, running parallel to the track, is what looks like mainstreet"
        $ visited.add("trainstation")
    $ roundedtime=int(math.floor(time))
    "I am by the hotel and the train station, The time is [roundedtime], you have been here for [day] days"
    $renpy.free_memory()
    call screen trainstation_map
    $whereto = _return
    if whereto == "mainstreet":
        jump main_street
        
    jump train_station

Post Reply

Who is online

Users browsing this forum: No registered users