forked from neuromancer/AlienBreedObliteration
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcredit.py
262 lines (195 loc) · 7.48 KB
/
credit.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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
"""
Written By:
Chris Humphreys
Email: < chris (--AT--) habitualcoder [--DOT--] com >
All python source code copyright Chris Humphreys 2010
Level data, Obliteration name and some media copyright
Flash Jester Punk 2007
Alien Breed name, concept and media copyright Team17 1992
This file is part of alien breed obliteration wii edition
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
from utils import *
from text import *
SITE = "http://sourceforge.net/projects/wiiab"
class SolidText:
def __init__(self, my_game, text, delay):
self.menu_font = BreedFont(my_game.get_mixer())
self.lines = text.split('\n')
self.delay = delay
self.my_game = my_game
self.last_update = 0
def update(self, time):
if time - self.last_update > self.delay:
if self.last_update ==0:
self.last_update = time
else:
return True
return False
def draw(self, screen):
sw = screen.get_width()
sh = screen.get_height()
y = sh/2 - (len(self.lines) * self.menu_font.large_font_height) /2
for line in self.lines:
self.menu_font.draw_line_centered(line, y, screen)
y+= self.menu_font.large_font_height
class FadeInText:
def __init__(self, my_game, text, fade_delay):
self.menu_font = BreedFont(my_game.get_mixer())
self.lines = text.split('\n')
self.fade_delay = fade_delay
self.my_game = my_game
self.fade_val = 255
self.last_update = 0
def update(self, time):
if time - self.last_update > self.fade_delay:
self.increment()
self.last_update = time
return self.finished()
def finished(self):
return self.fade_val == 0
def increment(self):
self.fade_val -=10
if self.fade_val < 0:
self.fade_val = 0
def draw(self, screen):
sw = screen.get_width()
sh = screen.get_height()
y = sh/2 - (len(self.lines) * self.menu_font.large_font_height) /2
for line in self.lines:
self.menu_font.draw_line_centered(line, y, screen)
y+= self.menu_font.large_font_height
#Overlays not supported in 8bit mode
if DEPTH != 8:
overlay = self.my_game.create_blank((sw,sh))
overlay.fill(mygame.Colour(0, 0, 0))
overlay.set_alpha(self.fade_val)
screen.blit(overlay, (0,0))
class FadeOutText(FadeInText):
def __init__(self, my_game, text, fade_delay):
FadeInText.__init__(self, my_game, text, fade_delay)
self.fade_val = 0
def increment(self):
self.fade_val +=10
if self.fade_val > 255:
self.fade_val = 255
def finished(self):
return self.fade_val == 255
class FadeInSprite:
def __init__(self, my_game, img, caption, fade_delay):
self.img = mygame.load_image(get_image_pathname(img))
if RESIZE:
self.img = self.img.scale((int(self.img.get_width()*RESIZE_FACTOR),int(self.img.get_height() *RESIZE_FACTOR)))
trans = mygame.Colour(255, 0, 255)
self.img.set_colorkey(trans)
self.fade_delay = fade_delay
self.my_game = my_game
self.fade_val = 255
self.last_update = 0
self.caption = caption
if self.caption:
self.menu_font = BreedFont(my_game.get_mixer())
def update(self, time):
if time - self.last_update > self.fade_delay:
self.increment()
self.last_update = time
return self.finished()
def finished(self):
return self.fade_val == 0
def increment(self):
self.fade_val -=10
if self.fade_val < 0:
self.fade_val = 0
def draw(self, screen):
sw = screen.get_width()
sh = screen.get_height()
x = sw/2 - self.img.get_width() / 2
y = sh/2 - self.img.get_height() /2
self.my_game.get_screen().blit(self.img,(x, y))
if self.caption:
y+= self.menu_font.large_font_height + self.img.get_height()
self.menu_font.draw_line_centered(self.caption, y, screen)
#Overlay not supported in 8bit mode
if DEPTH != 8:
overlay = self.my_game.create_blank((sw,sh))
overlay.fill(mygame.Colour(0, 0, 0))
overlay.set_alpha(self.fade_val)
screen.blit(overlay, (0,0))
class FadeOutSprite(FadeInSprite):
def __init__(self, my_game, img, caption, fade_delay):
FadeInSprite.__init__(self, my_game, img, caption, fade_delay)
self.fade_val = 0
def increment(self):
self.fade_val +=10
if self.fade_val > 255:
self.fade_val = 255
def finished(self):
return self.fade_val == 255
class SolidSprite(FadeOutSprite):
def __init__(self, my_game, img, caption, fade_delay):
FadeOutSprite.__init__(self, my_game, img, caption, fade_delay)
self._finished = False
def increment(self):
if self.last_update !=0:
self._finished = True
return
def finished(self):
return self._finished
class CreditsMenu:
def __init__(self, my_game):
self.commands = []
self.setup_commands(my_game)
self.current_command = 0
def add_text(self, my_game, text, hold=1000):
self.commands.append(FadeInText(my_game,text, 10))
self.commands.append(SolidText(my_game,text, hold))
self.commands.append(FadeOutText(my_game,text, 10))
def add_image(self, img, caption, my_game, hold=1000):
self.commands.append(FadeInSprite(my_game,img, caption, 10))
self.commands.append(SolidSprite(my_game,img, caption, hold))
self.commands.append(FadeOutSprite(my_game,img, caption, 10))
def setup_commands(self, my_game):
self.add_text(my_game, "Alien Breed Obliteration - Wii Edition")
self.add_text(my_game,"Written by HabitualCoder")
self.add_text(my_game,"A homage to the Alien Breed series by")
self.add_image("t17logo.bmp", None,my_game)
self.add_text(my_game, "A clone of the retro remake by")
self.add_image("developer.bmp", None, my_game)
self.add_text(my_game, "Thanks to")
self.add_text(my_game, "Everybody behind\n\nDevkitpro, libogc and SDL-Wii\nWii-Brew, Team Twiizers\ngc-linux, python and pygame", 4000)
self.add_text(my_game, "Tested by The don")
self.add_text(my_game, "The program and installation scripts\nare Free Software, GNU v3\nSee LICENSE for more details.\nGraphics, sounds and level data\nretrieved as part of installation\nare not covered by the GNU license.", 8000)
#self.add_text(my_game, "Want to get involved...\n\n" + SITE, 2000)
self.add_image("website.bmp", None,my_game)
def update(self, time):
if self.current_command < len(self.commands):
finished = self.commands[self.current_command].update(time)
if finished:
if self.current_command < len(self.commands) -1:
self.current_command +=1
else:
return True
return False
def draw(self, screen):
if self.current_command < len(self.commands):
self.commands[self.current_command].draw(screen)
def start(self):
self.current_command = 0
class DemoMenu(CreditsMenu):
def __init__(self, my_game):
CreditsMenu.__init__(self, my_game)
def setup_commands(self, my_game):
self.add_image("demoScreen5.bmp", 'CLASSIC ALIEN BREED GAMEPLAY', my_game, 4000)
self.add_image("demoScreen4.bmp", 'ORIGINAL GFX AND MUSIC', my_game, 4000)
self.add_image("demoScreen2.bmp", '15 NEW LEVELS TO EXPLORE', my_game, 4000)
self.add_image("demoScreen1.bmp", 'EVOLVED ALIEN AI', my_game, 4000)
self.add_image("demoScreen3.bmp", 'IMPROVED BOSS FIGHTS', my_game, 4000)