load tilemaps made in Tiled directly into your Ren'py screen

in game •  6 years ago  (edited)


Here's few small functions that let you read and load maps you've made in Tiled directly into your screens to make those simple mini-games you wanted to make.

  • simply download and add these files to your game:
    04 image fit.rpy
    05 tilemap loader.rpy
    tilemap test.rpy

  • download Tiled to make your map:
    https://www.mapeditor.org/

  • make your map and export it as .csv file

  • put your map file and tileset in the game directory

  • follow the example screen in the tilemap test.rpy to find out how to add your tilemap to the screen

the important lines are:

default tsize = 32
default tileset = "maps/01.png"
default tilemap = "maps/01.csv"

where you specify your tile size, the path to your tileset image and the path to youe tilemap


the load_map function gives you a nested list like this:

default map:[
[-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1],
[-1,-1,-1,-1,-1,-1,-1,-1,29,3,29,29,11,12,13,-1],
[-1,-1,-1,-1,-1,-1,-1,-1,37,28,37,39,12,8,23,-1],
[-1,-1,-1,-1,-1,-1,-1,-1,23,28,1,41,36,4,33,-1],
[-1,-1,-1,-1,-1,-1,-1,-1,33,28,29,28,40,28,45,-1],
[-1,-1,-1,-1,-1,-1,-1,-1,29,38,39,37,9,39,45,-1],
[-1,-1,-1,-1,-1,-1,-1,-1,38,1,41,36,36,43,2,-1],
[-1,-1,-1,-1,-1,-1,-1,-1,27,27,27,32,32,33,-1,-1],
[-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1],
]

that comes in handy when you want to find out where is your player on the map and what blocks are around it by simply comparing your players x-y value with the map.
I think there are better ways to add tiles to renpy but I'm too lazy to fiddle with classes, Creator-Defined Displayables and I'm most comfortable working with screens and simple python functions.

I am providing this exclusively to my patreon and members of steem community.
to download, visit my patreon: https://www.patreon.com/KiaAzad
or leave a comment here


▶️ DTube
▶️ IPFS
Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

Your outstanding gaming content has caught our eyes and is rewarded with an upvote. Please visit our page @steemgg to learn more about Steemgg, the first html5 gaming platform built on the Steem Blockchain.
Vote for bobdos Witness

Congratulations @kiaazad! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :

You made more than 6000 upvotes. Your next target is to reach 7000 upvotes.

Click here to view your Board
If you no longer want to receive notifications, reply to this comment with the word STOP

Do not miss the last post from @steemitboard:

SteemWhales has officially moved to SteemitBoard Ranking
SteemitBoard - Witness Update

Support SteemitBoard's project! Vote for its witness and get one more award!