Nov-28-2017, 02:14 PM
My friend wrote a program that displays an amount of dots (like a dice would), and pauses when you click. I tried to edit this code to use images - but it isn't working. I'm getting an error about putting the images on the screen, even though I've been able to do it in previous programs. Any help? :)
import pygame, sys, random, time pygame.init() done = False size = 500, 500 screen = pygame.display.set_mode(size) WHITE = 255, 255, 255 coords = 225, 255 one = pygame.image.load('one.png').convert two = pygame.image.load('two.png').convert three = pygame.image.load('three.png').convert four = pygame.image.load('four.png').convert five = pygame.image.load('five.png').convert six = pygame.image.load('six.png').convert def one(): screen.blit(one, coords) def two(): screen.blit(two, coords) def three(): screen.blit(three, coords) def four(): screen.blit(four, coords) def five(): screen.blit(five, coords) def six(): screen.blit(six, coords) while done == False: rolled = False for event in pygame.event.get(): if event.type == pygame.QUIT: done = True pygame.quit() while not rolled: screen.fill(WHITE) random.choice([one, two, three, four, five, six])() pygame.display.flip() time.sleep(0.18) for event in pygame.event.get(): if event.type == pygame.MOUSEBUTTONDOWN: rolled = True screen.fill(WHITE) random.choice([one, two, three, four, five, six])() pygame.display.flip() time.sleep(2.5)
Error:Traceback (most recent call last):
File "H:/CODE/dice/dice code 2.py", line 49, in <module>
screen.blit(one, coords)
TypeError: argument 1 must be pygame.Surface, not function