how to imagemap? hmmm. - SOLVED!

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
shuumai
Newbie
Posts: 5
Joined: Fri Apr 13, 2012 5:44 am
Contact:

how to imagemap? hmmm. - SOLVED!

#1 Post by shuumai »

Hi! I'm a serioussss newbie of Ren'py! okay, so starting from choosing the characters.

Code: Select all

screen character_select:
    zorder 100 #this makes sure the imagemap is on top of everything else
    imagemap:
        ground "choose!.png" #what the imagemap looks like normally
        hover "mhm.png" #what it looks like when everything's hovered over
        
        hotspot (173, 99, 333, 446) clicked Return("sakura")
        hotspot (519, 100, 330, 445) clicked Return("takuya")

label start:
    show image "choose!.png"
    with dissolve #these two lines are because I'm a perfectionist and want the screen to fade in, which it can't do normally when you use call
    # and you have to use call NOT SHOW for an imagemap screen, otherwise the game will just take you back to the main menu afterward/skip over the screen, basically 
    call screen character_select
    $ result = _return #makes that return into a variable so you can use it
    if result == "takuya":
        jump takuya_start
    elif result == "sakura":
        jump sakura_start
        
# The game starts here.

menu:
        "Sakura":
            $ character = "A"
        "Takuya":
            $ character = "B"
if character == "A":
I've successfully imagemaped the choose which character page now, everytime I launch it, it works but then when I try to pick a character, it says
"could not find sakura_start" the one I bolded, so what do you think is wrong with it?
elif result == "sakura":
jump sakura_start
note: the codes, I just copied and pasted so I don't really know what I'm doing haha. I just started today so, yeah. please guide me~

EDIT:
okay so I got it to work but then it shows it like this
Image
Last edited by shuumai on Fri Apr 13, 2012 8:39 am, edited 1 time in total.

tuna_sushi
Veteran
Posts: 299
Joined: Thu Jul 07, 2011 9:33 am
Projects: BloomingBlossoms
Contact:

Re: how to imagemap? hmmm.

#2 Post by tuna_sushi »

shuumai wrote:EDIT:
okay so I got it to work but then it shows it like this
Image

Code: Select all

menu:
 "Sakura":
 $ character = "A"
 "Takuya":
 $ character = "B"
if character == "A":
Delete this and put this below the "if" and "elif" like this:

Code: Select all

    if result == "takuya":
    $ character = "A"
        jump takuya_start
    elif result == "sakura":
    $ character = "B"
        jump sakura_start
I hope you can understand me ^_^"

shuumai
Newbie
Posts: 5
Joined: Fri Apr 13, 2012 5:44 am
Contact:

Re: how to imagemap? hmmm.

#3 Post by shuumai »

@tuna_sushi, first of all thank you for replying~ but it still won't wr=ork, maybe there's something wrong with my other codes?

Image
Image

and just so you know, I changed it to this~
Image
Last edited by shuumai on Fri Apr 13, 2012 7:59 am, edited 1 time in total.

Valmoer
Regular
Posts: 53
Joined: Sat Feb 04, 2012 9:46 pm
Contact:

Re: how to imagemap? hmmm.

#4 Post by Valmoer »

Code: Select all

    if result == "takuya":
    $ character = "A"
        jump takuya_start
    elif result == "sakura":
    $ character = "B"
        jump sakura_start
should be

Code: Select all

    if result == "takuya":
        $ character = "A"
        jump takuya_start
    elif result == "sakura":
        $ character = "B"
        jump sakura_start
Indentation is critical in python (and thus in renpy).

In a general manner :

Code: Select all

    keyword 'statement' :
        indented code
        that is linked to the statement
    non-indented code -> no link to the previous statement

shuumai
Newbie
Posts: 5
Joined: Fri Apr 13, 2012 5:44 am
Contact:

Re: how to imagemap? hmmm.

#5 Post by shuumai »

@valmoer, oh! I see! thank you.

but then it says
line 48: indentation mismatch
where it says [if result == "takuya":]

Valmoer
Regular
Posts: 53
Joined: Sat Feb 04, 2012 9:46 pm
Contact:

Re: how to imagemap? hmmm.

#6 Post by Valmoer »

Hmm... I'm not quite sure, but I think your cut/paste philosophy is backstabbing you
For Massive Damage!
In the words of one more skilled than me :
Jake wrote:Python - and thus Ren'Py, which is based on Python - is rather picky about indentation; you have to use spaces to indent your lines, and you have to indent each line in the same 'block' by the same number of spaces. While the general layout of the sample you posted there looks OK, and if I copy and paste it into the template script here it runs fine, there's probably some extra space/s or tabs instead of spaces somewhere which the engine is picking up.

Open the editor, look at line [48], and double-check the indentation. It's probably easiest to delete all the empty space at the beginning of the line and replace it with space characters to the same depth as the surrounding block, just to be sure.
So, when you see a bit of code that does please you, do not take it as is - copy it by hand one character at a time, thus :
  1. Giving you control over what you type, especially the indentation
  2. Forcing you to understand what you type.

Edit:
Image What ?
Last edited by Valmoer on Fri Apr 13, 2012 8:28 am, edited 2 times in total.

shuumai
Newbie
Posts: 5
Joined: Fri Apr 13, 2012 5:44 am
Contact:

Re: how to imagemap? hmmm.

#7 Post by shuumai »

oh wait! I don't think the rest are the problem but the

Code: Select all

 jump sakura_start
and takuya's one
so before adding that, did i have to code any other first to make sakura_start on or found(?)

^
lol sorry as in, did i need to put anything before

Code: Select all

 jump sakura_start
because usually, the errors said it's because of that
Image

Valmoer
Regular
Posts: 53
Joined: Sat Feb 04, 2012 9:46 pm
Contact:

Re: how to imagemap? hmmm.

#8 Post by Valmoer »

Why, yes, you do need to code a

Code: Select all

label sakura_start:
or a

Code: Select all

menu sakura_start:
(if you want a menu)
before you can do a

Code: Select all

jump sakura_start
or a

Code: Select all

call sakura_start
Otherwise, you would ask renpy to jump to a point in the code... that doesn't exist. I guess you can see why he'd be confused.
Do note, though, that it doesn't need to exist before the jump call, it just need to exist inside the script file (or any of your script file, for that matter).

shuumai
Newbie
Posts: 5
Joined: Fri Apr 13, 2012 5:44 am
Contact:

Re: how to imagemap? hmmm.

#9 Post by shuumai »

aha! now that helped, thank you so much. sorry, I'm a beginner haha. I just started today as I mentioned in the first post. thank you!
But can I ask something?
How do you measure the coordinates for image maping when it comes to buttons?
sorry for the question~


never mind! got it! thank you sooooo much! :D

Valmoer
Regular
Posts: 53
Joined: Sat Feb 04, 2012 9:46 pm
Contact:

Re: how to imagemap? hmmm. - SOLVED!

#10 Post by Valmoer »

I'm not sure I understand your question...
Either you ask "How do we specify the area that a hotspot covers ?" and you already know that : you coded (or copied :lol: ) it before : it's Hotspot (x, y, width, height).

Or you're asking "How do we know which are the values of x, y, width, height that correspond to my screen ?" and, well, I say with your favorite image editor.

Or, another possibility : I totally didn't understand what you were asking.

Edit: Okay! Glad to have helped 8) :mrgreen:

Post Reply

Who is online

Users browsing this forum: Google [Bot], IrisColt, LegsWild