1
2
3 import libraryPyGame
4 import player
5
6 import pygame
7 from pygame.locals import *
8
9 if __name__ == '__main__':
10 lib=libraryPyGame.LibraryPyGame()
11
12 playerObj=player.Player(lib)
13
14 pygame.init()
15
16 playerObj.addState("intro")
17 playerObj.addState("happy")
18 playerObj.addState("medium")
19 playerObj.addState("tense")
20
21 playerObj.addMusicDirectoryToState("intro","Music/Ogg/Intro")
22 playerObj.addMusicDirectoryToState("happy","Music/Ogg/Happy")
23 playerObj.addMusicDirectoryToState("medium","Music/Ogg/Medium")
24 playerObj.addMusicDirectoryToState("tense","Music/Ogg/Tense")
25
26 playerObj.addTransition("happy","medium")
27 playerObj.addTransition("medium","tense")
28 playerObj.addTransition("tense","medium")
29 playerObj.addTransition("medium","happy")
30
31 playerObj.addMusicDirectoryToTransition("happy","medium","Music/Ogg/Transitions/Happy-Medium")
32 playerObj.addMusicDirectoryToTransition("medium","tense","Music/Ogg/Transitions/Medium-Tense")
33 playerObj.addMusicDirectoryToTransition("tense","medium","Music/Ogg/Transitions/Tense-Medium")
34 playerObj.addMusicDirectoryToTransition("medium","happy","Music/Ogg/Transitions/Medium-Happy")
35
36
37 playerObj.setState("intro")
38
39 surf=pygame.display.set_mode((200,200))
40
41 keyLabelText=["[1]: Intro",
42 "[2]: Happy",
43 "[3]: Medium",
44 "[4]: Tense",
45 "[R]: (rapid)",
46 "[ESC]: (quit)"]
47
48 defName=pygame.font.get_default_font()
49 print "default font name:", defName
50 defFont=pygame.font.Font(defName, 16)
51 labelsurfs=[defFont.render(x, 1, (190, 190, 0)) for x in keyLabelText]
52
53
54
55 gameOver=False
56 myClock=pygame.time.Clock()
57
58 while not gameOver:
59 surf.fill((255,255,255))
60 for i in range(6):
61 surf.blit(labelsurfs[i], (0,20*i))
62
63 curState=playerObj.getState()
64 if curState:
65 cursurf=defFont.render("mood: "+curState, 1, (80, 80, 200))
66 surf.blit(cursurf, (0,130))
67
68 if playerObj.musicLibrary.rapid:
69 rapidsurf=defFont.render("RAPID ON", 1, (0, 200, 0))
70 else:
71 rapidsurf=defFont.render("RAPID OFF", 1, (200, 0, 0))
72 surf.blit(rapidsurf, (0,160))
73
74
75
76
77
78 myClock.tick(5)
79 for e in pygame.event.get():
80 if e.type==QUIT:
81 gameOver=True
82 break
83 if e.type==KEYDOWN:
84 if e.key==K_1:
85 playerObj.pushState("intro")
86 elif e.key==K_2:
87 playerObj.pushState("happy")
88 elif e.key==K_3:
89 playerObj.pushState("medium")
90 elif e.key==K_4:
91 playerObj.pushState("tense")
92 elif e.key==K_q:
93 gameOver=True
94 elif e.key==K_ESCAPE:
95 gameOver=True
96 elif e.key==K_r:
97 lib.rapid= not lib.rapid
98 playerObj.tick()
99 pygame.display.flip()
100