Public Group

# Python RPGs Beginner

This topic is 1090 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I want to create 2D RPGs in Python using Pygame or other such libraries. I have experience in making small games like snake, football penalty shoots etc. using Pygame. However, now I would like to move over to some 2D RPGs like the old GameBoy Zelda or Sword of Mana games. Please guide me to how I should start and learn about it.

##### Share on other sites

What do you see as different compared to eg Snake?

Apparently, you can code that, while a RPG causes some block to you. What are you stuck on?

I would start by making a very small world, eg 4x4 tiles or so with only walls (nothing else in the room), and program that. Then extend by having to reach a certain tile.

Does that look like a good step to you?

##### Share on other sites

Apparently, you can code that, while a RPG causes some block to you. What are you stuck on?

My main problem is the lack of knowledge on maps, tilesets etc. I tried various things myself and using the internet but was not satisfied.

##### Share on other sites

A common approach is to have a (flat) world as a rectangular 2D grid mapped out in X and Y. Each cell contains one thing.

In your case, a cell is either floor or wall. The simplest approach is a top-down view.

You need a sprite for each type, say a 64x64 pixels green image for a floor, and red 64x64 pixels image for a wall.

A map is a 2d array where you specify what each cell in the grid contains, eg

map = [ [ 1, 1, 1, 1, 1],
[ 1, 0, 0, 0, 1],
[ 1, 1, 0, 1, 1],
[ 1, 0, 0, 1, 1],
[ 1, 1, 1, 1,,1] ]

for y, row in enumerate(map):
for x, cell in enumerate(row):
if cell == 1:
draw_wall(x*64, y*64)
else:
draw_floor(x*64, y*64)


The 'map' is the central thing. The player is at one of the 0 values (eg pos=(1, 1) ). You can go to the right if map[pos[1], pos[0]+1] == 0, ie if the cell next to the current location is a floor.  (You could draw yellow circle at the center of the 'pos' cell).

This is the core of a map and a tile set. You can extend of course, instead of simple a red 64x64 image, make something that looks like a wall. Have a stone floor and a wooden floor instead of a green rectangle. You give each variation a unique value in the map, and you code the display and the movement. Instead of a yellw circle, make an image that looks like a player seen from above.

Add a "door" cell. When the player moves into it, he goes "through the door" and you draw a new room by changing the map.

##### Share on other sites

I searched google for Zelda clone pygame tutorial, and the first entry looks like exactly what you're looking for:
http://inventwithpython.com/blog/2012/12/10/8-bit-nes-legend-of-zelda-map-data/

He explains how a 2d tile map works and even has source code available on github. Read the article, try to get something working, and feel free to come back with questions.

- Eck

Thanks a lot!!!!

1. 1
2. 2
3. 3
Rutin
14
4. 4
5. 5

• 9
• 9
• 11
• 11
• 23
• ### Forum Statistics

• Total Topics
633673
• Total Posts
3013274
×