Hellooooo, I'm totaly new to programming and just started reading some tutorials for python.
I use the Pyglet library.
I know how to blit images to a window and how to make text come up when I push buttons. And I've managed to make an image move across the screen slowly. I also understand if, else if, and else, and while loops.
I'm still trying to figure out how classes work and how I can add variables to ranges, though.
My problem is, I want to try and make an image move when I push the left and right arrow keys. And... It dosn't work.
Code:
import pyglet
from pyglet import image
from pyglet import window
win = window.Window()
img = image.load('image directory')
s = 50
def img_move(direction, s):
s = s
win.clear()
img.blit(s, 0)
win.flip()
if direction == key.RIGHT:
s + 50
return img_move()
elif direction == key.LEFT:
s - 50
return img_move()
else:
return img_move()
win.img_move = img_move
while not win.has_exit:
win.dispatch_events()