Sign in to follow this  

Tile based RPG with Pyglet

Recommended Posts

I'm trying to make a tile based RPG with pyglet but I'm a bit stuck [img][/img] I plan to have a text file from which it would read the tile positions and other details from



level = +++++

I was using configparser to turn this into a list of rows:
[source lang="python"] = parser.get("map","level").split("\n")[/source]

But I'm not sure where to go from there :/ What I want to do is have each symbol represent a tile (grass = - etc.) and be displayed on the screen.

Any suggestions would be greatly appreciated [img][/img] Edited by WallaceD

Share this post

Link to post
Share on other sites
A good start for this would be to load all textures into a dictionary where the key is a symbol.
An example of this is:
"-": grassImage,

and then loop through your map and draw based on the tile location:
[source lang="python"]tileMapping = {
"-": grassTexture, #preloaded

TILE_SIZE = 16 # for example

xCoord = 0
yCoord = 0

Map = ["-----"] # Preloaded map

for row in Map:
xCoord = 0
for tile in row:
tileTexture = tileMapping[tile]
x = xCoord * TILE_SIZE
y = yCoord * TILE_SIZE
# Draw Tile Texture Here at x,y
xCoord += 1
yCoord += 1[/source]

Hope this helps

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this