0

I'm fairly new to pygame and I'm working on making a tic tac toe game. So far I've added a 220 x 221 image of a tic tac toe board as a layer over a pygame window. My issue is that I originally had the window set to 1200 x 800 (I was messing around with the window before I started working on the game) and when I added the image over the window, it appeared instantly without a problem. I decided to change the window size down to 220 x 221 to fit the picture but once I did that, the picture wouldn't load/appear. I tried random sizes for the window such as 820 x 821 but the image still wouldn't show. I've also tried other IDE's that came with the OS installed on my Raspberry pi but It would only show on a 1200 x 800 window. Here's my non-functioning code so far:

import pygame
pygame.init()

black = (0,0,0)
board = pygame.image.load(r'/home/pi/Pictures/TicTacToeBoard.jpg')
display = pygame.display.set_mode((220, 221))

while True:
    display.fill(black)
    display.blit(board, (0,0))
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            pygame.quit()
            quit()
BPotter
  • 21
  • 2
  • 4
  • Does this answer your question? [Pygame. How do I resize a surface and keep all objects within proportionate to the new window size?](https://stackoverflow.com/questions/34910086/pygame-how-do-i-resize-a-surface-and-keep-all-objects-within-proportionate-to-t) – stovfl Dec 26 '19 at 11:14

1 Answers1

0

I don't think the problem is the size of the window. Besides, it does not seem possible your board image was ever drawn with this code since you have to flip() or update() the pygame display! At one point that part was lost? Apart from this, you need to stop the loop for a little time, or the sequence between fill (in black) and drawing the image will be too short.

Try this and check what happens now:

import pygame
import time

pygame.init()

black = (0,0,0)
board = pygame.image.load(r'/home/pi/Pictures/TicTacToeBoard.jpg')
display = pygame.display.set_mode((220, 221))

while True:
    display.fill(black)
    display.blit(board, (0,0))
    pygame.display.flip()
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            pygame.quit()
            quit()
    time.sleep(0.2)
Kalma
  • 111
  • 2
  • 15