-
Notifications
You must be signed in to change notification settings - Fork 0
/
gameinit.py
69 lines (55 loc) · 1.77 KB
/
gameinit.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
#no threads are harmed during creation of this module...
import pygame
from pygame.constants import * #
import game
import screen
import gamemenu
title_img = None
def load_game_resources():
global title_img
title_img = game.load_image('splash_title.png', game.colors['black'])
def get_input(): # reuse?
for event in pygame.event.get():
if event.type == QUIT:
return -1
if event.type == KEYDOWN:
if event.mod & KMOD_LALT and event.key == K_F4:
return -1
elif not event.key == K_LALT:
return 1
class GameInit:
def __init__(self):
self.titleimg = title_img
self.titlerect = self.titleimg.get_rect(topleft=(20,138))
self.nexthandler = gamemenu.GameMenu()
def start(self):
pass
def user_quit(self):
input = get_input()
if input:
if input == -1:
self.nexthandler = None
return 1
def intro_animation(self):
wait = pygame.time.wait
wait(100)
for i in range(0, 256, 3):
self.titleimg.set_alpha(i, RLEACCEL)
screen.blit(self.titleimg, self.titlerect)
screen.update()
screen.erase(self.titlerect)
wait(15)
if self.user_quit(): return
for i in range(14):
wait(100)
if self.user_quit(): return
def handle(self, event):
pass
def run(self):
self.intro_animation()
if self.nexthandler:
screen.update() #already erased...
for i in range(4):
pygame.time.wait(100)
if self.user_quit(): break
game.handler = self.nexthandler