I'm trying to recreate the chrome no internet dino game inside pygame/python. But whenever I run it it instead of creating the main file window it creates the image window from the sprite sheet file. Don't know what I'm doing wrong here.
main file:
# importing the other file where the spritesheet class is
from SpriteSheet import SpriteSheet
import pygame
pygame.init()
SW = 500
SH = 500
win = pygame.display.set_mode((SW, SH))
SPRITE_SHEET = pygame.image.load('sheet.png')
# mainloop
run = True
while run:
# checking for clicking the x button
for event in pygame.event.get():
if event.type == pygame.QUIT:
run = False
# cropping the image from the spritesheet
spritesheet = SpriteSheet(SPRITE_SHEET)
image = spritesheet.get_image(
848, 2, 44, 47, (255, 255, 255))
win.blit(image, (0, 0))
sprite sheet file:
import pygame
# creating the class
class SpriteSheet(object):
SpriteSheet = None
# getting the spritesheet
def __init__(self, sheet):
self.SpriteSheet = sheet
# cropping the image
def get_image(self, x, y, width, height, color):
image = pygame.display.set_mode([width, height])
image.blit(self.SpriteSheet, (0, 0), (x, y, width, height))
image.set_colorkey(color)
return image