im working on a tron game with pygame and i cant figure out how to make my tail that the player's car makes disappear after somany pixels. i want the tail to start shortening itself after like 500 pixels. if you can, can you post the full code edited (im kinda a noob at pygame)
thanks
import sys, random, time, pygame
from pygame.locals import *
def print_text(font, x, y, text, color=(255,255,255)):
imgText = font.render(text, True, color)
screen.blit(imgText, (x,y))
#main program begins
pygame.init()
w = 500
h = 500
screen = pygame.display.set_mode((w,h))
pygame.display.set_caption("Tron")
font1 = pygame.font.Font(None, 24)
pygame.mouse.set_visible(False)
white = 255,255,255
red = 220, 50, 50
yellow = 230,230,50
black = 0,0,0
pos_x = 300
pos_y = 460
p1 = [[300],[460]]
poss = pos_y,pos_x
print p1
screen.fill(black)
vel_y = 0.7
path = 8 # 8=up 6=right 4=left 2=down
#repeating loop
while True:
for event in pygame.event.get():
#Keydown
if event.type == KEYDOWN:
if event.key == K_ESCAPE:
pygame.quit()
sys.exit()
if event.key == K_UP and path != 2:
path = 8
if event.key == K_RIGHT and path != 4:
path = 6
if event.key == K_LEFT and path != 6:
path = 4
if event.key == K_DOWN and path != 8:
path = 2
if path == 8:
pos_y -= 1
elif path == 6:
pos_x += 1
elif path == 4:
pos_x -= 1
elif path == 2:
pos_y += 1
p1[0].append(pos_x)
p1[1].append(pos_y)
if pos_y <= 0 or pos_y >= h or pos_x <= 0 or pos_x >= w:
pygame.quit()
sys.exit()
if len(p1[0]) == 10:
pygame.time.delay(10)
pos = pos_x,pos_y,10,10
#print pos
pygame.draw.rect(screen, white, pos, 0)
pygame.display.update()