Search code examples
dictionarypygamedraw

draw dictionary in an adventure game


I've been programming my adventure game and I'd like to display my dictionary. I'm unfortunately not familiar with for loops. The dictionary should display my items which are stored in a different class. The items are not displaying in different rows. They merge into each other. hopefully someone can help me out.

"""

for k, v in self.hero_dic_items.items():
    BATTLE.draw_dmg(k, 110, 150, 10, self.black)
    BATTLE.draw_dmg(v, 200, 150, 10, self.black)

"""


Solution

  • Whatever argument to draw_dmg that specifies the y-coordinate to draw at needs to be different for each object. For example, you could have a variable y initialized to the location for the 1st item, and add enough to it inside the loop so that each next item will be drawn far enough down not to overlap. Something like y = y + 10 (or whatever number is appropriate).