-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathIntro.py
More file actions
68 lines (58 loc) · 2.54 KB
/
Intro.py
File metadata and controls
68 lines (58 loc) · 2.54 KB
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
### This module provides the beginning text intro
import math, sys, pickle
import pygame
from pygame.locals import *
class IntroMovie(object):
""" This class contains the images for the different intro screens as a list. """
def __init__(self, screen):
# IntroMovie must be given the screen you want it to blit onto
self.screen = screen
self.done = False
# Initialize the list of images in order of which you want displayed. Does not currently resize anything.
self.image_list = [pygame.image.load("png/title.png").convert_alpha(),
pygame.image.load("png/frame2.png").convert_alpha(),
pygame.image.load("png/frame3.png").convert_alpha(),
pygame.image.load("png/frame4.png").convert_alpha(),
pygame.image.load("png/frame5.png").convert_alpha(),
pygame.image.load("png/frame6.png").convert_alpha(),
pygame.image.load("png/frame7.png").convert_alpha(),
pygame.image.load("png/frame8.png").convert_alpha(),
pygame.image.load("png/frame9.png").convert_alpha(),
pygame.image.load("png/frame10.png").convert_alpha(),
pygame.image.load("png/frame11.png").convert_alpha(),
pygame.image.load("png/frame12.png").convert_alpha(),
pygame.image.load("png/frame13.png").convert_alpha()
]
# Set the starting image
self.image_index = -1
self.change_image()
def change_image(self):
# Moves to the next image and centers it
self.image_index += 1
self.image = self.image_list[self.image_index]
self.rect = self.image.get_rect()
self.rect.center = self.screen.get_rect().center
def update(self):
# Check for any updates, such as they are trying to skip through it all.
# Controller is not currently running, so this must be done within IntroMovie
for event in pygame.event.get():
if event.type == pygame.QUIT or (event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE):
self.done = True
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_SPACE:
if self.image_index < len(self.image_list)-1:
self.change_image()
else:
self.done = True
# Display on-screen with a black background, if applicable
self.screen.fill((0,0,0))
self.screen.blit(self.image, self.rect)
pygame.display.flip()
def run(screen, clock):
""" Makes things run. This is called in game_base.py before the game begins,
so that you only see it once. clock and screen are initialized outside of here
in order to make them be the same as the game will be played with."""
video = IntroMovie(screen)
while not video.done:
video.update()
clock.tick(60)