Unable to scale images

I am new to Python and got a book that teaches you how to make a game.
I’m enjoying learning and everything so far is going well, except for one snag.
It seems no matter what I try when trying to scale my image to either big or small nothing happens. I have no problem with my background image, but trying to scale (‘stars.png’)
is where I’m having an issue.

import pygame
from pygame import *


game_width = 1100
game_height = 600
game_res = (game_width, game_height)

game_window = display.set_mode(game_res)

bg_img = image.load(‘space-grid.jpg’)
bg_surf = Surface.convert_alpha(bg_img)
bg_scale = transform.scale(bg_surf, game_res)
game_window.blit(bg_img, (0, 0))

my_img = image.load(‘stars.png’)
my_surf = Surface.convert_alpha(my_img)
my_scale = transform.scale(my_surf, (100, 100))
game_window.blit(my_img, (0, 0))

game_running = True
while game_running:
for event in pygame.event.get():
if event.type == QUIT:
game_running = False

Please enclose code and output between lines of triple backticks eg:

 your code
 goes here

This preserves indentation and punctuation, which are critical.

Cameron Simpson cs@cskk.id.au

Sorry for my mistake, I’ll be more aware about that in the future.
I did some more searching around and after trying something a little different, it finally decided to work for me and I was able to size my image to what I needed.

1 Like