Skip to content

Instantly share code, notes, and snippets.

@nasajpledu
Created September 9, 2021 23:57
Show Gist options
  • Save nasajpledu/34e5cef1b2278862267ecd96ce13bca5 to your computer and use it in GitHub Desktop.
Save nasajpledu/34e5cef1b2278862267ecd96ce13bca5 to your computer and use it in GitHub Desktop.
class GameObject:
def __init__(self, image_path, x, y, width, height):
# Player image import and resize
object_image = pygame.image.load(image_path)
self.image = pygame.transform.scale(object_image, (width, height))
self.x_pos = x
self.y_pos = y
self.width = width
self.height = height
# Draw the object by blitting it onto the background(game_screen)
def draw(self, background):
background.blit(self.image, (self.x_pos, self.y_pos))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment