-
Notifications
You must be signed in to change notification settings - Fork 0
/
menu.py
140 lines (127 loc) · 2.74 KB
/
menu.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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# menu.py
import time
import pygame
import os
import sys
from retrogamelib import display
from retrogamelib import button
from retrogamelib import clock
from retrogamelib import font
from retrogamelib import gameobject
from retrogamelib import dialog
from retrogamelib.constants import *
from retrogamelib.util import *
from game import *
from levels import *
def run_menu():
play_music("sfx/title_screen.ogg")
timer = 0
game = Game()
set_global_sound_volume(0.75)
while True:
clock.tick()
button.handle_input()
if button.is_pressed(START):
play_music("sfx/ChibiNinja.ogg", -1)
whitefont = font.Font(GAMEBOY_FONT, GB_SCREEN_COLOR)
box = dialog.DialogBox((152, 46), (50, 50, 50),
GB_SCREEN_COLOR, whitefont)
box.set_dialog([
"GET THEM DARN ALIENS!"
])
box.set_scrolldelay(2)
while not box.over():
clock.tick()
button.handle_input()
if button.is_pressed(A_BUTTON):
box.progress()
screen = display.get_surface()
screen.fill(GB_SCREEN_COLOR)
screen.blit(game.background, (0, 0))
box.draw(screen, (4, 4))
display.update()
game.won = True
game.level = 1
game.lives = 5
game.score = 0
# Play each level
for lvl in LEVELS:
game.start_level(lvl)
game.level += 1
game.loop()
if not game.player.alive():
break
# If we got to the end of the game, display credits
if game.won:
pos = 144
credits = [
"Credits",
"",
"",
"Programming by",
"Tommy Brunn",
"pymike",
"saluk",
"",
"",
"Art by",
"Tommy Brunn",
"",
"",
"Sound Mixing",
"Tommy Brunn",
"",
"",
"Music",
"Eric Skiff",
"thechad1138",
"",
"",
"Special Thanks To",
"SFXR by DrPetter",
"pymike",
"saluk",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
" Thanks for playing!"]
while pos > -144-(len(credits)*7):
button.handle_input()
if button.is_pressed(START):
break
screen = display.get_surface()
screen.fill(GB_SCREEN_COLOR)
screen.blit(game.background, (0, 0))
clock.tick()
pos -= 0.5
y = 0
for c in credits:
ren = game.font.render(c)
screen.blit(ren, (80-ren.get_width()/2, pos+y))
y += 10
display.update()
play_music("sfx/title_screen.ogg")
#Draw main menu
screen = display.get_surface()
screen.fill(GB_SCREEN_COLOR)
#screen.blit(load_image("gfx/menu.png"), (0, 0))
ren = game.font.render("Press Start")
timer += 1
timer = timer % 30
if timer < 15:
screen.blit(ren, (80-ren.get_width()/2,
104-ren.get_height()/2))
display.update()