3

I want to create a game in pygame but want it to have pixelated graphics, so instead of resizing a pixelated image, i was hoping to just change the resolution of the pygame screen .

screen = pygame.display.set_mode((width, height))

Thanks.

Nipun Thennakoon
  • 3,586
  • 1
  • 18
  • 26
Thomas Ayling
  • 95
  • 2
  • 10

1 Answers1

2

Make two screens. One with your desired resolution( let's call screen) and the other with your desired screen size(let's call window). Then blit screen into window while scaling it to the size of the window.

window.blit(pygame.transform.scale(screen,(windoWidth,windowHeight)),(0,0))

That should work.

EDIT: As the Ted's comments suggests it will be more easy to understand like this.

resized_screen = pygame.transform.scale(screen, (windoWidth,windowHeight)) 
window.blit(resized_screen, (0, 0))
Nipun Thennakoon
  • 3,586
  • 1
  • 18
  • 26
  • I know this changes the size of the screen but I want to change the resolution, so how many pixels are on the screen not how tall/wide the screen is – Thomas Ayling Jul 09 '18 at 11:23
  • 1
    I think it would be clearer if you divided the code in several lines instead of having a one-liner, i.e. `resized_screen = pygame.transform.scale(screen, (windoWidth,windowHeight))` and `window.blit(resized_screen, (0, 0))`. – Ted Klein Bergman Jul 09 '18 at 13:07
  • could you tell me what happened? was there errors or simply resoultion didn't change? – Nipun Thennakoon Jul 10 '18 at 11:41
  • 1
    Remember to clear `screen` with `screen.fill(bgcolor)` or blit a background to it, then draw to `screen`, then blit `screen` to `window`, and finally call `pygame.display.update()`. If you do all of that in that order in the game loop, this method should work. – SnootierBaBoon Jul 11 '18 at 19:46