python - How to create sprites using ConfigParser in Pygame -


i have pygame program , cant sprites work.

i using configparser , map proof of concept is:

################## ################## #...#########....# #.p.........#....# #...#######....p.# ###########.#....# ##.p.######.#....# ##...######.###### ###.#######.###### ###.............## ###############.## ######.p.######.## ######...#####..## ######...#.....### #######.##...##### ##..........###### ##.######...###### #...#####...###### #.p.#####..####### #...#####..####### #########..####### 

where p sprite

how tell configparser if there p sprite?

thanks

# load map  mymap = []  open('data.txt') f:     line in f:         mymap.append( line.strip() )  # show map  line in mymap:     print line  # find sprites on map  y, line in enumerate(mymap):     x, char in enumerate(line):         if char == 'p':             print 'sprite at', x, y 

result:

################## ################## #...#########....# #.p.........#....# #...#######....p.# ###########.#....# ##.p.######.#....# ##...######.###### ###.#######.###### ###.............## ###############.## ######.p.######.## ######...#####..## ######...#.....### #######.##...##### ##..........###### ##.######...###### #...#####...###### #.p.#####..####### #...#####..####### #########..#######  sprite @ 2 3 sprite @ 15 4 sprite @ 3 6 sprite @ 7 11 sprite @ 2 18 

you can read way:

mymap = open('data.txt').readlines() mymap = map(str.strip,mymap) # remove '\n' 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -