I am utilizing pygame and making an attempt to create an animation by going via an inventory of variables:
self.picture = self.walk_right[self.index]
I’ve loaded the pictures into variables and now i need to add them to my record, I assume there ought to be a method to make use of a for loop to do that, I attempted utilizing a formatted string to append them to the record, nonetheless then they turn out to be strings and I get the error:
TypeError: Supply objects have to be a floor
Is there a solution to convert these strings again to being variables? Is there a greater method to do that?
Or do I must kind out the identify of every body as soon as i’ve imported it from the sprite sheet?
walk_right_1 = sprite_sheet.get_image(1,11,sprite_width,sprite_height,1.25,0)
walk_right_2 = sprite_sheet.get_image(2,11,sprite_width,sprite_height,1.25,0)
walk_right_3 = sprite_sheet.get_image(3,11,sprite_width,sprite_height,1.25,0)
walk_right_4 = sprite_sheet.get_image(4,11,sprite_width,sprite_height,1.25,0)
walk_right_5 = sprite_sheet.get_image(5,11,sprite_width,sprite_height,1.25,0)
walk_right_6 = sprite_sheet.get_image(6,11,sprite_width,sprite_height,1.25,0)
walk_right_7 = sprite_sheet.get_image(7,11,sprite_width,sprite_height,1.25,0)
walk_right_8 = sprite_sheet.get_image(8,11,sprite_width,sprite_height,1.25,0)
walk_right_9 = sprite_sheet.get_image(9,11,sprite_width,sprite_height,1.25,0)
self.walk_right = []
for num in vary (1,10):
self.walk_right.append(f'walk_right_{num}')
Thanks for any assist!