Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/MAFH.activity/Comic.py
blob: f4b6af4b2e1b0c710a28784a6d45aa332e41eac6 (plain)
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
import pygame
import os

######################################################################
#Comic Class: stores an image list and possible BGM, traverses through list and tries to play BGM
######################################################################
class Comic:
    def __init__(self,Folder,BGM):
        self.currentIndex = 0
        self.images=[]
        #load images into sprites
        i=0
        for image in os.listdir(Folder):
            spt=pygame.sprite.Sprite()
            spt.image=pygame.image.load(Folder+image)
            spt.rect=pygame.Rect(0,0,1200,900)
            self.images.append(spt)
            i+=1
        self.size=i
        #try to load music
        if BGM != None:
            pygame.mixer.muxic.stop()
            pygame.mixer.music.load(SOUND_PATH+BGM)
            pygame.mixer.music.play(-1)

    def next(self,player):
        if self.currentIndex < self.size - 1:
            self.currentIndex+=1

        else:
            player.stopComic()

    def previous(self):
        if self.currentIndex > 0:
            self.currentIndex-=1

        else:
            self.currentIndex=0

    def draw(self,screen):
        screen.blit(self.images[self.currentIndex].image,(0,0,1200,900))
        pygame.display.flip()