Newbie question, I guess.
thedog
thedog at linux.nu
Mon May 7 08:28:47 EDT 2001
Newbie question, I guess.
I have two variables direction and framenr
direction = 'fw'
framenr = 1
which I want to use in the following code to navigate round in my little
game.
keystate = pygame.key.get_pressed()
if keystate[K_UP]:
framenr = framenr + 1
frame = '%(direction)s%(framenr)simage' %vars()
if keystate[K_DOWN]:
framenr = framenr - 1
frame = '%(direction)s%(framenr)simage' %vars()
if keystate[K_RIGHT] or keystate[K_LEFT]: #byter mellan fw och
bw
if direction == 'fw':
direction = 'bw'
frame = '%(direction)s%(framenr)simage' %vars()
else:
direction == 'fw'
frame = '%(direction)s%(framenr)simage' %vars()
the problem is the line: frame = '%(direction)s%(framenr)simage' %vars()
when using this a string is passed to frame(for example, when the up
arrow is pressed: the string fw1image). But I dont want a string to
be passed to it just fw1image, because fw1image is a surface that later
will be shown on screen.
So I want to change fw1image to fw1image, is this possible?
Or if you know any better way of accomplishing this, enlighten me.
PS. Im sorry if the text is confusing, but Im very very tired.
More information about the Python-list
mailing list