Skip to content

Commit

Permalink
Merged intro and game
Browse files Browse the repository at this point in the history
  • Loading branch information
ktzar committed Oct 2, 2011
1 parent e202cdd commit 131dc1a
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 306 deletions.
Binary file removed data/laser2.gif
Binary file not shown.
99 changes: 38 additions & 61 deletions game/intro.py
Expand Up @@ -6,33 +6,13 @@

class Intro():

def __init__(self):
if not pygame.font: print 'Warning, fonts disabled'
if not pygame.mixer: print 'Warning, sound disabled'
self.initialise()
self.loop()

def initialise(self):
"""this function is called when the program starts.
it initializes everything it needs, then runs in
a loop until the function returns."""
#Initialize Everything
pygame.init()
self.clock = pygame.time.Clock()
self.screen = pygame.display.set_mode((640, 480), pygame.DOUBLEBUF)
self.size = self.screen.get_size()
self.font = utils.load_font('4114blasterc.ttf', 36)
pygame.display.set_caption('VacuumFire')
pygame.mouse.set_visible(0)
#icon
icon, foo = utils.load_image('icon.png')
pygame.display.set_icon(icon)

self.age = 0

def __init__(self, screen):
#sounds
self.music = utils.load_sound('intro.ogg')
self.music.play()
self.screen = screen
self.age = 0
self.font = utils.load_font('4114blasterc.ttf', 36)
self.size = self.screen.get_size()
self.menu_finished = False

self.background, self.background_rect = utils.load_image('intro_bg_1.jpg')
self.parallax, self.parallax_rect = utils.load_image('intro_bg_2.png')
Expand All @@ -44,42 +24,39 @@ def initialise(self):

#Main Loop
def loop(self):
while 1:
for event in pygame.event.get():
if event.type == QUIT:
#exit
return
elif event.type == KEYDOWN and event.key == K_ESCAPE:
pygame.quit()
quit()

self.clock.tick(50)

init_text = 'Press any key'
for event in pygame.event.get():
if event.type == QUIT:
#exit
return
elif event.type == KEYDOWN:
self.menu_finished = True


init_text = 'Press any key'

if self.age%8 == 0 or self.age%8 == 1:
text_color = (0,0,0)
else:
text_color = (255, 255, 255)
text = self.font.render(init_text, 1, text_color)

if self.age%2 == 0:
self.background_rect = self.background_rect.move((-1,0))
if self.age%3 == 0:
self.parallax_rect = self.parallax_rect.move((-1,0))
#rotate background
if -self.background_rect.left > self.background_rect.width - self.size[0] :
self.background_rect.left = 0
if -self.parallax_rect.left > self.parallax_rect.width - self.size[0] :
self.parallax_rect.left = 0

self.screen.blit(self.background, self.background_rect)
self.screen.blit(self.parallax, self.parallax_rect)
self.screen.blit(self.logo, (0, 0))
self.screen.blit(text, (200, 300))

if self.age%8 == 0 or self.age%8 == 1:
text_color = (0,0,0)
else:
text_color = (255, 255, 255)
text = self.font.render(init_text, 1, text_color)

if self.age%2 == 0:
self.background_rect = self.background_rect.move((-1,0))
if self.age%3 == 0:
self.parallax_rect = self.parallax_rect.move((-1,0))
#rotate background
if -self.background_rect.left > self.background_rect.width - self.size[0] :
self.background_rect.left = 0
if -self.parallax_rect.left > self.parallax_rect.width - self.size[0] :
self.parallax_rect.left = 0

self.screen.blit(self.background, self.background_rect)
self.screen.blit(self.parallax, self.parallax_rect)
self.screen.blit(self.logo, (0, 0))
self.screen.blit(text, (200, 300))

pygame.display.flip()
self.age += 1
pygame.display.flip()
self.age += 1

#Game Over

Expand Down

0 comments on commit 131dc1a

Please sign in to comment.