0

I'm working on a timer template for use in my games that I create. This is the code I have for a timer module (haven't put it into a class yet)

import time
import math
import pygame
from livewires import games, color
timer = 0

games.init(screen_width = 640, screen_height = 480, fps = 50)

gamefont = pygame.font.Font(None, 30)
timertext = gamefont.render('Timer: ' +str(timer), 1, [255,0,0])
screen.blit(timertext, [scoreXpos,20])

Eventually, I'm going to have a live timer which is why I use the the render and blit methods, but for now, I just have a static variable called timer set equal to 0. When I run this program however, I get an error that says "Cannot have more than on screen object." I'm really confused because I don't think I've ever seen this error before, and definitely don't know what it means, or how to fix it. If someone could help me understand what's happening, I would very much appreciate it. Also, the reason I've imported games and color from livewires, is to use it for another purpose later on in the code.

emufossum13
  • 377
  • 1
  • 10
  • 21

1 Answers1

0

The exception is raised by the Screen class of livewires.

...
class Screen(object): 

    initialized = 0 

    def __init__ (self, width=640, height=480, fps=50): 
        # Bomb if you try this more than once
        if Screen.initialized: 
            raise GamesError("Cannot have more than on Screen object")

        Screen.initialized = 1
...

You didn't show your entire code, so I guess you created a second instance of the Screen class somewhere.

sloth
  • 99,095
  • 21
  • 171
  • 219