# Import Libraries import os, sys import pygame from pygame.locals import * from urllib.request import urlopen from urllib.request import Request import urllib.error def download_art(): file_link = "https://datasets-server.huggingface.co/assets/mswhite/artwork/--/mswhite--artwork/train/0/image/image.jpg" file_name = "new_art.jpg" try: req = Request(file_link) req.add_header('User-Agent', 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.130 AOL/9.8 AOLBuild/4346.2019.US Safari/537.36') remotefile = urlopen(req) localfile = open(file_name, 'wb') localfile.write(remotefile.read()) localfile.close() remotefile.close() except urllib.error.HTTPError as e: print('ERROR: ',e.code,' REASON: ',e.reason, " => ",file_link) # Url = e.url # Initialize Game Engine / screen pygame.init() screen = pygame.display.set_mode((0, 0), pygame.FULLSCREEN) art_image = "new_art.jpg" download_art() image = pygame.image.load(art_image) infoObject = pygame.display.Info() pygame.display.set_mode((infoObject.current_w, infoObject.current_h)) window_width = infoObject.current_w window_height = infoObject.current_h image_width = image.get_width() image_height = image.get_height() scale_factor = min(window_width / image_width, window_height / image_height) DEFAULT_IMAGE_SIZE = (image_width * scale_factor, image_height * scale_factor) background_img = pygame.transform.scale(image, DEFAULT_IMAGE_SIZE) offset = int((window_width * 0.5) - 0.5 * (image_width * scale_factor)) # -------------------------- # Main Loop while True: # Handle Events for event in pygame.event.get(): if event.type == KEYDOWN and (event.key in [K_ESCAPE, K_q]): sys.exit(0) elif event.type == KEYDOWN and event.key in [K_UP,K_DOWN,K_RIGHT,K_b,K_d]: pass # Mouse is held down if pygame.mouse.get_pressed()[0]: pass # Refresh Screen screen.fill(pygame.color.THECOLORS["black"]) screen.blit(background_img, (offset,0)) pygame.display.flip() # sys.exit(0)