Movement Radius Screen on top of Tilemap not displaying

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
User avatar
Treladon
Regular
Posts: 40
Joined: Sat Dec 31, 2016 3:20 pm
Projects: ToMaG, Feinted Game
Organization: Kuehler-Corrada Productions
Deviantart: Journie
Contact:

Movement Radius Screen on top of Tilemap not displaying

#1 Post by Treladon »

Hi,

So I've created this tilemap that depicts the inside of a ballroom. What I'd like to do is create a screen overtop of this tilemap that, depending on the given movement radius, places imagebuttons around the main character so that the player can click and move to that spot. However, it's not displaying. I don't get an error, but it seems like Ren'Py isn't sure what my screen is.

Here's the relevant code:

Code: Select all

init -10 python:
    import math

    tileset=[Image("map block.png"), Image("map pillar.png"), Image("map transparent.png"), Image("map block.png")]
    
    map = [
        [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
        [0, 1, 0, 0, 0, 1, 0, 0, 0, 0],
        [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
        [0, 1, 0, 0, 0, 1, 0, 2, 2, 2],
        [0, 0, 0, 0, 0, 0, 0, 0, 0, 2],
        [0, 1, 0, 0, 0, 1, 0, 2, 0, 2],
        [0, 0, 0, 0, 0, 0, 0, 2, 0, 2],
        [0, 1, 0, 0, 0, 1, 0, 0, 0, 2],
        [0, 0, 0, 0, 0, 0, 0, 2, 2, 2]]
    
    def get_position_from_tilemap(column, row): #returns position of tile given its row and column on the tilemap
        x=265+(column*75)
        y=23+(row*75)
        return (x,y)
    def test_distance((column1, row1),(column2,row2)): #just a distance function
        distance=math.sqrt((column2-column1)**2+(row2-row1)**2)
        return distance
    def mark_move_radius(highlighted_radius):
        global map
        main_pos=(xposition_main,yposition_main) #main character's position
        for row in range(len(map)):
            for column in range(len(map[row])):
                if map[row][column]==1 or map[row][column]==2: #if tile is a pillar block or transparent block, skip it
                    continue
                else: #if tile is regular floor block:
                    testerpos=get_position_from_tilemap(column, row) #get tile's position
                    if test_distance(testerpos,main_pos)<=highlighted_radius*106.1: #75*sqrt(2) to grab diagonal squares
                        map[row][column]=3 #if within given distance to main character, mark as '3'
                    if test_distance(testerpos,main_pos)>highlighted_radius*106.1:
                        map[row][column]=0 #otherwise, mark as '0'
        return map

screen move_radius():
    for row in range(len(map)):
        for column in range(len(map[row])):
            if map[row][column]==3: #if tile has been marked as '3', place an imagebutton there
                imagebutton auto "map_rad button %s.png" focus_mask True action [Show('move_action')] xpos (265+(column*75)) ypos (23+(row*75))
In the label, it's executed like this:

Code: Select all

label overworld:
    show mapscreen at truecenter 
    $ mark_move_radius(highlighted_radius=3)
    show move_radius 
    with dissolve
However, this is what I see when it's all displayed:
renpy bug.PNG
Can anyone see what's wrong?
WIP: The Tasks of Messengers and Guardians - Progress Page Here!

User avatar
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: Movement Radius Screen on top of Tilemap not displaying

#2 Post by Remix »

The show statement might need a little nudge to tell it what to show... (it appears to be trying to show an image rather than screen)

show screen move_radius

Plus you might do best to manually add a fixed: into the screen
...and perhaps check math.hypot( adjacent length, opposite length ) rather than rolling your own
Frameworks & Scriptlets:

Post Reply

Who is online

Users browsing this forum: No registered users