-
Notifications
You must be signed in to change notification settings - Fork 0
/
view_solved.py
106 lines (92 loc) · 4.17 KB
/
view_solved.py
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!/usr/bin/env python
# -*- coding:utf-8 -*-
# vim:ts=4:sw=4:expandtab
import pygame
from timer import *
from questions import *
import view_question
import view_end
from pygame.locals import *
# Übersicht: Lösung des Rätsels (Spiel-Cover und -Name in groß)
STATE_SOLVED = 0
# Cover wird klein und bewegt sich nach oben links
STATE_MOVING = 1
# Szenen-Screenshot mit kurzem Text wird angezeigt
STATE_SCENE = 2
class ViewSolved:
def __init__(self, screen, question):
print "initiating view"
self.res = None
self.screen = screen
self.question = question
self.font = pygame.font.Font(None, 32)
self.game_logo = pygame.image.load(question.gamecover)
self.logorect = self.game_logo.get_rect()
self.logorect.centerx = screen.get_rect().centerx
self.logorect.centery = screen.get_rect().centery
self.text = self.font.render("Das war aus: " + question.gametitle, True, (255, 255, 255), (0, 0, 0))
self.textrect = self.text.get_rect()
self.textrect.centerx = screen.get_rect().centerx
self.textrect.top = self.logorect.bottom + 25
self.state = STATE_SOLVED
t = Timer(1000, True, self.get_start_animation())
def get_start_animation(self):
def start_animation():
if self.question.scenepic != None:
self.state = STATE_MOVING
print "Starting animation (1s has passed)"
return start_animation
def handle_key(self, key):
print "handling key"
if key == K_DOWN:
print "user pressed down"
def handle_key_u(self, key):
if key == ' ':
q = questions.next_question(self.screen)
if q == None:
self.res = view_end.ViewEnd(self.screen)
else:
self.res = view_question.ViewQuestion(self.screen, q, questions.cur + 1)
def handle_wiimote(self, wiimote, button):
pass
def render(self, screen):
screen.fill((0, 0, 0))
screen.blit(self.game_logo, self.logorect)
if self.state == STATE_SOLVED:
screen.blit(self.text, self.textrect)
elif self.state == STATE_MOVING:
if self.logorect.top > 50:
self.logorect = self.logorect.move([-25, -25])
else:
self.game_logo = pygame.transform.scale(self.game_logo, (self.logorect.width / 2, self.logorect.height / 2))
self.logorect = self.game_logo.get_rect()
self.logorect.top = 25
self.logorect.left = 25
self.state = STATE_SCENE
self.text = self.font.render(self.question.gametitle, True, (255, 255, 255), (0, 0, 0))
self.textrect = self.text.get_rect()
self.textrect.centerx = self.logorect.centerx
self.textrect.top = self.logorect.bottom
if self.question.scenepic != None:
self.scene_logo = pygame.image.load(self.question.scenepic)
r = self.scene_logo.get_rect()
h = int(500 * (float(r.height) / r.width))
self.scene_logo = pygame.transform.scale(self.scene_logo, (500, h))
self.scene_logo_rect = self.scene_logo.get_rect()
self.scene_logo_rect.centerx = screen.get_rect().centerx
self.scene_logo_rect.centery = screen.get_rect().centery
self.scene_desc = self.font.render(self.question.description, True, (255, 255, 255), (0, 0, 0))
r = self.scene_desc.get_rect()
r.centerx = screen.get_rect().centerx
if self.question.scenepic != None:
r.top = self.scene_logo_rect.bottom + 10
else:
r.top = screen.get_rect().centery + 10
self.scene_desc_rect = r
elif self.state == STATE_SCENE:
screen.blit(self.text, self.textrect)
if self.question.scenepic != None:
screen.blit(self.scene_logo, self.scene_logo_rect)
screen.blit(self.scene_desc, self.scene_desc_rect)
#screen.blit(self.rgb2r_logo, (800 / 2 - (300 / 2), 10))
return self.res