-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTask_2 Zoom
More file actions
50 lines (44 loc) · 1.26 KB
/
Task_2 Zoom
File metadata and controls
50 lines (44 loc) · 1.26 KB
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
import os
import sys
import pygame
import requests
def get_picture(x, y, z=10):
if z > 18:
z = 18
if z < 1:
z = 1
up = z
FPS = 60
map_request = s = f'https://static-maps.yandex.ru/1.x/?ll={x}%2C{y}&size=450,450&z={z}&l=map'
response = requests.get(map_request)
fullscreen = False
width = 600
height = 350
pygame.init()
map_file = "map.png"
with open(map_file, "wb") as file:
file.write(response.content)
pygame.init()
screen = pygame.display.set_mode((600, 450))
screen.blit(pygame.image.load(map_file), (0, 0))
pygame.display.set_caption('Австралия')
pygame.display.flip()
running = True
while running:
screen.fill((255, 255, 255))
for event in pygame.event.get():
keys = pygame.key.get_pressed()
if event.type == pygame.QUIT:
running = False
if keys[pygame.K_PAGEUP]:
up -= 1
get_picture(x, y, up)
if keys[pygame.K_PAGEDOWN]:
up += 1
get_picture(x, y, up)
img = pygame.image.load('Map.png')
screen.blit(img, (0, 0))
pygame.display.flip()
pygame.quit()
os.remove(map_file)
get_picture(57, 57, 1)