Adding points every second independent from the rest of the program
I would use a custom event to do this. See the following:
import pygame
from pygame.constants import *
#initialise pygame
pygame.init()
screen=pygame.display.set_mode((100,100))
screen.fill((255,255,255))
font=pygame.font.SysFont("Verdana",10)
#variables
bal=0
autoclickers=0
running=True
#create custom event. Note that you have to use USEREVENT+1 for the following event, +2 for the next...
secondpassed=USEREVENT
pygame.time.set_timer(secondpassed,1000)
while running:
for event in pygame.event.get():
if event.type==QUIT:
running=False
elif event.type==KEYDOWN and event.key==K_RETURN:
#enter pressed
bal+=1
elif event.type==secondpassed:
#event passed, add autoclickers
bal+=autoclickers
elif event.type==MOUSEBUTTONDOWN and bal>5:
#autoclicker bought
autoclickers+=1
bal-=5
#render amount of balls
screen.fill((255,255,255))
balls=font.render("balls: "+str(bal),False,(0,0,0))
screen.blit(balls,(0,0))
pygame.display.update()
pygame.quit()
Note that this does not schedule a timer upon an autoclicker is bought, so the time between the buying and the first ball gain will be less then 1 second. After that, it will be 1 second.