Reputation: 369
I am new to pygame and i am having a problem with something i am working on.
f=input('blahblablb')
if f =='badafd':
x=input'ajdfkladjsl'
elif f ==...
so i have this input and variable but later when i use the variables
class A(pygame.sprite.Sprite):
i made a class and had the code in it for an image and it appeared fine i also put it in a group and it appeared fine later i added
if f=='badafd':
all_sprites_list.add[A]
but the image appears even though f does not equal badafd please tell me the problem and i will include the main loop because that might be the problem
while True:
all_sprites_list.update()
all_sprites_list.draw(screen)
pygame.display.update()
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
if there is anything i could improve could you also tell me
Upvotes: 0
Views: 174
Reputation: 1897
You don't really have enough code, but I have some ideas (I can update the answer if more code is included). I am guessing that you are using an inputted string as a spite attribute. If this is the case, you could just assign the variable in initialization using input. If you want to assign this to all of them, just take the input, and then iterate through the list, like so:
for sprite in <sprite_group>:
sprite.<attribute> = <input>
Another important thing is that you should really be using raw_input. This probably won't affect your performance, but raw_input really is much better. To get an input string, just use this code:
myvariable = raw_input("enter text input: ")
this will give you a prompt of "enter text input: " and will return the text that is inputted.
Upvotes: 1