im trying to get this script to draw a line from the center of the rectangle to the mouse BUT i only want it to draw about 10 pixels out. how can i find that point that is 10 pixels(or points) out?
code so far:

``````import pygame
from pygame.locals import *
import math
pygame.init()
screen = pygame.display.set_mode((640, 480))

red = (255,0,0)
green = (0,255,0)
blue = (0,0,255)
darkBlue = (0,0,128)
white = (255,255,255)
black = (0,0,0)
pink = (255,200,200)

x = 5
y = 5
delta = 0

running = 1

while running:
for event in pygame.event.get():
if event.type == QUIT:
running = 0
#elif event.type == KEYDOWN and event.key == K_w:
#print "key"
#else:
#print event
#a = 1
keystate = pygame.key.get_pressed()
if keystate[K_w]:
y-=1
if keystate[K_d]:
x+=1
elif keystate[K_a]:
x-=1
elif keystate[K_s]:
y+=1
if keystate[K_d]:
x+=1
elif keystate[K_a]:
x-=1
elif keystate[K_a]:
x-=1
elif keystate[K_d]:
x+=1
screen.fill((120, 120, 120))
myfont = pygame.font.SysFont("monospace", 12)

mouse = pygame.mouse.get_pos()

pygame.draw.rect(screen, red, (x,y,10,10), 0)
pygame.draw.line(screen, blue, [x+5,y+5], [mouse,mouse])
pygame.display.flip()

pygame.quit()
``````

I've gotten a little closer i think:

``````(dx, dy) = (mouse-(x+5), mouse-(y+5))
print str(degs) + " " + str(float(dx)) + " " + str(float(dy))
pygame.draw.rect(screen, red, (x,y,10,10), 0)#tank
#pygame.draw.rect(screen, red, (x+5,y+5,10,10), 0)#turret
pygame.draw.line(screen, blue, [x+5,y+5], [(5*math.cos(degs*(math.pi/180))),(5*math.sin(degs*(math.pi/180)))])
print (5*math.cos(degs*(math.pi/180))),(5*math.sin(degs*(math.pi/180)))
``````

a little closer... i think

``````  (dx, dy) = (mouse-(x+5), mouse-(y+5))