|
|
|
@ -1,7 +1,212 @@
@@ -1,7 +1,212 @@
|
|
|
|
|
#!/usr/bin/env python3 |
|
|
|
|
|
|
|
|
|
from tkinter.tix import Tree |
|
|
|
|
import pygame, sys |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def display_text(settings, screen, text): |
|
|
|
|
WIDTH, HEIGHT = settings['window_size'] |
|
|
|
|
bg = pygame.Surface((WIDTH-20, 100)) |
|
|
|
|
bg.set_alpha(128) |
|
|
|
|
pygame.draw.rect(bg, (255, 255, 255), (0, 0, WIDTH-20, 100), 0, 5) |
|
|
|
|
pygame.draw.rect(bg, (0, 0, 0), (5, 5, WIDTH-30, 90), 0, 5) |
|
|
|
|
screen.blit(bg, (10, HEIGHT-105)) |
|
|
|
|
font = pygame.font.SysFont("Sans Serif", 45) |
|
|
|
|
text_label = font.render(text, 1, (255, 255, 255)) |
|
|
|
|
screen.blit(text_label, (30, HEIGHT-95)) |
|
|
|
|
|
|
|
|
|
class Diogenes: |
|
|
|
|
'''Move Alexander away''' |
|
|
|
|
def __init__(self, screen, settings, clock): |
|
|
|
|
self.settings = settings |
|
|
|
|
self.screen = screen |
|
|
|
|
self.clock = clock |
|
|
|
|
self.img = pygame.image.load("assets/other/Diogenes.png") |
|
|
|
|
self.alex_img = pygame.image.load("assets/other/alex.png") |
|
|
|
|
|
|
|
|
|
self.name = "Move Alex" |
|
|
|
|
self.task_type = "Diogenes" |
|
|
|
|
self.done = False |
|
|
|
|
|
|
|
|
|
def do_task(self): |
|
|
|
|
'''open screen with task''' |
|
|
|
|
|
|
|
|
|
alex_x = 600 |
|
|
|
|
alex_rect = pygame.Rect((600, 50), (250, 670)) |
|
|
|
|
alex_hold = False |
|
|
|
|
|
|
|
|
|
dialog_texts = [ |
|
|
|
|
"Alex: Hey, don't wou want to improve your life? I can give you anything you want.", |
|
|
|
|
"Diogenes: Just move away, you are blocking the sun.", |
|
|
|
|
"Alex: Ok, sure" |
|
|
|
|
] |
|
|
|
|
dialog_index = 0 |
|
|
|
|
dialog_active = True |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# main loop of task |
|
|
|
|
while not self.done: |
|
|
|
|
self.clock.tick(self.settings['FPS']) |
|
|
|
|
# parse events |
|
|
|
|
for event in pygame.event.get(): |
|
|
|
|
# check if window is closed |
|
|
|
|
if event.type == pygame.QUIT: |
|
|
|
|
exit_sig = True |
|
|
|
|
sys.exit() |
|
|
|
|
# check if a key was pressed |
|
|
|
|
elif event.type == pygame.KEYDOWN: |
|
|
|
|
# exit task when ESC is pressed |
|
|
|
|
if event.key == pygame.K_ESCAPE: |
|
|
|
|
# status 1 indicates task isn't finished |
|
|
|
|
return 1 |
|
|
|
|
# check if a key was released |
|
|
|
|
elif event.type == pygame.KEYUP: |
|
|
|
|
if event.key in self.settings['controls']['right']: |
|
|
|
|
pass |
|
|
|
|
elif event.type == pygame.MOUSEBUTTONDOWN: |
|
|
|
|
if dialog_active: |
|
|
|
|
if dialog_index < len(dialog_texts) - 1: |
|
|
|
|
dialog_index += 1 |
|
|
|
|
else: |
|
|
|
|
dialog_active = False |
|
|
|
|
# check if mouse is holding alex |
|
|
|
|
elif alex_rect.collidepoint(event.pos): |
|
|
|
|
alex_hold = True |
|
|
|
|
elif event.type == pygame.MOUSEBUTTONUP: |
|
|
|
|
# release alex, create new hitbox in its position |
|
|
|
|
alex_rect = pygame.Rect((alex_x, 50), (250, 630)) |
|
|
|
|
alex_hold = False |
|
|
|
|
|
|
|
|
|
# move alex with mouse |
|
|
|
|
cur_pos = pygame.mouse.get_pos() |
|
|
|
|
if alex_hold: |
|
|
|
|
# don't go too far left |
|
|
|
|
if cur_pos[0] > 700: |
|
|
|
|
alex_x = 600 |
|
|
|
|
else: |
|
|
|
|
# reset if alex reached destination |
|
|
|
|
if cur_pos[0] < 300: |
|
|
|
|
alex_hold = False |
|
|
|
|
return 0 |
|
|
|
|
else: |
|
|
|
|
alex_x = cur_pos[0]-100 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# draw stuff into task window |
|
|
|
|
task_window = pygame.Surface((self.settings['window_size'][0], self.settings['window_size'][1])) |
|
|
|
|
task_window.fill((255,0,0)) |
|
|
|
|
task_window.blit(self.img, (0,0)) |
|
|
|
|
task_window.blit(self.alex_img, (alex_x, 0)) |
|
|
|
|
# blit task window on screen |
|
|
|
|
if dialog_active: |
|
|
|
|
display_text(self.settings, task_window, dialog_texts[dialog_index]) |
|
|
|
|
self.screen.blit(task_window, (0,0)) |
|
|
|
|
pygame.display.update() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Pytagoras: |
|
|
|
|
'''Move Alexander away''' |
|
|
|
|
def __init__(self, screen, settings, clock): |
|
|
|
|
self.settings = settings |
|
|
|
|
self.screen = screen |
|
|
|
|
self.clock = clock |
|
|
|
|
self.img = pygame.image.load("assets/other/Pytagoras.png") |
|
|
|
|
self.kospi_img = pygame.image.load("assets/other/kospi.png") |
|
|
|
|
|
|
|
|
|
self.name = "Pytagoras" |
|
|
|
|
self.task_type = "Pytagoras" |
|
|
|
|
self.done = False |
|
|
|
|
|
|
|
|
|
def do_task(self): |
|
|
|
|
'''open screen with task''' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dialog2_correct_texts = [ |
|
|
|
|
"Kosper: Priatel, tesim sa!", |
|
|
|
|
"Pythagoras: Oh right, how could I forget.", |
|
|
|
|
] |
|
|
|
|
dialog2_incorrect_texts = [ |
|
|
|
|
"Kosper: Uu! Priatel, toto je chyba!", |
|
|
|
|
"Pytagoras: Hmm, I'll have to think about it a bit more." |
|
|
|
|
] |
|
|
|
|
dialog2_index = 0 |
|
|
|
|
dialog2_active = False |
|
|
|
|
|
|
|
|
|
option1 = pygame.rect.Rect((425, 81), (215, 217)) |
|
|
|
|
option2 = pygame.rect.Rect((713, 81), (217, 217)) |
|
|
|
|
|
|
|
|
|
dialog1_text = "Pythagoras: Yesterday I found a formula but I can't remember which one it was." |
|
|
|
|
dialog1_done = False |
|
|
|
|
|
|
|
|
|
kosper_on_scene = False |
|
|
|
|
dialog2_active = False |
|
|
|
|
|
|
|
|
|
# main loop of task |
|
|
|
|
while not self.done: |
|
|
|
|
self.clock.tick(self.settings['FPS']) |
|
|
|
|
# parse events |
|
|
|
|
for event in pygame.event.get(): |
|
|
|
|
# check if window is closed |
|
|
|
|
if event.type == pygame.QUIT: |
|
|
|
|
exit_sig = True |
|
|
|
|
sys.exit() |
|
|
|
|
# check if a key was pressed |
|
|
|
|
elif event.type == pygame.KEYDOWN: |
|
|
|
|
# exit task when ESC is pressed |
|
|
|
|
if event.key == pygame.K_ESCAPE: |
|
|
|
|
# status 1 indicates task isn't finished |
|
|
|
|
return 1 |
|
|
|
|
# check if a key was released |
|
|
|
|
elif event.type == pygame.KEYUP: |
|
|
|
|
if event.key in self.settings['controls']['right']: |
|
|
|
|
pass |
|
|
|
|
elif event.type == pygame.MOUSEBUTTONDOWN: |
|
|
|
|
if not dialog1_done: |
|
|
|
|
dialog1_done = True |
|
|
|
|
elif option1.collidepoint(event.pos) and not kosper_on_scene: |
|
|
|
|
for i in range(380, 0, -20): |
|
|
|
|
task_window.blit(self.img, (0, 0)) |
|
|
|
|
task_window.blit(self.kospi_img, (i, 0)) |
|
|
|
|
self.screen.blit(task_window, (0, 0)) |
|
|
|
|
pygame.display.update() |
|
|
|
|
kosper_on_scene = True |
|
|
|
|
dialog2_texts = dialog2_correct_texts |
|
|
|
|
dialog2_active = True |
|
|
|
|
elif option2.collidepoint(event.pos) and not kosper_on_scene: |
|
|
|
|
for i in range(380, 0, -20): |
|
|
|
|
task_window.blit(self.img, (0, 0)) |
|
|
|
|
task_window.blit(self.kospi_img, (i, 0)) |
|
|
|
|
self.screen.blit(task_window, (0, 0)) |
|
|
|
|
pygame.display.update() |
|
|
|
|
kosper_on_scene = True |
|
|
|
|
dialog2_texts = dialog2_incorrect_texts |
|
|
|
|
dialog2_active = True |
|
|
|
|
elif dialog2_active: |
|
|
|
|
if dialog2_index < len(dialog2_texts) - 1: |
|
|
|
|
dialog2_index += 1 |
|
|
|
|
else: |
|
|
|
|
dialog2_active = False |
|
|
|
|
return 0 |
|
|
|
|
elif event.type == pygame.MOUSEBUTTONUP: |
|
|
|
|
pass |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# draw stuff into task window |
|
|
|
|
task_window = pygame.Surface((self.settings['window_size'][0], self.settings['window_size'][1])) |
|
|
|
|
task_window.fill((255,0,0)) |
|
|
|
|
task_window.blit(self.img, (0,0)) |
|
|
|
|
if kosper_on_scene: |
|
|
|
|
task_window.blit(self.kospi_img, (0,0)) |
|
|
|
|
# blit task window on screen |
|
|
|
|
if not dialog1_done: |
|
|
|
|
display_text(self.settings, task_window, dialog1_text) |
|
|
|
|
if dialog2_active: |
|
|
|
|
display_text(self.settings, task_window, dialog2_texts[dialog2_index]) |
|
|
|
|
self.screen.blit(task_window, (0,0)) |
|
|
|
|
pygame.display.update() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class WinDosXD: |
|
|
|
|
'''Help load WinDos by moving blue bar to right''' |
|
|
|
|
def __init__(self, screen, settings, clock): |
|
|
|
|