0
\$\begingroup\$

I'm making a game with pygame and I wanted to add a background for my game. I'm trying to add a 1920x1080 background to a 1920x1080 screen, but part of the background is not visible.

My code:

import pygame
import sys

pygame.init()

screen = pygame.display.set_mode((1920, 1080))

bg_img = pygame.image.load("wp.jpg").convert()

clock = pygame.time.Clock()

while True:
    screen.blit(bg_img, (0, 0))
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            pygame.quit()
            sys.exit(0)
    pygame.display.update()
    clock.tick(60)

wp.jpg: enter image description here

Result: enter image description here

\$\endgroup\$
3
  • \$\begingroup\$ Maybe it depends on your screen resolution. Is your screen resolution 1920x1080 too? \$\endgroup\$
    – Mangata
    May 16 at 17:25
  • 2
    \$\begingroup\$ Are you on Windows? Is your display scaled by your OS? You don't pass any parameter to your set_mode function so I assume you have a frame around your game, if that's so, maybe the size you request is the size of the window, not the size of the surface you'll be able to draw on, and the image is clipped? \$\endgroup\$
    – Vaillancourt
    May 16 at 17:26
  • \$\begingroup\$ Hi, my screen resolution 1920x1080 too. Im on Windows. I don't have any frame around game. It's fullscreen when i use screen = pygame.display.set_mode((1920, 1080)) or screen = pygame.display.set_mode((1920, 1080), pygame.FULLSCREEN) and image is not clipped. \$\endgroup\$
    – Furkan125
    May 16 at 17:58

1 Answer 1

0
\$\begingroup\$

I fixed the problem by changing my code to:

import pygame
import sys

pygame.init()

screen = pygame.display.set_mode((0, 0), pygame.FULLSCREEN|pygame.NOFRAME)

bg_img = pygame.image.load("wp.jpg").convert()

clock = pygame.time.Clock()

while True:
    screen.blit(bg_img, (0, 0))
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            pygame.quit()
            sys.exit(0)
    pygame.display.update()
    clock.tick(60)
\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .