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))
Code: Select all
label overworld:
show mapscreen at truecenter
$ mark_move_radius(highlighted_radius=3)
show move_radius
with dissolve