I am currently creating a game in which (for now) the score gains 1 point every second.
However, with my current code (which I believe DOES change the variable every second) whenever I run the program, the text doesn't change. It just stays at 0.
Here is my code: (I've provided text in this question to explain my code, like comments.)
SECTION 1: Importing PyGame and other standard procedure code.
import sys, pygame
from pygame.locals import *
pygame.init()
size = width, height = 800,500
screen = pygame.display.set_mode(size)
SECTION 2: Setting the window caption and a color variable.
pygame.display.set_caption("One Score (Created by - Not Really Working Lamp Productions:)")
WHITE = (255,255,255)
SECTION 3: Declaring the variable "score". I've given it a separate code sample, because it's heavily involved with the problem.
score = 0
SECTION 4: Filling the screen and declaring the default font variable.
screen.fill (WHITE)
myfont = pygame.font.SysFont("monospace", 16)
SECTION 5: Disclaimer Text (Or is it claimer text, I'm not quite sure.)
disclaimertext = myfont.render("Copyright, 2013, Not Really Working Lamp Productions.", 1, (0,0,0))
screen.blit(disclaimertext, (5, 480))
SECTION 6: Adding the score text (POSSIBLY THE MOST CRUCIAL PART.)
scoretext = myfont.render("Score = "+str(score), 1, (0,0,0))
screen.blit(scoretext, (5, 10))
SECTION 7: The while loop (POSSIBLY THE MOST CRUCIAL PART.)
while 1:
for event in pygame.event.get():
pygame.display.flip()
if event.type == pygame.QUIT:sys.exit()
pygame.time.wait(100)
score = score + 1
So where in my code do I put what? (I need the screen to constantly update the score as it changes every second from the "while 1:" loop.)
Thank you.