File size: 2,261 Bytes
98454cc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# 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)