Commit ddef40f6 authored by Tošner, Jan's avatar Tošner, Jan
Browse files

v1.1

- malá optimalizace
- přidaná možnost variabilní velikosti obrazovky
--stačí změnit hodnoty SCREEN_WIDTH a SCREEN_HEIGHT
parent 4d46d05d
......@@ -94,7 +94,7 @@ class Game:
book.load()
else:
selected = book.select(x, y)
else:
elif not in_menu and not in_book:
if event.button == 4:
if picture.extend <= MAXIMAL_ZOOM:
picture.extend += 0.5
......@@ -108,9 +108,9 @@ class Game:
elif l == 1:
if selected >= 0:
picture.put(book.blocks[selected], (x, y))
if m == 1:
pygame.mouse.get_rel()
moving = True
if m == 1:
pygame.mouse.get_rel()
moving = True
if moving and event.type == pygame.MOUSEBUTTONUP:
l, m, r = pygame.mouse.get_pressed()
if m == 0:
......@@ -142,16 +142,18 @@ class Picture:
def __init__(self):
self.pos = (0, 0)
self.extend = 1
self.surf = pygame.Surface((1920, 1080))
self.pic = pygame.Surface((960, 544))
self.ratio = (1, 1)
self.surf = pygame.Surface((SCREEN_WIDTH, SCREEN_HEIGHT))
self.pic = pygame.Surface((1920, 1072))
self.pic.fill(WHITE_COLOR)
self.shown = self.pic.copy()
def scale(self):
return pygame.transform.scale(self.shown, (int(1920 * self.extend), int(1080 * self.extend)))
return pygame.transform.scale(self.shown, (int(SCREEN_WIDTH * self.extend), int(SCREEN_HEIGHT * self.extend)))
def load(self, path):
self.pic = pygame.image.load(path)
self.ratio = ((SCREEN_WIDTH/self.pic.get_width()), (SCREEN_HEIGHT/self.pic.get_height()))
self.shown = self.pic.copy()
def move(self, pos):
......@@ -176,7 +178,6 @@ class Picture:
self.pos = (0, 0)
def print(self, screen):
self.surf.fill(BLACK_COLOR)
self.surf.blit(self.scale(), self.pos)
screen.blit(self.surf, (0, 0))
......@@ -195,7 +196,7 @@ class Picture:
def put(self, img, cord):
x, y = cord
xp, yp = self.pos
cord = (((x-xp)//(32*self.extend))*16, ((y-yp)//(32*self.extend))*16)
cord = (((x - xp)//(16 * self.ratio[0] * self.extend))*16, ((y - yp)//(16 * self.ratio[0] * self.extend))*16)
img.draw(self.pic, cord)
self.shown = self.pic.copy()
......@@ -203,7 +204,7 @@ class Picture:
self.shown = self.pic.copy()
x, y = cord
xp, yp = self.pos
cord = (((x - xp) // (32 * self.extend)) * 16, ((y - yp) // (32 * self.extend)) * 16)
cord = (((x - xp)//(16 * self.ratio[0] * self.extend))*16, ((y - yp)//(16 * self.ratio[1] * self.extend))*16)
img.draw(self.shown, cord)
def stop_preview(self):
......@@ -313,7 +314,6 @@ class Block:
surf.blit(self.icon, cord)
pygame.init()
new_game = Game("images/GUI/frame.png", SCREEN_TITLE, SCREEN_WIDTH, SCREEN_HEIGHT)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment