creating an image map over an image map

DoctorPervic

Well-Known Member
Game Developer
Aug 13, 2019
1,081
4,430
So I am looking for some advice or help in understanding how I can create an image map over an image map.

What I want is to be able to display an image with some characters displayed. then when the user clicks on a character image, it displays another image that shows the character bio. then the next click brings them back to the previous scereen.

The current code I have to show an image like that is listed below. I have it for a galaxy map I want to use in my game. It works great, but I am at a loss on how to make an image that you click on to get another image displayed.

screen MapButton():
imagebutton:
xalign 0.98
yalign 0.03
idle "images/mapbutton.png"

action Show("GalaxyMap"), Hide("MapButton")

screen GalaxyMap():
imagebutton:
idle "images/galaxymap.jpg"
action Hide("GalaxyMap"), Show("MapButton")

any help is greatly apriciated. Thanks so much.
 

obsessionau

Member
Game Developer
Sep 27, 2018
270
376
From what you are saying I would probably go about it this way (so likely not to be the best way):

Python:
screen GalaxyMap():
    imagebutton:
        idle "images/galaxymap.jpg"
        action Call("MapScreen","PlanetMap")

screen PlanetMap():
    imagebutton:
        idle "images/planetmap.jpg"

label MapScreen(NewScreen):
#Do whatever you want here such as hide current map and show new map of zoomed in planets.
    show screen NewScreen
 
Last edited:

DoctorPervic

Well-Known Member
Game Developer
Aug 13, 2019
1,081
4,430
Basicly What I am trying to do is have a button that you click on that displayes this screen.

races.jpg

This screen will be a basic imagemap that I can target each image when clicked on will then open another image

nebulienbio.jpg

which is this one. Each image will have their own bio of the character image that can be displayed.

Then I need a way to exit out of each image and go back to the main image and also exit out of the main image and go back to the game.
 

obsessionau

Member
Game Developer
Sep 27, 2018
270
376
Essentially the same as above but there are so many different ways you could do it.

action Call("CharacterInfo","Neublien")

will send you to the label "CharacterInfo" and pass it the value "Neublien".

As your back in the label's you can hide the character screen and show another screen displaying all the details for "Neublien"
 
Last edited:

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,971
16,226
Python:
screen GalaxyMap():
    imagebutton:
        idle "images/galaxymap.jpg"
        action Call("MapScreen","PlanetMap")

screen PlanetMap():
    imagebutton:
        idle "images/planetmap.jpg"

label MapScreen(NewScreen):
#Do whatever you want here such as hide current map and show new map of zoomed in planets.
    show screen NewScreen
It's way too much works. You don't need to pass by a label for this.

Something like that is enough :
Code:
screen GalaxyMap():
    imagebutton:
        idle "images/galaxymap.jpg"
        action Show("PlanetMap")

screen PlanetMap():
    imagebutton:
        idle "images/planetmap.jpg"
Like you can have more than one action, it works perfectly whatever you expected to do in the label, unless it's displaying a dialog line.
 

DoctorPervic

Well-Known Member
Game Developer
Aug 13, 2019
1,081
4,430
So you can have more then 1 action. you would just put them under each other. like this?
action Show("PlanetMap")
action Hide("something")
action jump("something else")
 

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,608
2,256
So you can have more then 1 action. you would just put them under each other. like this?
action Show("PlanetMap")
action Hide("something")
action jump("something else")
Not quite.

You'd code it something like this...

Python:
            action [ Show("PlanetMap"), Hide("something"), Jump("somewhere") ]
In case you are wondering, the square brackets are used by python as a . So you're passing action a list of actions to perform.

I've added a few extra spaces to make things a little more readable - but they aren't strictly necessary.

I will say, it's not entirely obvious to me why you'd want action Show() and action Jump() combined. It feels like you're trying to enforce some sort of loop - but... hmmm... I can't find a way to explain what I mean here. So I'll just leave the start of the comment as a "something feels off about this" and hope I'm on the right track.


Also, since you've mentioned hide (screen) at the same time as show (screen) - it might be worth mentioning the tag property of a . What it does is say that only one screen with an identical tag can be shown on screen at a time. In effect, you can create a lot of separate screens with the same tag and showing one will automatically hide any other screen with the same tag.

Depending on how you are doing things, it may well mean you can avoid hiding one screen in order to show another.

Python:
screen  race_neubliens():
    tag race_details
    # blah blah

screen  race_ sireone():
    tag race_details
    # blah blah

# only one screen tagged "race_details" can be shown at any time.
 
Last edited:

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,971
16,226
Python:
            action [ Show("PlanetMap"), Hide("something"), Jump("somewhere") ]
Be noted that the order is important.
Screen actions like Jump, Call or Return, put you somewhere else on the game code. Therefore, they also stop the processing of the actions, and MUST always be the last one.
 

DoctorPervic

Well-Known Member
Game Developer
Aug 13, 2019
1,081
4,430
Thank you all for your help this will work great. all your information was very very helpful. about the show hide jump, thing. I just used thoes as examples for something for the actions to do.
 

DoctorPervic

Well-Known Member
Game Developer
Aug 13, 2019
1,081
4,430
Do you know how I can pause the game while the user is looking at the map and then continue after they exit out of the map.
I tried to use a call statement instead of a show for (show screen racebutton) that stops the game but I dont know how to start it again when the user exits the race bio page or the map page.

I also tried $ renpy.pause(hard=True) but that does the same thing.
Do I need to use an if statement.
 

DoctorPervic

Well-Known Member
Game Developer
Aug 13, 2019
1,081
4,430
I found out what I needed to use. modal True
It works perfectly now!!! Thanks