Hi im new to python and am trying to make a simple tank game where I want the tank gun to follow the position of the mouse cursor. Im am having some trouble in doing this. Below is my code. Whenever I run I get an error. So far I want the idle screen to print out the position of the mouse and display the co-ordinates. I can get the mouse button down function to work but not the mouse position. Any ideas please. Again I am new to Python.
def mouse_position():
running = True
while running:
for event in pygame.event.get():
#if event.type == pygame.MOUSEBUTTONDOWN:
#mosdown = pygame.mouse.get_pos()
#print(mosdown)
if event in pygame.event.get_rel():
mospos = pygame.mouse.get_rel()
print(mospos)