Jump to content

  • Log In with Google      Sign In   
  • Create Account

Tile based RPG with Pyglet


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 WallaceD   Members   -  Reputation: 130

Like
0Likes
Like

Posted 27 July 2012 - 08:56 PM

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

e.g.

[map]

level = +++++
+-----+
+-----+
+++++

I was using configparser to turn this into a list of rows:
[source lang="python"]self.map = 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 Posted Image

Edited by WallaceD, 28 July 2012 - 01:31 AM.


Sponsor:

#2 slicksk8te   Members   -  Reputation: 191

Like
2Likes
Like

Posted 25 September 2012 - 04:00 PM

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 examplexCoord = 0yCoord = 0Map = ["-----"] # Preloaded mapfor 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




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS