|
|
|
@ -566,7 +566,155 @@ class Atomisti:
@@ -566,7 +566,155 @@ class Atomisti:
|
|
|
|
|
pygame.display.update() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Matrix: |
|
|
|
|
'''Bullet time with Mr. Descartes and Mr. Smith''' |
|
|
|
|
def __init__(self, screen, settings, clock): |
|
|
|
|
self.settings = settings |
|
|
|
|
self.screen = screen |
|
|
|
|
self.clock = clock |
|
|
|
|
self.player_img = pygame.image.load("assets/other/real_neo.png") |
|
|
|
|
self.img_intro = pygame.image.load("assets/other/matrix_intro2.png") |
|
|
|
|
self.img_bg = pygame.image.load("assets/other/matrix_bg.png") |
|
|
|
|
|
|
|
|
|
self.name = "Matrix" |
|
|
|
|
self.task_type = "Matrix" |
|
|
|
|
self.done = False |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def matrix(self): |
|
|
|
|
player_pos = [self.settings['window_size'][0]//2, self.settings['window_size'][1]//2] |
|
|
|
|
controls = self.settings['controls'] |
|
|
|
|
walk_r = False |
|
|
|
|
walk_l = False |
|
|
|
|
walk_d = False |
|
|
|
|
walk_u = False |
|
|
|
|
player_rect = self.player_img.get_rect() |
|
|
|
|
|
|
|
|
|
bullets = [] |
|
|
|
|
bullet = { |
|
|
|
|
"x": 0, |
|
|
|
|
"y": 0, |
|
|
|
|
"vx": 0, |
|
|
|
|
"vy": 0, |
|
|
|
|
"rect": pygame.rect.Rect(0, 0, 20, 20) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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: |
|
|
|
|
sys.exit() |
|
|
|
|
# check if a key was pressed |
|
|
|
|
elif event.type == pygame.KEYDOWN: |
|
|
|
|
if event.type == pygame.KEYDOWN: |
|
|
|
|
if event.key in controls['right']: |
|
|
|
|
walk_r = True |
|
|
|
|
if event.key in controls['left']: |
|
|
|
|
walk_l = True |
|
|
|
|
if event.key in controls['down']: |
|
|
|
|
walk_d = True |
|
|
|
|
if event.key in controls['up']: |
|
|
|
|
walk_u = True |
|
|
|
|
# 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 controls['right']: |
|
|
|
|
walk_r = False |
|
|
|
|
if event.key in controls['left']: |
|
|
|
|
walk_l = False |
|
|
|
|
if event.key in controls['down']: |
|
|
|
|
walk_d = False |
|
|
|
|
if event.key in controls['up']: |
|
|
|
|
walk_u = False |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
player_pos[0] += 15 if walk_r else 0 |
|
|
|
|
player_pos[0] -= 15 if walk_l else 0 |
|
|
|
|
player_pos[1] += 15 if walk_d else 0 |
|
|
|
|
player_pos[1] -= 15 if walk_u else 0 |
|
|
|
|
player_rect.x = player_pos[0] |
|
|
|
|
player_rect.y = player_pos[1] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if player_pos[0] < 0: |
|
|
|
|
player_pos[0] = 0 |
|
|
|
|
elif player_pos[0] > self.settings['window_size'][0] - self.player_img.get_width(): |
|
|
|
|
player_pos[0] = self.settings['window_size'][0] - self.player_img.get_width() |
|
|
|
|
if player_pos[1] < 0: |
|
|
|
|
player_pos[1] = 0 |
|
|
|
|
elif player_pos[1] > self.settings['window_size'][1] - self.player_img.get_height(): |
|
|
|
|
player_pos[1] = self.settings['window_size'][1] - self.player_img.get_height() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 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_bg, (0,0)) |
|
|
|
|
task_window.blit(self.player_img, player_pos) |
|
|
|
|
# blit task window on screen |
|
|
|
|
self.screen.blit(task_window, (0,0)) |
|
|
|
|
pygame.display.update() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def do_task(self, results): |
|
|
|
|
'''open screen with task''' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dialog1_texts = [ |
|
|
|
|
"Smith: We meet again Mr. Descartes.", |
|
|
|
|
"Descartes: Oh hi! What a lovely sunny day, isn't it?", |
|
|
|
|
"Smith: Huh? Are you aware that you are inside a computer? There is no sun in here!", |
|
|
|
|
"Smith: Seriously, it is time for you to wake up into reality!" |
|
|
|
|
] |
|
|
|
|
dialog1_done = False |
|
|
|
|
dialog1_index = 0 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 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: |
|
|
|
|
if dialog1_index < len(dialog1_texts) - 1: |
|
|
|
|
dialog1_index += 1 |
|
|
|
|
else: |
|
|
|
|
dialog1_done = True |
|
|
|
|
self.matrix() |
|
|
|
|
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_intro, (0,0)) |
|
|
|
|
# blit task window on screen |
|
|
|
|
if not dialog1_done: |
|
|
|
|
display_text(self.settings, task_window, dialog1_texts[dialog1_index]) |
|
|
|
|
self.screen.blit(task_window, (0,0)) |
|
|
|
|
pygame.display.update() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|