예제 #1
0
 def __init__(self, position,toon):
     gameObject.__init__(self, self.groups)
     self.toon = toon
     self.image = self.move_images[0]
     self.left = []
     for image in self.move_images:
         self.left.append(pygame.transform.flip(image,1,0))
     self.rect = self.image.get_rect(topleft=position)
     self.jumping = 0
     self.breaker = 0
     self.up = 0
     self.direction = 1
     self.pic = 0
     self.save = 0
     self.dead = 0
     self.life = 1
     self.invuln = 0
     self.star = 0
     self.no_clip = 0
     self.woo = data.load_sound('star.wav')
     self.timer = 0
     self.inc = .3
     self.jumps = data.load_sound('jump.wav')
     self.bounces = data.load_sound('jump2.wav')
     self.hits = data.load_sound('hit.wav')
예제 #2
0
파일: player.py 프로젝트: brunez/m-reborn
    def __init__(self, pos, name, object_id):
        sprites.Collidable.__init__(self, pos, object_id=object_id)
        self.left_images = []
        for i in self.right_images:
            self.left_images.append(pygame.transform.flip(i, 1, 0))
        self.image = self.right_images[0]
        self.rect = self.image.get_rect(topleft = pos)        
        self.frame = 0
        self.direction = 1
        self.angle = 0
        self.dying = False        
        self.shooting = False
        self.shoot_timer = 0
        self.still_timer = 0
        self.hp = 1
        self.hit_timer = 0
        self.jump_sound = data.load_sound("jump.ogg")
        self.hit_sound = data.load_sound("stomp.ogg")
        self.spring_sound = data.load_sound("jump2.ogg")
        self.springing = False
        self.dx = 1
        self.speed = 0                    
        
        self.won = False
        self.flag = None
#        self.JUMP_KEY = jumpKey

        #Images
        self.win_image = data.load_image("mariowin-%d.png" % (int(self.object_id)+1))
        self.slide_image = data.load_image("mario_slide-%d.png" % (int(self.object_id)+1))
        self.dead_image = data.load_image("mariodie-%d.png" % (int(self.object_id)+1))

        self.thrust = NO_THRUST
        self.state = STILL

        self.name = name
        self.walking = False
        self.braking = False
        self.direction = 1
        self.trying_to_walk = False
        
        self.jump_speed = 0
        self.jump_accel = 0.3
        self.jumping = False
        self.keep_jumping = False
        
        #This is for the dying animation
        self.life = 1
        self.dead_step = -3
        
        self.state_observers = []
        
        #Collision group not in use right now
        self.collision_group = sprites.player_collision_group
예제 #3
0
def init():
    SoundSystem._eat = [load_sound("eat1.wav"),
            load_sound("eat2.wav"),
            load_sound("eat3.wav")]
    SoundSystem._poop = [load_sound("poop.wav")]
    SoundSystem._water = [load_sound("water.wav")]
    SoundSystem._grunt = [load_sound(os.path.join("grunt", "grunt.oga")),
              load_sound(os.path.join("grunt", "grunt2.oga")),
              load_sound(os.path.join("grunt", "grunt3.oga")),
              load_sound(os.path.join("grunt", "grunt4.oga"))]
예제 #4
0
 def __init__(self,position,orient):
     gameObject.__init__(self, self.groups)
     self.rect = self.image.get_rect(topleft=position)
     self.orientation = orient
     self.hits = -1
     self.breaking = [data.load_image('break%s.png'%image)for image in xrange(1,4)]
     self.breaknoise = data.load_sound('break.wav')
예제 #5
0
    def __init__(self, game, name, index, config=None):
        super(GameOverScene, self).__init__(game, name, index, config)

        gameovermessage = config['message'] if 'message' in config else 'Game Over'
        gameovermusic = config['music'] if 'music' in config else 'gameover.ogg'

        self.gameovertxt = data.render_text(data.FONT_TITLE, 30, gameovermessage, (255, 255, 255))
        self.gameovertxtRect = self.gameovertxt.get_rect()
        self.background = data.load_image('gameover.png')

        self.music_bg = data.load_sound(gameovermusic)

        self.teaserText = data.render_text(data.FONT_MAIN, 17, 'Who\'s the rockstar with '+str(self.game.points)+' points ?', (255, 255, 255))
        self.teaserTextrect = self.teaserText.get_rect()

        #temp
        self.teaserTextInputRect = self.teaserTextrect
        self.blinkInputCounter = 0
        self.blinkInputTime = 400
        self.userFilledStr = []
        self.usernickText = None
        self.usernickTextRect = None
        self.userFillingTextField = True
        self.showUnderscore = True
        self.lScoreFile = None
        self.userscores = None
        self.orderedTabScore = []
        self.buildTabScore()
예제 #6
0
파일: game.py 프로젝트: BradyZhou/15-112
    def gameOver(self):
        choice = 1
        lose = data.load_sound('gameover.wav',1)
        lose.play()
        while choice:
            self.clear_level()
            self.screen.fill((0,0,0))
            text = self.font4.render('G A M E  O V E R',1,(255,255,255))
            self.screen.blit(text,(320-text.get_width()/2,230-text.get_height()/2))
            if self.score >= 3000:
                text = self.font3.render('Press R to restart! (3000 points)',1,(255,255,255))
                self.screen.blit(text,(320-text.get_width()/2,260))
            text = self.font.render('Press Enter to quit.',1,(255,255,255))
            self.screen.blit(text,(320-text.get_width()/2,290))
            events = pygame.event.get()
            for event in events:
                if event.type == KEYDOWN:
                    if event.key == K_RETURN:
                        lose.stop()
                        if self.score > self.highscore:
                            Savefile('scores.txt').writescore(self.score)
                        start.Menu(self.screen)
                    if event.key == K_r:
                        lose.stop()
                        if self.score >= 3000:
                            self.score -= 3000
                            self.lives = 3
                            choice = 0
                            self.redo()

            pygame.display.flip()
예제 #7
0
    def __init__(self, game, name, index, config=None):
        super(HowtoScene, self).__init__(game, name, index, config)

        self.bg_text = data.load_image('howtoplay.png')
        self.bg_text = pygame.transform.scale(self.bg_text, (534, 400))
        self.bg_textrect = self.bg_text.get_rect()

        fontText = data.load_font(data.FONT_MAIN, 20)
        fontText.set_bold(True)

        texts = [{
            'text': '1) The boss generates 1 to 9 sounds',
            'top': 30,
            'left': 50
        }, {
            'text': '2) You must copy the generated sequence',
            'top': 250,
            'left': 20
        }]

        for phrase in texts:
            text = fontText.render(phrase['text'], True, (255, 255, 255))
            textrect = text.get_rect()
            textrect.top = phrase['top']
            textrect.left = phrase['left']
            self.bg_text.blit(text, textrect)

        self.text = data.render_text(data.FONT_MAIN, 37, 'Push the button !',
                                     (255, 255, 255))
        self.textrect = self.text.get_rect()

        #        bg_text.blit(self.text, self.textrect)

        self.background = data.load_image('credits.png')
        self.music_bg = data.load_sound('credits.ogg')
예제 #8
0
    def gameOver(self):
        choice = 1
        lose = data.load_sound('gameover.wav',1)
        lose.play()
        while choice:
            self.clear_level()
            self.screen.fill((0,0,0))
            text = self.font4.render('G A M E  O V E R',1,(255,255,255))
            self.screen.blit(text,(320-text.get_width()/2,230-text.get_height()/2))
            if self.score >= 3000:
                text = self.font3.render('Press R to restart! (3000 points)',1,(255,255,255))
                self.screen.blit(text,(320-text.get_width()/2,260))
            text = self.font.render('Press Enter to quit.',1,(255,255,255))
            self.screen.blit(text,(320-text.get_width()/2,290))
            events = pygame.event.get()
            for event in events:
                if event.type == KEYDOWN:
                    if event.key == K_RETURN:
                        lose.stop()
                        if self.score > self.highscore:
                            Savefile('scores.txt').writescore(self.score)
                        start.Menu(self.screen)
                    if event.key == K_r:
                        lose.stop()
                        if self.score >= 3000:
                            self.score -= 3000
                            self.lives = 3
                            choice = 0
                            self.redo()

            pygame.display.flip()
예제 #9
0
 def associateTheme(self, type, theme):
     self.activeImage = data.load_image('button-' + type + '-' +
                                        str(1 + self.name) + '.png')
     self.sound = data.load_sound(
         'button-' + type + '-' + str(1 + self.name) + '.ogg', theme)
     self.sound.set_volume(0.4)
     self.channel = None
예제 #10
0
 def __init__(self,position):
     gameObject.__init__(self,self.groups)
     self.rect = self.image.get_rect(topleft=position)
     self.name = 'Bowser'
     self.x = position[0]
     self.y = position[1]-2 #temp fix -.-
     self.up = data.load_image('bowserjump.png')
     self.down = data.load_image('bowser.png')
     self.shoot = data.load_image('bowserfire.png')
     self.pic = 0
     self.dead = data.load_image('bowserdie.png')
     self.winner = data.load_sound('win.wav')
     self.ping = data.load_sound('bowserfire.wav')
     self.fall = data.load_sound('bowserdie.wav')
     self.fallsound = -1
     self.victory = -1
예제 #11
0
    def __init__(self, game, name, index, config=None):
        super(HowtoScene, self).__init__(game, name, index, config)

        self.bg_text = data.load_image('howtoplay.png')
        self.bg_text = pygame.transform.scale(self.bg_text, (534, 400))
        self.bg_textrect = self.bg_text.get_rect()
        
        fontText = data.load_font(data.FONT_MAIN, 20)
        fontText.set_bold(True)
        
        texts = [
            {'text':'1) The boss generates 1 to 9 sounds', 'top':30, 'left':50},
            {'text':'2) You must copy the generated sequence', 'top':250, 'left':20}
        ]
        
        for phrase in texts:
            text = fontText.render(phrase['text'], True, (255, 255, 255))
            textrect = text.get_rect()
            textrect.top = phrase['top']
            textrect.left = phrase['left']
            self.bg_text.blit(text, textrect)
        
        self.text = data.render_text(data.FONT_MAIN, 37, 'Push the button !', (255, 255, 255))
        self.textrect = self.text.get_rect()
        
#        bg_text.blit(self.text, self.textrect)

        self.background = data.load_image('credits.png')
        self.music_bg = data.load_sound('credits.ogg')
예제 #12
0
파일: game.py 프로젝트: boubateam/PyWeek-12
 def __init__(self):
     self.level  = None
     self.difficulty = 4
     self.points = 0
     self.director = director.Director(self, {
         'title' : 'Ninth Kind',
         'show_fps' : False})
     self.music = data.load_sound('intro.ogg')
     self.channel = None
예제 #13
0
 def on_init(self):
     self.splash = pygame.image.load(data.filepath('law_and_order.png'))
     self.snd = data.load_sound(data.filepath('sfx/intro.wav')).play()
     self.played = False
     self.pos = Vec2D(400, -50)
     self.accel = Vec2D(0, 0.0025)
     self.vel = Vec2D(0, 0)
     self.run_time = 0.0
     self.target_time = 900.0
예제 #14
0
 def on_init(self):
     self.splash = pygame.image.load(data.filepath('law_and_order.png'))
     self.snd = data.load_sound(data.filepath('sfx/intro.wav')).play()
     self.played = False
     self.pos = Vec2D(400, -50)
     self.accel = Vec2D(0, 0.0025)
     self.vel = Vec2D(0, 0)
     self.run_time = 0.0
     self.target_time = 900.0
예제 #15
0
파일: menu.py 프로젝트: boubateam/PyWeek-12
    def __init__(self, game, name, index, config=None):
        self.background = pygame.surface.Surface((640, 480), flags=pygame.SRCALPHA)
        self.background.fill((0, 0, 0, 95))

        menus = (('Resume', self.cont),
                 ('Back to Menu', self.back))

        MenuScene.__init__(self, game, name, index, config, (320, 240), menus)
        self.music_bg = data.load_sound('pause.ogg')
예제 #16
0
 def __init__(self,position):
     gameObject.__init__(self, self.groups)
     self.image = self.images[0]
     self.rect = self.image.get_rect(topleft=position)
     self.pic = 0
     self.x = position[0]
     self.y = ((position[1]-32)/32)*31.8
     self.coined = 0
     self.hit = data.load_sound('bump.wav')
     self.done = data.load_image('qempty.png')
예제 #17
0
def get_sound(sound_code):
    '''
	Devuelve el sonido asociado al código del sonido dado.
	'''
    __check_initialize()
    if __sounds.has_key(sound_code):
        print "Sonido " + sound_code + " ya cargado"
    else:
        print "Sonido " +  sound_code + " no cargado, cargado..."
        __sounds[sound_code] = data.load_sound(__sounds_info[sound_code])
        
    return __sounds[sound_code]
예제 #18
0
 def __init__(self, pos, dir, id, player):
     Collidable.__init__(self, pos)
     self.rect = self.image.get_rect(center=pos)
     self.move((28 - id * 12) * dir, 0)
     self.move(54 * dir, 0)
     self.player = player
     self.dir = dir
     self.id = id
     if dir < 0:
         self.image = pygame.transform.flip(self.image, 1, 0)
     self.life = 5 * id
     self.shoot_sound = data.load_sound("fireball.ogg")
     self.shoot_sound.play()
예제 #19
0
 def update(self):
     self.pic+= 1
     if self.flagged == 0:
         if self.speed > 0:
             self.image = self.right[self.pic/20%2]
         if self.speed < 0:
             self.image = self.images[self.pic/20%2]
         if self.pic%2 == 0:
             self.move(self.speed,1)
     else:
         GreenKoopaDeath((self.rect.left,self.rect.top+24))
         self.kill()
         death = data.load_sound('stomp.wav')
         death.play()
예제 #20
0
def get_sound(sound_code):
    '''
	@brief Función que devuelve el sonido asociado al código del sonido dado.
    
    @param sound_code Código del sonido a cargar.
    @return Referencia al sonido cargado.
	'''
    __check_initialize()
    if __sounds.has_key(sound_code):
        print "Sonido " + sound_code + " ya cargado"
    else:
        print "Sonido " +  sound_code + " no cargado, cargado..."
        __sounds[sound_code] = data.load_sound(__sounds_info[sound_code])
        
    return __sounds[sound_code]
예제 #21
0
def get_sound(sound_code):
    '''
	@brief Función que devuelve el sonido asociado al código del sonido dado.
    
    @param sound_code Código del sonido a cargar.
    @return Referencia al sonido cargado.
	'''
    __check_initialize()
    if __sounds.has_key(sound_code):
        pass
        #print "Sonido " + sound_code + " ya cargado"
    else:
        #print "Sonido " +  sound_code + " no cargado, cargado..."
        __sounds[sound_code] = data.load_sound(__sounds_info[sound_code])

    return __sounds[sound_code]
예제 #22
0
    def __init__(self, game, name, index, config=None):
        super(IntroScene, self).__init__(game, name, index, config)

        self.background = data.load_image('intro.png')
        self.music = data.load_sound('intro.ogg')

        self.endTime = None
        self.currentIntroIdx = None
        self.intros = []
        self.intros.append(Intro(5000, True, ['2038. The Earth.', 'Sonore Aliens wade in !', 'With their ultrasonic sounds', 'they want to destroy humanity !']))
        self.intros.append(Intro(7000, True, ['Thanks to', 'the found sumerian technology', 'dated 4000 years BC', 'human resistance can recreate', 'sonore attacks and defend the Earth.', '', 'Fight for the resistance !']))
        
        self.blinkText = None
        self.blinkTextRect = None
        self.blinkInputCounter = 0
        self.blinkInputTime = 500
        self.showBlinkText = True
예제 #23
0
 def update(self):
     if self.flagged == 0:
         self.pic+=1
         self.image = self.images[self.pic/16%2]
         if self.rect.y > 460:
             self.kill()
         if self.rect.left < 0:
             self.rect.left = 0
             self.speed = 1
         self.move(self.speed,1)
         if self.speed == 1:
             self.x += 1
         else:
             self.x -= 1
     else:
         GoombaDie((self.rect.left,self.rect.top+14))
         stomp = data.load_sound('stomp.wav')
         stomp.play()
         self.kill()
예제 #24
0
    def __init__(self, game, name, index, config=None):
        super(CreditsScene, self).__init__(game, name, index, config)

        self.text = data.render_text(data.FONT_TITLE, 37, 'Thanks for Playing',
                                     (255, 255, 255))
        self.textrect = self.text.get_rect()

        font = data.load_font(data.FONT_MAIN, 17)
        names = ('cyqui', 'gleuh', 'greg0ire', 'joksnet')

        self.designLabel = data.render_text(data.FONT_TITLE, 23, 'Design:',
                                            (255, 255, 127))
        self.designLabelRect = self.designLabel.get_rect()
        self.design = data.render_text(data.FONT_MAIN, 21, 'tocab',
                                       (255, 255, 255))
        self.designRect = self.design.get_rect()

        self.musicLabel = data.render_text(data.FONT_TITLE, 23, 'Music:',
                                           (255, 255, 127))
        self.musicLabelRect = self.musicLabel.get_rect()
        self.music = data.render_text(data.FONT_MAIN, 21, 'TOTOleHero',
                                      (255, 255, 255))
        self.musicRect = self.music.get_rect()

        self.namesLabel = data.render_text(data.FONT_TITLE, 23, 'Developers',
                                           (255, 255, 127))
        self.namesLabelRect = self.namesLabel.get_rect()

        self.names = []

        for name in names:
            rend = font.render(name, True, (255, 255, 255))
            rect = rend.get_rect()

            self.names.append((rend, rect))

        self.team = data.render_text(data.FONT_TITLE, 37, 'The Bouba Team',
                                     (60, 255, 60))
        self.teamRect = self.team.get_rect()

        self.background = data.load_image('credits.png')
        self.music_bg = data.load_sound('credits.ogg')
def load_sfx(sound_on=True):
    class NoneSound:  #taken from chimp linebyline tutorial
        def play(self): pass

    if sound_on:
        dc_sfx["revive"] = data.load_sound("revive.ogg")
        dc_sfx["cast"] = data.load_sound("revive.ogg")
        dc_sfx["lvlup"] = data.load_sound("lvlup.ogg")
        dc_sfx["mdeath"] = data.load_sound("monsterdth.ogg")
        dc_sfx["pdeath"] = data.load_sound("playerdth.ogg")
        dc_sfx["hit"] = data.load_sound("thud.ogg")
        dc_sfx["sel"] = data.load_sound("select.ogg")
    else:
        dc_sfx["revive"] = NoneSound()
        dc_sfx["lvlup"] = NoneSound()
        dc_sfx["cast"] = NoneSound()
        dc_sfx["mdeath"] = NoneSound()
        dc_sfx["pdeath"] = NoneSound()
        dc_sfx["hit"] = NoneSound()
        dc_sfx["sel"] = NoneSound()
예제 #26
0
 def associateTheme(self, type, theme):
     self.activeImage = data.load_image('button-' + type + '-' + str(1+self.name) + '.png')
     self.sound = data.load_sound('button-' + type + '-' + str(1+self.name) + '.ogg', theme)
     self.sound.set_volume(0.4)
     self.channel = None 
예제 #27
0
    def __init__(self, game, name, index, config=None):
        super(LevelScene, self).__init__(game, name, index, config)

        self.font = data.load_font(data.FONT_FIX, 23)

        self.count = config['count'] if 'count' in config else 9
        self.delta = config['delta'] if 'delta' in config else 1000

        self.points = config['points'] if 'points' in config else 500
        self.volume = config['volume'] if 'volume' in config else 0.3
        self.pointsMulti = config[
            'pointsMulti'] if 'pointsMulti' in config else 1
        self.pointsText = None

        self.sequence = button.SequenceButtonGroup((20, 20), (210, 100), 15, 5,
                                                   self.count, self.delta)
        self.buttons = button.PlayableButtonGroup((50, 150), (35, 300), 20, 15,
                                                  self.count, 750)

        self.seqindex = 0
        self.sequencing = False

        self.play = []
        self.playing = False

        self.background = data.load_image('background.png')
        self.ray = data.load_image('ray.png')
        self.piano = data.load_image('piano.png')

        self.music_bg = data.load_sound('background.ogg', self.name)
        self.music_bg.set_volume(self.volume)
        self.music_pre_bg = data.load_sound('pre-background.ogg', self.name)
        self.music_pre_bg.set_volume(0.3)

        self.sequence.associateTheme(self.name)
        self.buttons.associateTheme(self.name)

        self.pre_bg_channel = None
        self.bg_channel = None

        # step counter management
        self.stepElapsingInTime = 1
        self.stepElapsedTimeCounter = 0
        self.counterStepPerClick = config[
            'timetoclick'] if 'timetoclick' in config else 200
        self.currentCounterStep = self.counterStepPerClick

        # counting only when button animation is over
        self.stepCountElapsingTime = False
        self.stepCounterText = None
        self.rectWidth = 0

        boss = data.load_image('boss.png', self.name)
        boss.set_colorkey((255, 0, 255))

        miniboss = data.load_image('boss_mini.png', self.name)
        miniboss.set_colorkey((255, 0, 255))

        self.animMiniBossImage = miniboss  # pygame.transform.scale(boss, (170, 170))
        self.animMiniBossRect = self.animMiniBossImage.get_rect()
        self.animMiniBossRect.left = 302
        self.animMiniBossRect.bottom = 243

        self.animBossAction = 'scale'
        self.animBossActionCount = 0
        self.animBossImage = boss  # pygame.transform.scale(boss, (170, 170))
        self.animBossRect = self.animBossImage.get_rect()
        self.animBossRect.left = 350
        self.animBossRect.bottom = 280
        self.animBossTime = 0
        self.animBossShowRaw = False

        self.counterRect = [266, 250, 110, 8]
        self.counterRectDecSizePerStep = 110.0 / self.counterStepPerClick

        self.incrRedColorUnit = 255.0 / self.counterStepPerClick
        self.decrBlueColorUnit = 255.0 / self.counterStepPerClick

        self.bottomPanel = pygame.Surface((640, 240))
        self.bottomPanel.fill((100, 100, 100))
        self.bottomPanel.set_alpha(200)

        self.bottomText = data.render_text(
            data.FONT_MAIN, 30,
            self.name.replace('-', ' ') + " starting in...", (255, 0, 0))
        self.bottomTextRect = self.bottomText.get_rect()
        self.bottomTextRect.center = (320, 360)
예제 #28
0
파일: game.py 프로젝트: BradyZhou/15-112
    def main_loop(self):
        while self.start:
            if not self.paused:
                self.clock.tick(60)
                self.camera.update()

                # for guy in self.character:
                #     guy.update()

                #########################################
                # HANDLES NO CLIPPING TOGGLING
                #########################################
                if self.cheat_enabled:
                    self.player.no_clip = 1
                    self.player.clear_collisions()
                else:
                    self.player.no_clip = 0

                #########################################
                # DEALS WITH NO CLIP INVICIBILITY
                #########################################
                if self.record == 'konami' and not self.chill and self.lvl != 9:
                    print 'C H E A T    E N A B L E D'
                    self.cheat_enabled = 1
                    self.chill = 1
                    data.stop_music()
                    data.play_music('winner.wav')

                if self.lvl == 9 and self.cheat_enabled:
                    self.cheat_enabled = 0
                    print 'C H E A T    D I S A B L E D'
                    print 'You no longer need to cheat. You cannot die in this sanctuary.'

                #########################################
                # FIX FOR MULTIPLE DYING SOUNDS, DYING IN GENERAL
                #########################################
                if self.flagged:
                    if self.diefix == 0:
                        die = data.load_sound('die.wav')
                        die.play()
                        self.diefix += 1
                    self.playerdie()

                #########################################
                # PRECAUTION IF FLAG DOES NOT CATCH YOU FOR SOME REASON
                #########################################
                if self.player.rect.right > self.level.size:
                    self.player.rect.right = self.level.size

                #########################################
                # KILLS YOU/SAVES YOU IF YOU FALL
                #########################################
                if self.player.rect.top > 460 and not self.player.invuln:
                    self.player.life -= 1
                    self.flagged = 1
                    self.playerdie()
                elif self.player.rect.bottom > 460 and self.player.invuln and not self.cheat_enabled:
                    self.player.rect.bottom = 460
                    self.player.save = 1

                #########################################
                # HANDLES INVULNERABILITY
                #########################################
                for toon in self.sprites:
                    toon.update()
                    if not self.cheat_enabled:
                        if self.player.invuln:
                            self.player.timer += 1
                            if self.player.timer > 250000:
                                self.player.invuln = 0
                                self.player.timer = 0
                                self.player.save = 0

                #########################################
                # CANNOT LOSE VICTORY LEVEL
                #########################################
                if self.lvl == 9 or self.cheat_enabled:
                    self.player.invuln = 1

                for platform in self.platforms:
                    platform.update()

                if self.player.no_clip != 1:
                    self.player.collide(self.platforms)

                for banner in self.flags:
                    banner.update()
                    if self.player.rect.centerx >= banner.rect.centerx and self.lvl !=9:
                        pygame.mixer.music.stop()
                        self.complete.play()
                        self.score += 460-self.player.rect.bottom
                        self.finish()
                    elif self.player.rect.centerx >= banner.rect.centerx:
                        self.score += 1000
                        self.win_game()


                #########################################
                # HANDLES CANNON FIRING
                #########################################
                for weapon in self.cannons:
                    if abs(weapon.rect.centerx-self.player.rect.centerx) < 400:
                        if self.player.rect.centerx < weapon.rect.centerx:
                            weapon.chance()

                #########################################
                # COIN EXTRACTION
                #########################################
                for block in self.coinquestions:
                    if block.rect.bottom == self.player.rect.top and (block.rect.left-15 < self.player.rect.centerx < block.rect.right+15):
                        block.bing()

                #########################################
                # HANDLES BULLET BILLS
                #########################################
                for bomb in self.missles:
                    if (bomb.rect.left - 20 < self.player.rect.centerx < bomb.rect.right + 20) and (0 < bomb.rect.top-self.player.rect.bottom < 5):
                            self.score += 245
                            self.player.up = -6
                            GrabCoin((bomb.rect.left,bomb.rect.top))
                            bomb.kill()
                            self.player.rect.bottom = bomb.rect.top-1
                    elif self.player.rect.colliderect(bomb.rect):
                        if self.player.invuln:
                            self.score += 20
                            GrabCoin((bomb.rect.left,bomb.rect.top))
                            bomb.kill()
                        else:
                            self.player.life -= 1
                            self.flagged = 1
                            self.playerdie()
                    bomb.update()

                #########################################
                # HANDLES BOWSER FIRE AND FLARES
                #########################################
                for heat in self.fire:
                    heat.update()
                    if self.player.rect.colliderect(heat.rect):
                        if self.player.invuln != 1:
                            self.player.life -= 1
                            self.flagged = 1
                            self.playerdie()
                        else:
                            heat.kill()

                for flare in self.flares:
                    if self.player.rect.colliderect(flare.rect):
                        if self.player.invuln:
                            flare.kill()
                        else:
                            self.player.life -= 1
                            self.flagged = 1
                            self.playerdie()

                #########################################
                # HANDLES QUESTIONBLOCK EXTRACTION
                #########################################
                for block in self.upplat:
                    if block.rect.bottom == self.player.rect.top and (block.rect.left-15 < self.player.rect.centerx < block.rect.right+15):
                        block.bing()

                for block in self.brickquestions:
                    if block.rect.bottom == self.player.rect.top and (block.rect.left-15 < self.player.rect.centerx < block.rect.right+15):
                        block.bing()

                for block in self.starquestions:
                    if block.rect.bottom == self.player.rect.top and (block.rect.left-15 < self.player.rect.centerx < block.rect.right+15):
                        block.bing()

                #########################################
                # HANDLES BRICK DEMOLITION
                #########################################
                for block in self.breakable:
                    if block.rect.bottom == self.player.rect.top and (block.rect.left-15 < self.player.rect.centerx < block.rect.right+15):
                        if self.player.breaker == 1:
                            block.bing()
                        if block.hits >= 9:
                            block.kill()
                            self.score += 10

                #########################################
                # HANDLES MUSHROOMS
                #########################################
                for shroom in self.mushrooms:
                    shroom.update()
                    shroom.collide(self.platforms)
                    if self.player.rect.colliderect(shroom.rect):
                        shroom.kill()
                        self.power.play()
                        if shroom.name == 'brick':
                            self.player.breaker = 1
                            self.score += 45
                            #self.player.magic()
                        if shroom.name == 'life':
                            self.lives += 1
                            self.score += 30
                        GrabShroom(shroom.rect.topleft,shroom.name)

                #########################################  
                # HANDLES STARS
                #########################################
                for star in self.powerup:
                    star.update()
                    if self.player.rect.colliderect(star.rect):
                        star.kill()
                        self.power.play()
                        if self.player.invuln == 0:
                            self.player.invuln = 1
                        GrabShroom(star.rect.topleft,star.name)

                #########################################
                # HANDLES COINS
                #########################################
                for coin in self.coins:
                    if self.player.rect.colliderect(coin.rect):
                        coin.kill()
                        self.score += 50
                        self.coinsound.play()
                        GrabCoin(coin.rect.topleft)

                #########################################
                # HANDLES SPIKES
                #########################################
                for dagger in self.hazards:
                    if self.player.rect.colliderect(dagger.rect):
                        if self.player.invuln != 1:
                            self.player.life -= 1
                            self.flagged = 1
                            self.playerdie()
                        else:
                            dagger.kill()

                #########################################
                # HANDLES ENEMY COLLISIONS AND BOWSER BEHAVIOR
                #########################################
                for enemy in self.enemies:
                    enemy.update()
                    enemy.collide(self.stationary)
                    if enemy.name == 'Bowser':
                        if self.player.rect.centerx+3000 >= enemy.x:
                            if self.player.rect.right - enemy.rect.left < -75:
                                enemy.play((self.player.rect.right,self.player.rect.top))
                            elif self.player.rect.right - enemy.rect.left > -75:
                                enemy.defeat()
                        if self.player.rect.colliderect(enemy.rect):
                            if not self.player.invuln:
                                self.player.life -=1
                                self.flagged = 1
                                self.playerdie()
                    if enemy.name != 'Bowser':
                        if (enemy.rect.left - 17 < self.player.rect.centerx < enemy.rect.right + 17) and (0 < enemy.rect.top-self.player.rect.bottom < 8):
                            if enemy.name == 'Goomba':
                                self.score += 100
                            if enemy.name == 'RedKoopa':
                                self.score += 195
                            if enemy.name == 'GreenKoopa':
                                self.score += 165
                            self.player.up = -6
                            enemy.flag()
                            self.player.rect.bottom = enemy.rect.top-1
                        elif self.player.rect.colliderect(enemy.rect):
                            if self.player.invuln:
                                self.score += 20
                                enemy.flag()
                            else:
                                if self.player.breaker == 0:
                                    self.player.life -= 1
                                    self.flagged = 1
                                    self.playerdie()
                                else:
                                    enemy.flag()
                                    self.player.rect.bottom = enemy.rect.top-1
                                    self.player.breaker = 0
                                    #self.player.magic()

                #########################################
                # HANDLES BOWSER SWITCH KILLER
                #########################################
                for operator in self.switches:
                    if self.player.rect.bottom == operator.rect.top and (operator.rect.left-16 < self.player.rect.centerx < operator.rect.right+16):
                        for piece in self.bridges:
                            piece.kill()
                            for enemy in self.enemies:
                                if enemy.name == 'Bowser':
                                    enemy.die()
                    if self.player.rect.centerx > operator.rect.right:
                        for piece in self.bridges:
                            piece.kill()
                        for enemy in self.enemies:
                            if enemy.name == 'Bowser':
                                enemy.die()
                    if self.player.rect.left > operator.rect.right+50 and operator.dead == 0:
                        x = operator.x
                        y = operator.y
                        for mult in xrange(0,8):
                            CastleBrick((x,y-32*mult),None)
                        win = data.load_sound('break.wav',1)
                        win.play()
                        self.score += 500
                        operator.dead += 1

                #########################################
                # HANDLES PLANTS
                #########################################
                for venus in self.traps:
                    venus.update()
                    venus.collide(self.bases)
                    if self.player.rect.colliderect(venus.rect):
                        die = data.load_sound('stomp.wav',1)
                        if self.player.invuln:
                            venus.die()
                        else:
                            if self.player.breaker == 0:
                                self.player.life -= 1
                                self.flagged = 1
                                self.playerdie()
                            else:
                                self.player.breaker = 0
                                venus.die()

                #########################################
                # HANDLES EVENTS AND CHEAT CODES
                #########################################
                events = pygame.event.get()
                for event in events:
                    if event.type == QUIT:
                        sys.exit()
                        return
                    if event.type == KEYDOWN:
                        if event.key == K_ESCAPE:
                            self.paused = 1
                        if event.key == K_SPACE:
                            if not self.player.no_clip:
                                self.player.jump()
                        if self.record == '':
                            if event.key == K_k:
                                self.record += 'k'
                        if event.key == K_o and self.record == 'k':
                            self.record += 'o'
                        if event.key == K_n and self.record == 'ko':
                            self.record += 'n'
                        if event.key == K_a and self.record == 'kon':
                            self.record += 'a'
                        if event.key == K_m and self.record == 'kona':
                            self.record += 'm'
                        if event.key == K_i and self.record == 'konam':
                            self.record += 'i'
                        if self.record == 'konami':
                            if event.key == K_BACKQUOTE:
                                okay = 1
                                for sprite in self.platforms:
                                    if self.player.rect.colliderect(sprite.rect):
                                        okay = 0
                                if okay:
                                    self.record = ''
                                    self.chill = 0
                                    self.cheat_enabled = 0
                                    self.player.invuln = 0
                                    print 'C H E A T    D I S A B L E D'
                                    data.stop_music()
                                    data.play_music(self.bgcolor[self.lvl][1])
                                else:
                                    print 'This is not a valid location to turn on clipping!'

            #########################################
            # HANDLES SCREEN CREATION
            #########################################
            if not self.paused:
                self.screen.blit(self.bg, ((-self.camera.rect.x/1)%640, 0))
                self.screen.blit(self.bg, ((-self.camera.rect.x/1)%640 + 640, 0))
                self.screen.blit(self.bg, ((-self.camera.rect.x/1)%640 - 640, 0))
                self.camera.create_world(self.screen, self.sprites)
                self.info()
                pygame.display.flip()

            #########################################
            # HANDLES PAUSE SCREEN
            #########################################
            elif self.paused and not self.saving:
                events = pygame.event.get()
                pause = data.load_image('pausescreen.png',1)
                self.screen.blit(pause,(0,0))
                self.menu.create(self.screen)
                self.menu.choose(events)
                text = self.font.render('NOTE :',1,(255,0,0))
                self.screen.blit(text,(320-text.get_width()/2,360))
                text = self.font.render('If you quit without saving,',1,(255,255,255))
                self.screen.blit(text,(320-text.get_width()/2,390))
                text = self.font.render('your progress will be lost.',1,(255,255,255))
                self.screen.blit(text,(320-text.get_width()/2,420))
                for event in events:
                    if event.type == QUIT:
                        sys.exit()
                        return
                    if event.type == KEYDOWN:
                        if event.key == K_ESCAPE:
                            self.paused = 0
                pygame.display.flip()

            #########################################
            # HANDLES SAVES ETC.
            #########################################
            elif self.paused and self.saving:
                events = pygame.event.get()
                save = data.load_image('save.bmp',1)
                self.screen.blit(save,(0,0))
                saves = Savefile().read()
                if saves == []:
                    self.menu2.create(self.screen)
                    self.menu2.choose(events)
                else:
                    self.menu3.create(self.screen)
                    self.menu3.choose(events)
                for event in events:
                    if event.type == QUIT:
                        sys.exit()
                        return
                    if event.type == KEYDOWN:
                        if event.key == K_ESCAPE:
                            self.saving = 0
                pygame.display.flip()

            if self.lvl == 9:
                if self.player.rect.top < 100:
                    self.player.save = 0
예제 #29
0
    def __init__(self, game, name, index, config=None):
        super(LevelScene, self).__init__(game, name, index, config)

        self.font = data.load_font(data.FONT_FIX, 23)

        self.count = config['count'] if 'count' in config else 9
        self.delta = config['delta'] if 'delta' in config else 1000

        self.points = config['points'] if 'points' in config else 500
        self.volume = config['volume'] if 'volume' in config else 0.3
        self.pointsMulti = config['pointsMulti'] if 'pointsMulti' in config else 1
        self.pointsText = None

        self.sequence = button.SequenceButtonGroup((20, 20), (210, 100), 15, 5, self.count, self.delta)
        self.buttons = button.PlayableButtonGroup((50, 150), (35, 300), 20, 15, self.count, 750)

        self.seqindex = 0
        self.sequencing = False

        self.play = []
        self.playing = False

        self.background = data.load_image('background.png')
        self.ray = data.load_image('ray.png')
        self.piano = data.load_image('piano.png')

        self.music_bg = data.load_sound('background.ogg', self.name)
        self.music_bg.set_volume(self.volume)
        self.music_pre_bg = data.load_sound('pre-background.ogg', self.name)
        self.music_pre_bg.set_volume(0.3)

        self.sequence.associateTheme(self.name) 
        self.buttons.associateTheme(self.name)

        self.pre_bg_channel = None
        self.bg_channel = None

        # step counter management
        self.stepElapsingInTime = 1
        self.stepElapsedTimeCounter = 0
        self.counterStepPerClick = config['timetoclick'] if 'timetoclick' in config else 200
        self.currentCounterStep = self.counterStepPerClick

        # counting only when button animation is over
        self.stepCountElapsingTime = False
        self.stepCounterText = None
        self.rectWidth = 0

        boss = data.load_image('boss.png', self.name)
        boss.set_colorkey((255, 0, 255))
        
        miniboss = data.load_image('boss_mini.png', self.name)
        miniboss.set_colorkey((255, 0, 255))    
            
        self.animMiniBossImage = miniboss # pygame.transform.scale(boss, (170, 170))
        self.animMiniBossRect = self.animMiniBossImage.get_rect()
        self.animMiniBossRect.left = 302
        self.animMiniBossRect.bottom = 243
        
        self.animBossAction = 'scale'
        self.animBossActionCount = 0
        self.animBossImage = boss # pygame.transform.scale(boss, (170, 170))
        self.animBossRect = self.animBossImage.get_rect()
        self.animBossRect.left = 350
        self.animBossRect.bottom = 280
        self.animBossTime = 0
        self.animBossShowRaw = False

        self.counterRect = [266,250,110,8]
        self.counterRectDecSizePerStep = 110.0/self.counterStepPerClick

        self.incrRedColorUnit = 255.0/self.counterStepPerClick
        self.decrBlueColorUnit = 255.0/self.counterStepPerClick

        self.bottomPanel = pygame.Surface((640,240))
        self.bottomPanel.fill((100, 100, 100))
        self.bottomPanel.set_alpha(200)

        self.bottomText     = data.render_text(data.FONT_MAIN, 30, self.name.replace('-', ' ') + " starting in...", (255, 0, 0))
        self.bottomTextRect = self.bottomText.get_rect()
        self.bottomTextRect.center = (320, 360)
예제 #30
0
 def __init__(self, snd_name):
     if not media.have_avbin: return
     self.sound = data.load_sound(snd_name)
     self.player = None
예제 #31
0
 def __init__(self, *snd_names):
     if not media.have_avbin: return
     self.sounds = [data.load_sound(snd_name) for snd_name in snd_names]
     self.player = None
예제 #32
0
def loadSfx():
    game_vars.ball_death = data.load_sound('ball_death.wav')
    game_vars.ball_hit_wall = data.load_sound('ball_hit_wall.wav')
    game_vars.ball_hit_wall.set_volume(.2)
    game_vars.battery_pickup = data.load_sound('battery.wav')
    game_vars.check = data.load_sound('checkpoint.wav')
    game_vars.heal = data.load_sound('heal.wav')
    game_vars.robot_death = data.load_sound('robot_death.wav')
    game_vars.robot_hit_wall = data.load_sound('robot_hit_wall.wav')
    game_vars.robot_hit_wall.set_volume(.2)
    game_vars.teleport = data.load_sound('teleport.wav')
    game_vars.throw = data.load_sound('throw.wav')
    game_vars.block_hit = data.load_sound('block_hit.wav')
    game_vars.jet_pack = data.load_sound('jetpack.wav')
예제 #33
0
파일: game.py 프로젝트: Bredgren/OmniTank
 def _load_assets(self):
     self._img = {name: data.load_image(filename) for name, filename in self.img_assets.items()}
     self._snd = {name: data.load_sound(filename) for name, filename in self.snd_assets.items()}
예제 #34
0
    def __init__(self, screen,toon, level=1,lives=3):

        #########################################
        # SET UP SCREEN, FPS MONITOR (CLOCK), AND SPRITES
        #########################################
        self.screen = screen
        self.clock = pygame.time.Clock()
        self.sprites = pygame.sprite.OrderedUpdates()
        self.character = pygame.sprite.OrderedUpdates()
        self.flags = pygame.sprite.OrderedUpdates()
        self.death = pygame.sprite.OrderedUpdates()
        self.platforms = pygame.sprite.OrderedUpdates()
        self.enemies = pygame.sprite.OrderedUpdates()
        self.mushrooms = pygame.sprite.OrderedUpdates()
        self.coins = pygame.sprite.OrderedUpdates()
        self.questions = pygame.sprite.OrderedUpdates()
        self.stationary = pygame.sprite.OrderedUpdates()
        self.traps = pygame.sprite.OrderedUpdates()
        self.movingplatforms = pygame.sprite.OrderedUpdates()
        self.cannons = pygame.sprite.OrderedUpdates()
        self.bases = pygame.sprite.OrderedUpdates()
        self.coinquestions = pygame.sprite.OrderedUpdates()
        self.upplat = pygame.sprite.OrderedUpdates()
        self.brickquestions = pygame.sprite.OrderedUpdates()
        self.breakable = pygame.sprite.OrderedUpdates()
        self.powerup = pygame.sprite.OrderedUpdates()
        self.starquestions = pygame.sprite.OrderedUpdates()
        self.missles = pygame.sprite.OrderedUpdates()
        self.fire = pygame.sprite.OrderedUpdates()
        self.bridges = pygame.sprite.OrderedUpdates()
        self.switches = pygame.sprite.OrderedUpdates()
        self.hazards = pygame.sprite.OrderedUpdates()
        self.flares = pygame.sprite.OrderedUpdates()

        #########################################
        # IMAGES - all images cited in citations.txt
        #########################################
        if toon == 'Mario':
            Player.move_images = [data.load_image('mario1.png'), data.load_image('mario2.png'), data.load_image('mario3.png'), data.load_image('mario4.png'), data.load_image('mario1.png'), data.load_image('mario5.png')]
        if toon == 'Luigi':
            Player.move_images = [data.load_image('luigi1.png',1.435), data.load_image('luigi2.png',1.513), data.load_image('luigi3.png',1.513), data.load_image('luigi4.png',1.47), data.load_image('luigi1.png',1.435), data.load_image('luigi5.png',1.55)]
        if toon == 'Yoshi':
            Player.move_images = [data.load_image('yoshi1.png',1.75), data.load_image('yoshi2.png',1.694), data.load_image('yoshi3.png',1.696), data.load_image('yoshi4.png',1.694), data.load_image('yoshi1.png',1.75), data.load_image('yoshirand.png',1.6)]
        if toon == 'Toad':
            Player.move_images = [data.load_image('toad1.png'), data.load_image('toad2.png'), data.load_image('toad3.png'), data.load_image('toad4.png'), data.load_image('toad1.png'), data.load_image('toad5.png')]
        Cloud.image = data.load_image('cloud.png')
        Question.images = [data.load_image('q%s.png'%image) for image in xrange(0,4)]
        MushroomQuestion.images = [data.load_image('q%s.png'%image) for image in xrange(0,4)]
        StarBox.images = [data.load_image('q%s.png'%image) for image in xrange(0,4)]
        BrickQuestion.images = [data.load_image('q%s.png'%image) for image in xrange(0,4)]
        CoinQuestion.images = [data.load_image('q%s.png'%image) for image in xrange(0,4)]
        Coin.images = [data.load_image('coin%s.png'%image) for image in xrange(1,9)]
        Platform.image = data.load_image('platform-top.png')
        Brick.image = data.load_image('platform-brick.png')
        Bush.image = data.load_image('bush-1.png')
        Goomba.images = [data.load_image('goomba%s.png'%image)for image in xrange(1,4)]
        JumpPlatform.image = data.load_image('platform-air.png')
        OneUp.image = data.load_image('1up2.png')
        Pipe.image = data.load_image('pipe.png')
        Hill.image = data.load_image('hill.png')
        Flag.images = [data.load_image('flagpole%s.png' %image) for image in xrange(1,5)]
        Castle.image = data.load_image('castle.png')
        VenusFlyTrap.images = [data.load_image('redvenus%s.png' % image) for image in xrange(1,3)]
        BigPipe.image = data.load_image('bigpipe.png')
        RedKoopa.images = [data.load_image('redkoopa%s.png'%image) for image in xrange(1,4)]
        GreenKoopa.images = [data.load_image('greenkoopa%s.png'%image) for image in xrange(1,4)]
        DoubleCloud.image = data.load_image('doublecloud.png')
        BigTree.image = data.load_image('bigtree.png')
        Tree.image = data.load_image('tree.png')
        Fence.image = data.load_image('fence.png')
        RedKoopa.images = [data.load_image('redkoopa%s.png'%image) for image in xrange(1,4)]
        GrassLeft.image = data.load_image('grassleft.png')
        GrassMiddle.image = data.load_image('grassmiddle.png')
        GrassRight.image = data.load_image('grassright.png')
        GrassSupport.images = [data.load_image('grasssupport%s.png'%image) for image in xrange(0,4)]
        CrossGrass.images = [data.load_image('grass%s.png'%image)for image in xrange(1,4)]
        Wall.image = data.load_image('wall.png')
        Moving.image = data.load_image('moving.png')
        BigMoving.image = data.load_image('bigmoving.png')
        BigCannon.images = [data.load_image('cannonbig%s.png'%image) for image in xrange(1,3)]
        SmallCannon.images = [data.load_image('smallcannon%s.png'%image) for image in xrange(1,3)]
        Cannon.images = [data.load_image('cannon%s.png' % image) for image in xrange(1,3)]
        GrabCoin.images = [data.load_image('c%s.png' % image) for image in xrange(1,4)]
        GreenVenusFlyTrap.images = [data.load_image('vblue%s.png'%image)for image in xrange(0,2)]
        GrabShroom.images = [data.load_image('c%s.png' % image) for image in xrange(1,4)]
        BrickShroom.image = data.load_image('brickbreaker.png')
        Star.images = [data.load_image('star%s.png'%image)for image in xrange(0,8)]
        Bullet.image = data.load_image('bullet.png')
        CastleBrick.image = data.load_image('cbrick.png')
        Lava.images = [data.load_image('lava%s.png'%image)for image in xrange(0,2)]
        if level == 9:
            Lava.images = [data.load_image('water%s.png'%image)for image in xrange(0,2)]
        FireBlock.image = data.load_image('qempty.png')
        Bridge.image = data.load_image('bridge.png')
        Switch.image = data.load_image('switch.png')
        Bowser.image = data.load_image('bowser.png')
        FireBall.images = [data.load_image('fireball%s.png'%image,1.5)for image in xrange(0,6)]
        GoombaDie.image = data.load_image('goomba3.png')
        BowserCastle.image = data.load_image('bigcastle.png')
        Spike.image = data.load_image('spike.png')
        PeachCastle.image = data.load_image('peach.png',1)
        Flare.images = [data.load_image('flare%s.png'%image)for image in xrange(0,4)]

        #########################################
        # SPRITE GROUPS
        #########################################
        Flare.groups = self.flares, self.sprites
        PeachCastle.groups = self.sprites
        BowserCastle.groups = self.sprites
        Player.groups = self.sprites, self.character,self.death
        Cloud.groups = self.sprites,
        Question.groups = self.sprites, self.platforms, self.questions, self.stationary
        MushroomQuestion.groups = self.sprites, self.platforms, self.questions, self.stationary, self.upplat
        CoinQuestion.groups = self.sprites, self.platforms, self.questions, self.stationary, self.coinquestions
        BrickQuestion.groups = self.sprites, self.platforms, self.questions, self.stationary, self.brickquestions
        StarBox.groups = self.sprites, self.platforms, self.questions, self.stationary, self.starquestions
        Coin.groups = self.sprites,self.coins,
        Platform.groups = self.sprites,self.platforms,self.stationary,self.bases
        CastleBrick.groups = self.sprites,self.platforms,self.stationary
        Brick.groups = self.sprites, self.platforms, self.stationary, self.breakable
        Bush.groups = self.sprites
        Goomba.groups = self.sprites, self.enemies
        JumpPlatform.groups = self.sprites, self.platforms, self.stationary
        OneUp.groups = self.sprites, self.mushrooms
        Pipe.groups = self.sprites, self.platforms, self.stationary
        Hill.groups = self.sprites
        Flag.groups = self.sprites, self.flags
        Castle.groups = self.sprites
        VenusFlyTrap.groups = self.sprites, self.traps
        BigPipe.groups = self.sprites, self.platforms, self.stationary
        RedKoopa.groups = self.sprites, self.enemies
        GreenKoopa.groups = self.sprites, self.enemies
        DoubleCloud.groups = self.sprites
        Tree.groups = self.sprites
        BigTree.groups = self.sprites
        Fence.groups = self.sprites
        RedKoopa.groups = self.sprites, self.enemies
        GrassLeft.groups = self.sprites, self.platforms, self.stationary
        GrassMiddle.groups = self.sprites, self.platforms, self.stationary
        GrassRight.groups = self.sprites, self.platforms, self.stationary
        GrassSupport.groups = self.sprites, self.platforms, self.stationary
        CrossGrass.groups = self.sprites
        Wall.groups = self.sprites
        Moving.groups = self.sprites, self.platforms, self.movingplatforms
        BigMoving.groups = self.sprites, self.platforms, self.movingplatforms
        BigCannon.groups = self.sprites, self.platforms, self.stationary, self.cannons
        Cannon.groups = self.sprites, self.platforms, self.stationary, self.cannons
        SmallCannon.groups = self.sprites, self.platforms, self.stationary, self.cannons
        Death.groups = self.sprites,self.death
        GrabShroom.groups = self.sprites
        GrabCoin.groups = self.sprites,
        GreenVenusFlyTrap.groups = self.sprites, self.traps
        BrickShroom.groups = self.sprites, self.mushrooms
        Spike.groups = self.sprites, self.hazards
        Star.groups = self.sprites, self.powerup
        Bullet.groups = self.sprites, self.missles
        Lava.groups = self.sprites
        FireBlock.groups = self.sprites,self.platforms,self.stationary
        Bridge.groups = self.sprites,self.platforms,self.stationary,self.bridges
        Switch.groups = self.sprites,self.platforms,self.stationary,self.switches
        Bowser.groups = self.sprites,self.enemies
        FireBall.groups = self.sprites,self.fire
        GoombaDie.groups = self.sprites
        GreenKoopaDeath.groups = self.sprites
        Message.groups = self.sprites
        VenusDie.groups = self.sprites
        GreenVenusDie.groups = self.sprites
        RedKoopaDeath.groups = self.sprites

        # self.sprites = sprites w/ no interactions
        # self.character = the player
        # self.flags = flags @ end of level
        # self.death = keep track of death pictures
        # self.platforms = everything that you can stand on
        # self.enemies = all the enemies
        # self.mushrooms = powerups etc
        # self.coins = coins...
        # self.questions = question blocks
        # self.stationary = sprites which do not move
        # self.traps = the plants that eat you
        # self.movingplatforms = self explanatory
        # self.cannons = cannons
        # self.bases = floors for the plants
        # self.coinquestions = questions that spit coins
        # self.upplat = questions that spit 1up
        # self.brickquestions = questions that spit brickbreater /megamushroom
        # self.breakable = sprites that can be destroyed
        # self.powerup = ... power ups
        # self.starquestions = invincibility questions
        # self.missles = bullet bills
        # self.fire = bowser fire
        # self.bridges = bowser bridge
        # self.switches = bowser switch
        # self.hazards = bowser spikes

        #########################################
        # SOUNDS
        #########################################
        self.coinsound = data.load_sound('coin.wav',1)
        self.power = data.load_sound('getshroom.wav',1)
        self.complete = data.load_sound('flag.wav',1)

        #########################################
        # MENUS
        #########################################
        self.menu = genmenu(['Resume', lambda: self.placeholder()],['Save Game', lambda: self.placeholder1()],['Quit Game',lambda: self.placeholder2(self.screen)])
        self.menu.changeFont('Raleway Thin.ttf',28)
        self.menu.position(320,200)
        self.menu.defaultColor((255,255,255))
        self.menu.choiceColor((0,255,0))
        self.menu2 = genmenu(['FILE OPEN', lambda: self.save1(self.toon,self.lvl,self.lives)],['FILE OPEN', lambda: self.save2(self.toon,self.lvl,self.lives)],['FILE OPEN',lambda: self.save3(self.toon,self.lvl,self.lives)])
        self.save_menu()
        self.menu2.changeFont('smb256.ttf',28)
        self.menu2.position(320,200)
        self.menu2.defaultColor((0,0,0))
        self.menu2.choiceColor((255,0,125))

        #########################################
        # FONTS
        #########################################
        self.font = pygame.font.Font(data.filepath('smb256.ttf'),20)
        self.font4 = pygame.font.Font(data.filepath('smb256.ttf'),36)
        self.font2 = pygame.font.Font(data.filepath('Raleway Thin.ttf'),14)
        self.font3 = pygame.font.Font(data.filepath('Raleway Thin.ttf'),24)

        #########################################
        # FLAGS / GAME VALUES
        #########################################
        self.start = 1
        self.saving = 0
        self.diefix = 0
        self.paused = 0
        self.toon = toon
        self.score = 000
        self.chill = 0
        self.record = ''
        self.flagged = 0
        self.lives = lives
        self.powertracker = 0
        self.cheat_enabled = 0

        #########################################
        # LEVEL CREATION
        #########################################
        self.lvl = level
        self.bgcolor = get_bg()
        self.level = Level(self.lvl)
        self.player = Player((000,00),toon)
        self.bg = self.bgcolor[self.lvl][0]
        data.play_music(self.bgcolor[self.lvl][1])
        self.camera = Camera(self.player,self.level.width())

        #########################################
        # LOAD SCORES
        #########################################
        if Savefile('scores.txt').readscore() == None:
            self.highscore = 0
        else:
            self.highscore = int(Savefile('scores.txt').readscore())

        #########################################
        # AESTHETIC CHANGES
        #########################################
        self.mworld = 1 + (self.lvl-1)/4
        self.stage = (self.lvl-1)%4+1
        if level != 9:
            pygame.display.set_caption('World %s-%s'%(self.mworld,self.stage))
        else:
            pygame.display.set_caption('Princess Peach\'s Castle')

        #########################################
        # INITIALIZE GAME
        #########################################
        self.main_loop()
예제 #35
0
 def __init__(self, name):
     self.source = data.load_sound(name)
예제 #36
0
    def main_loop(self):
        while self.start:
            if not self.paused:
                self.clock.tick(60)
                self.camera.update()

                # for guy in self.character:
                #     guy.update()

                #########################################
                # HANDLES NO CLIPPING TOGGLING
                #########################################
                if self.cheat_enabled:
                    self.player.no_clip = 1
                    self.player.clear_collisions()
                else:
                    self.player.no_clip = 0

                #########################################
                # DEALS WITH NO CLIP INVICIBILITY
                #########################################
                if self.record == 'konami' and not self.chill and self.lvl != 9:
                    print 'C H E A T    E N A B L E D'
                    self.cheat_enabled = 1
                    self.chill = 1
                    data.stop_music()
                    data.play_music('winner.wav')

                if self.lvl == 9 and self.cheat_enabled:
                    self.cheat_enabled = 0
                    print 'C H E A T    D I S A B L E D'
                    print 'You no longer need to cheat. You cannot die in this sanctuary.'

                #########################################
                # FIX FOR MULTIPLE DYING SOUNDS, DYING IN GENERAL
                #########################################
                if self.flagged:
                    if self.diefix == 0:
                        die = data.load_sound('die.wav')
                        die.play()
                        self.diefix += 1
                    self.playerdie()

                #########################################
                # PRECAUTION IF FLAG DOES NOT CATCH YOU FOR SOME REASON
                #########################################
                if self.player.rect.right > self.level.size:
                    self.player.rect.right = self.level.size

                #########################################
                # KILLS YOU/SAVES YOU IF YOU FALL
                #########################################
                if self.player.rect.top > 460 and not self.player.invuln:
                    self.player.life -= 1
                    self.flagged = 1
                    self.playerdie()
                elif self.player.rect.bottom > 460 and self.player.invuln and not self.cheat_enabled:
                    self.player.rect.bottom = 460
                    self.player.save = 1

                #########################################
                # HANDLES INVULNERABILITY
                #########################################
                for toon in self.sprites:
                    toon.update()
                    if not self.cheat_enabled:
                        if self.player.invuln:
                            self.player.timer += 1
                            if self.player.timer > 250000:
                                self.player.invuln = 0
                                self.player.timer = 0
                                self.player.save = 0

                #########################################
                # CANNOT LOSE VICTORY LEVEL
                #########################################
                if self.lvl == 9 or self.cheat_enabled:
                    self.player.invuln = 1

                for platform in self.platforms:
                    platform.update()

                if self.player.no_clip != 1:
                    self.player.collide(self.platforms)

                for banner in self.flags:
                    banner.update()
                    if self.player.rect.centerx >= banner.rect.centerx and self.lvl !=9:
                        pygame.mixer.music.stop()
                        self.complete.play()
                        self.score += 460-self.player.rect.bottom
                        self.finish()
                    elif self.player.rect.centerx >= banner.rect.centerx:
                        self.score += 1000
                        self.win_game()


                #########################################
                # HANDLES CANNON FIRING
                #########################################
                for weapon in self.cannons:
                    if abs(weapon.rect.centerx-self.player.rect.centerx) < 400:
                        if self.player.rect.centerx < weapon.rect.centerx:
                            weapon.chance()

                #########################################
                # COIN EXTRACTION
                #########################################
                for block in self.coinquestions:
                    if block.rect.bottom == self.player.rect.top and (block.rect.left-15 < self.player.rect.centerx < block.rect.right+15):
                        block.bing()

                #########################################
                # HANDLES BULLET BILLS
                #########################################
                for bomb in self.missles:
                    if (bomb.rect.left - 20 < self.player.rect.centerx < bomb.rect.right + 20) and (0 < bomb.rect.top-self.player.rect.bottom < 5):
                            self.score += 245
                            self.player.up = -6
                            GrabCoin((bomb.rect.left,bomb.rect.top))
                            bomb.kill()
                            self.player.rect.bottom = bomb.rect.top-1
                    elif self.player.rect.colliderect(bomb.rect):
                        if self.player.invuln:
                            self.score += 20
                            GrabCoin((bomb.rect.left,bomb.rect.top))
                            bomb.kill()
                        else:
                            self.player.life -= 1
                            self.flagged = 1
                            self.playerdie()
                    bomb.update()

                #########################################
                # HANDLES BOWSER FIRE AND FLARES
                #########################################
                for heat in self.fire:
                    heat.update()
                    if self.player.rect.colliderect(heat.rect):
                        if self.player.invuln != 1:
                            self.player.life -= 1
                            self.flagged = 1
                            self.playerdie()
                        else:
                            heat.kill()

                for flare in self.flares:
                    if self.player.rect.colliderect(flare.rect):
                        if self.player.invuln:
                            flare.kill()
                        else:
                            self.player.life -= 1
                            self.flagged = 1
                            self.playerdie()

                #########################################
                # HANDLES QUESTIONBLOCK EXTRACTION
                #########################################
                for block in self.upplat:
                    if block.rect.bottom == self.player.rect.top and (block.rect.left-15 < self.player.rect.centerx < block.rect.right+15):
                        block.bing()

                for block in self.brickquestions:
                    if block.rect.bottom == self.player.rect.top and (block.rect.left-15 < self.player.rect.centerx < block.rect.right+15):
                        block.bing()

                for block in self.starquestions:
                    if block.rect.bottom == self.player.rect.top and (block.rect.left-15 < self.player.rect.centerx < block.rect.right+15):
                        block.bing()

                #########################################
                # HANDLES BRICK DEMOLITION
                #########################################
                for block in self.breakable:
                    if block.rect.bottom == self.player.rect.top and (block.rect.left-15 < self.player.rect.centerx < block.rect.right+15):
                        if self.player.breaker == 1:
                            block.bing()
                        if block.hits >= 9:
                            block.kill()
                            self.score += 10

                #########################################
                # HANDLES MUSHROOMS
                #########################################
                for shroom in self.mushrooms:
                    shroom.update()
                    shroom.collide(self.platforms)
                    if self.player.rect.colliderect(shroom.rect):
                        shroom.kill()
                        self.power.play()
                        if shroom.name == 'brick':
                            self.player.breaker = 1
                            self.score += 45
                            #self.player.magic()
                        if shroom.name == 'life':
                            self.lives += 1
                            self.score += 30
                        GrabShroom(shroom.rect.topleft,shroom.name)

                #########################################
                # HANDLES STARS
                #########################################
                for star in self.powerup:
                    star.update()
                    if self.player.rect.colliderect(star.rect):
                        star.kill()
                        self.power.play()
                        if self.player.invuln == 0:
                            self.player.invuln = 1
                        GrabShroom(star.rect.topleft,star.name)

                #########################################
                # HANDLES COINS
                #########################################
                for coin in self.coins:
                    if self.player.rect.colliderect(coin.rect):
                        coin.kill()
                        self.score += 50
                        self.coinsound.play()
                        GrabCoin(coin.rect.topleft)

                #########################################
                # HANDLES SPIKES
                #########################################
                for dagger in self.hazards:
                    if self.player.rect.colliderect(dagger.rect):
                        if self.player.invuln != 1:
                            self.player.life -= 1
                            self.flagged = 1
                            self.playerdie()
                        else:
                            dagger.kill()

                #########################################
                # HANDLES ENEMY COLLISIONS AND BOWSER BEHAVIOR
                #########################################
                for enemy in self.enemies:
                    enemy.update()
                    enemy.collide(self.stationary)
                    if enemy.name == 'Bowser':
                        if self.player.rect.centerx+3000 >= enemy.x:
                            if self.player.rect.right - enemy.rect.left < -75:
                                enemy.play((self.player.rect.right,self.player.rect.top))
                            elif self.player.rect.right - enemy.rect.left > -75:
                                enemy.defeat()
                        if self.player.rect.colliderect(enemy.rect):
                            if not self.player.invuln:
                                self.player.life -=1
                                self.flagged = 1
                                self.playerdie()
                    if enemy.name != 'Bowser':
                        if (enemy.rect.left - 17 < self.player.rect.centerx < enemy.rect.right + 17) and (0 < enemy.rect.top-self.player.rect.bottom < 8):
                            if enemy.name == 'Goomba':
                                self.score += 100
                            if enemy.name == 'RedKoopa':
                                self.score += 195
                            if enemy.name == 'GreenKoopa':
                                self.score += 165
                            self.player.up = -6
                            enemy.flag()
                            self.player.rect.bottom = enemy.rect.top-1
                        elif self.player.rect.colliderect(enemy.rect):
                            if self.player.invuln:
                                self.score += 20
                                enemy.flag()
                            else:
                                if self.player.breaker == 0:
                                    self.player.life -= 1
                                    self.flagged = 1
                                    self.playerdie()
                                else:
                                    enemy.flag()
                                    self.player.rect.bottom = enemy.rect.top-1
                                    self.player.breaker = 0
                                    #self.player.magic()

                #########################################
                # HANDLES BOWSER SWITCH KILLER
                #########################################
                for operator in self.switches:
                    if self.player.rect.bottom == operator.rect.top and (operator.rect.left-16 < self.player.rect.centerx < operator.rect.right+16):
                        for piece in self.bridges:
                            piece.kill()
                            for enemy in self.enemies:
                                if enemy.name == 'Bowser':
                                    enemy.die()
                    if self.player.rect.centerx > operator.rect.right:
                        for piece in self.bridges:
                            piece.kill()
                        for enemy in self.enemies:
                            if enemy.name == 'Bowser':
                                enemy.die()
                    if self.player.rect.left > operator.rect.right+50 and operator.dead == 0:
                        x = operator.x
                        y = operator.y
                        for mult in xrange(0,8):
                            CastleBrick((x,y-32*mult),None)
                        win = data.load_sound('break.wav',1)
                        win.play()
                        self.score += 500
                        operator.dead += 1

                #########################################
                # HANDLES PLANTS
                #########################################
                for venus in self.traps:
                    venus.update()
                    venus.collide(self.bases)
                    if self.player.rect.colliderect(venus.rect):
                        die = data.load_sound('stomp.wav',1)
                        if self.player.invuln:
                            venus.die()
                        else:
                            if self.player.breaker == 0:
                                self.player.life -= 1
                                self.flagged = 1
                                self.playerdie()
                            else:
                                self.player.breaker = 0
                                venus.die()

                #########################################
                # HANDLES EVENTS AND CHEAT CODES
                #########################################
                events = pygame.event.get()
                for event in events:
                    if event.type == QUIT:
                        sys.exit()
                        return
                    if event.type == KEYDOWN:
                        if event.key == K_ESCAPE:
                            self.paused = 1
                        if event.key == K_SPACE:
                            if not self.player.no_clip:
                                self.player.jump()
                        if self.record == '':
                            if event.key == K_k:
                                self.record += 'k'
                        if event.key == K_o and self.record == 'k':
                            self.record += 'o'
                        if event.key == K_n and self.record == 'ko':
                            self.record += 'n'
                        if event.key == K_a and self.record == 'kon':
                            self.record += 'a'
                        if event.key == K_m and self.record == 'kona':
                            self.record += 'm'
                        if event.key == K_i and self.record == 'konam':
                            self.record += 'i'
                        if self.record == 'konami':
                            if event.key == K_BACKQUOTE:
                                okay = 1
                                for sprite in self.platforms:
                                    if self.player.rect.colliderect(sprite.rect):
                                        okay = 0
                                if okay:
                                    self.record = ''
                                    self.chill = 0
                                    self.cheat_enabled = 0
                                    self.player.invuln = 0
                                    print 'C H E A T    D I S A B L E D'
                                    data.stop_music()
                                    data.play_music(self.bgcolor[self.lvl][1])
                                else:
                                    print 'This is not a valid location to turn on clipping!'

            #########################################
            # HANDLES SCREEN CREATION
            #########################################
            if not self.paused:
                self.screen.blit(self.bg, ((-self.camera.rect.x/1)%640, 0))
                self.screen.blit(self.bg, ((-self.camera.rect.x/1)%640 + 640, 0))
                self.screen.blit(self.bg, ((-self.camera.rect.x/1)%640 - 640, 0))
                self.camera.create_world(self.screen, self.sprites)
                self.info()
                pygame.display.flip()

            #########################################
            # HANDLES PAUSE SCREEN
            #########################################
            elif self.paused and not self.saving:
                events = pygame.event.get()
                pause = data.load_image('pausescreen.png',1)
                self.screen.blit(pause,(0,0))
                self.menu.create(self.screen)
                self.menu.choose(events)
                text = self.font.render('NOTE :',1,(255,0,0))
                self.screen.blit(text,(320-text.get_width()/2,360))
                text = self.font.render('If you quit without saving,',1,(255,255,255))
                self.screen.blit(text,(320-text.get_width()/2,390))
                text = self.font.render('your progress will be lost.',1,(255,255,255))
                self.screen.blit(text,(320-text.get_width()/2,420))
                for event in events:
                    if event.type == QUIT:
                        sys.exit()
                        return
                    if event.type == KEYDOWN:
                        if event.key == K_ESCAPE:
                            self.paused = 0
                pygame.display.flip()

            #########################################
            # HANDLES SAVES ETC.
            #########################################
            elif self.paused and self.saving:
                events = pygame.event.get()
                save = data.load_image('save.bmp',1)
                self.screen.blit(save,(0,0))
                saves = Savefile().read()
                if saves == []:
                    self.menu2.create(self.screen)
                    self.menu2.choose(events)
                else:
                    self.menu3.create(self.screen)
                    self.menu3.choose(events)
                for event in events:
                    if event.type == QUIT:
                        sys.exit()
                        return
                    if event.type == KEYDOWN:
                        if event.key == K_ESCAPE:
                            self.saving = 0
                pygame.display.flip()

            if self.lvl == 9:
                if self.player.rect.top < 100:
                    self.player.save = 0
예제 #37
0
파일: game.py 프로젝트: BradyZhou/15-112
    def __init__(self, screen,toon, level=1,lives=3):

        #########################################
        # SET UP SCREEN, FPS MONITOR (CLOCK), AND SPRITES
        #########################################
        self.screen = screen
        self.clock = pygame.time.Clock()
        self.sprites = pygame.sprite.OrderedUpdates()
        self.character = pygame.sprite.OrderedUpdates()
        self.flags = pygame.sprite.OrderedUpdates()
        self.death = pygame.sprite.OrderedUpdates()
        self.platforms = pygame.sprite.OrderedUpdates()
        self.enemies = pygame.sprite.OrderedUpdates()
        self.mushrooms = pygame.sprite.OrderedUpdates()
        self.coins = pygame.sprite.OrderedUpdates()
        self.questions = pygame.sprite.OrderedUpdates()
        self.stationary = pygame.sprite.OrderedUpdates()
        self.traps = pygame.sprite.OrderedUpdates()
        self.movingplatforms = pygame.sprite.OrderedUpdates()
        self.cannons = pygame.sprite.OrderedUpdates()
        self.bases = pygame.sprite.OrderedUpdates()
        self.coinquestions = pygame.sprite.OrderedUpdates()
        self.upplat = pygame.sprite.OrderedUpdates()
        self.brickquestions = pygame.sprite.OrderedUpdates()
        self.breakable = pygame.sprite.OrderedUpdates()
        self.powerup = pygame.sprite.OrderedUpdates()
        self.starquestions = pygame.sprite.OrderedUpdates()
        self.missles = pygame.sprite.OrderedUpdates()
        self.fire = pygame.sprite.OrderedUpdates()
        self.bridges = pygame.sprite.OrderedUpdates()
        self.switches = pygame.sprite.OrderedUpdates()
        self.hazards = pygame.sprite.OrderedUpdates()
        self.flares = pygame.sprite.OrderedUpdates()

        #########################################
        # IMAGES - all images cited in citations.txt
        #########################################
        if toon == 'Mario':
            Player.move_images = [data.load_image('mario1.png'), data.load_image('mario2.png'), data.load_image('mario3.png'), data.load_image('mario4.png'), data.load_image('mario1.png'), data.load_image('mario5.png')]
        if toon == 'Luigi':
            Player.move_images = [data.load_image('luigi1.png',1.435), data.load_image('luigi2.png',1.513), data.load_image('luigi3.png',1.513), data.load_image('luigi4.png',1.47), data.load_image('luigi1.png',1.435), data.load_image('luigi5.png',1.55)]
        if toon == 'Yoshi':
            Player.move_images = [data.load_image('yoshi1.png',1.75), data.load_image('yoshi2.png',1.694), data.load_image('yoshi3.png',1.696), data.load_image('yoshi4.png',1.694), data.load_image('yoshi1.png',1.75), data.load_image('yoshirand.png',1.6)]
        if toon == 'Toad':
            Player.move_images = [data.load_image('toad1.png'), data.load_image('toad2.png'), data.load_image('toad3.png'), data.load_image('toad4.png'), data.load_image('toad1.png'), data.load_image('toad5.png')]
        Cloud.image = data.load_image('cloud.png')
        Question.images = [data.load_image('q%s.png'%image) for image in xrange(0,4)]
        MushroomQuestion.images = [data.load_image('q%s.png'%image) for image in xrange(0,4)]
        StarBox.images = [data.load_image('q%s.png'%image) for image in xrange(0,4)]
        BrickQuestion.images = [data.load_image('q%s.png'%image) for image in xrange(0,4)]
        CoinQuestion.images = [data.load_image('q%s.png'%image) for image in xrange(0,4)]
        Coin.images = [data.load_image('coin%s.png'%image) for image in xrange(1,9)]
        Platform.image = data.load_image('platform-top.png')
        Brick.image = data.load_image('platform-brick.png')
        Bush.image = data.load_image('bush-1.png')
        Goomba.images = [data.load_image('goomba%s.png'%image)for image in xrange(1,4)]
        JumpPlatform.image = data.load_image('platform-air.png')
        OneUp.image = data.load_image('1up2.png')
        Pipe.image = data.load_image('pipe.png')
        Hill.image = data.load_image('hill.png')
        Flag.images = [data.load_image('flagpole%s.png' %image) for image in xrange(1,5)]
        Castle.image = data.load_image('castle.png')
        VenusFlyTrap.images = [data.load_image('redvenus%s.png' % image) for image in xrange(1,3)]
        BigPipe.image = data.load_image('bigpipe.png')
        RedKoopa.images = [data.load_image('redkoopa%s.png'%image) for image in xrange(1,4)]
        GreenKoopa.images = [data.load_image('greenkoopa%s.png'%image) for image in xrange(1,4)]
        DoubleCloud.image = data.load_image('doublecloud.png')
        BigTree.image = data.load_image('bigtree.png')
        Tree.image = data.load_image('tree.png')
        Fence.image = data.load_image('fence.png')
        RedKoopa.images = [data.load_image('redkoopa%s.png'%image) for image in xrange(1,4)]
        GrassLeft.image = data.load_image('grassleft.png')
        GrassMiddle.image = data.load_image('grassmiddle.png')
        GrassRight.image = data.load_image('grassright.png')
        GrassSupport.images = [data.load_image('grasssupport%s.png'%image) for image in xrange(0,4)]
        CrossGrass.images = [data.load_image('grass%s.png'%image)for image in xrange(1,4)]
        Wall.image = data.load_image('wall.png')
        Moving.image = data.load_image('moving.png')
        BigMoving.image = data.load_image('bigmoving.png')
        BigCannon.images = [data.load_image('cannonbig%s.png'%image) for image in xrange(1,3)]
        SmallCannon.images = [data.load_image('smallcannon%s.png'%image) for image in xrange(1,3)]
        Cannon.images = [data.load_image('cannon%s.png' % image) for image in xrange(1,3)]
        GrabCoin.images = [data.load_image('c%s.png' % image) for image in xrange(1,4)]
        GreenVenusFlyTrap.images = [data.load_image('vblue%s.png'%image)for image in xrange(0,2)]
        GrabShroom.images = [data.load_image('c%s.png' % image) for image in xrange(1,4)]
        BrickShroom.image = data.load_image('brickbreaker.png')
        Star.images = [data.load_image('star%s.png'%image)for image in xrange(0,8)]
        Bullet.image = data.load_image('bullet.png')
        CastleBrick.image = data.load_image('cbrick.png')
        Lava.images = [data.load_image('lava%s.png'%image)for image in xrange(0,2)]
        if level == 9:
            Lava.images = [data.load_image('water%s.png'%image)for image in xrange(0,2)]
        FireBlock.image = data.load_image('qempty.png')
        Bridge.image = data.load_image('bridge.png')
        Switch.image = data.load_image('switch.png')
        Bowser.image = data.load_image('bowser.png')
        FireBall.images = [data.load_image('fireball%s.png'%image,1.5)for image in xrange(0,6)]
        GoombaDie.image = data.load_image('goomba3.png')
        BowserCastle.image = data.load_image('bigcastle.png')
        Message.image = data.load_image('castleend.png')
        Spike.image = data.load_image('spike.png')
        PeachCastle.image = data.load_image('peach.png',1)
        Flare.images = [data.load_image('flare%s.png'%image)for image in xrange(0,4)]

        #########################################
        # SPRITE GROUPS
        #########################################
        Flare.groups = self.flares, self.sprites
        PeachCastle.groups = self.sprites
        BowserCastle.groups = self.sprites
        Player.groups = self.sprites, self.character,self.death
        Cloud.groups = self.sprites,
        Question.groups = self.sprites, self.platforms, self.questions, self.stationary
        MushroomQuestion.groups = self.sprites, self.platforms, self.questions, self.stationary, self.upplat
        CoinQuestion.groups = self.sprites, self.platforms, self.questions, self.stationary, self.coinquestions
        BrickQuestion.groups = self.sprites, self.platforms, self.questions, self.stationary, self.brickquestions
        StarBox.groups = self.sprites, self.platforms, self.questions, self.stationary, self.starquestions
        Coin.groups = self.sprites,self.coins,
        Platform.groups = self.sprites,self.platforms,self.stationary,self.bases
        CastleBrick.groups = self.sprites,self.platforms,self.stationary
        Brick.groups = self.sprites, self.platforms, self.stationary, self.breakable
        Bush.groups = self.sprites
        Goomba.groups = self.sprites, self.enemies
        JumpPlatform.groups = self.sprites, self.platforms, self.stationary
        OneUp.groups = self.sprites, self.mushrooms
        Pipe.groups = self.sprites, self.platforms, self.stationary
        Hill.groups = self.sprites
        Flag.groups = self.sprites, self.flags
        Castle.groups = self.sprites
        VenusFlyTrap.groups = self.sprites, self.traps
        BigPipe.groups = self.sprites, self.platforms, self.stationary
        RedKoopa.groups = self.sprites, self.enemies
        GreenKoopa.groups = self.sprites, self.enemies
        DoubleCloud.groups = self.sprites
        Tree.groups = self.sprites
        BigTree.groups = self.sprites
        Fence.groups = self.sprites
        RedKoopa.groups = self.sprites, self.enemies
        GrassLeft.groups = self.sprites, self.platforms, self.stationary
        GrassMiddle.groups = self.sprites, self.platforms, self.stationary
        GrassRight.groups = self.sprites, self.platforms, self.stationary
        GrassSupport.groups = self.sprites, self.platforms, self.stationary
        CrossGrass.groups = self.sprites
        Wall.groups = self.sprites
        Moving.groups = self.sprites, self.platforms, self.movingplatforms
        BigMoving.groups = self.sprites, self.platforms, self.movingplatforms
        BigCannon.groups = self.sprites, self.platforms, self.stationary, self.cannons
        Cannon.groups = self.sprites, self.platforms, self.stationary, self.cannons
        SmallCannon.groups = self.sprites, self.platforms, self.stationary, self.cannons
        Death.groups = self.sprites,self.death
        GrabShroom.groups = self.sprites
        GrabCoin.groups = self.sprites,
        GreenVenusFlyTrap.groups = self.sprites, self.traps
        BrickShroom.groups = self.sprites, self.mushrooms
        Spike.groups = self.sprites, self.hazards
        Star.groups = self.sprites, self.powerup
        Bullet.groups = self.sprites, self.missles
        Lava.groups = self.sprites
        FireBlock.groups = self.sprites,self.platforms,self.stationary
        Bridge.groups = self.sprites,self.platforms,self.stationary,self.bridges
        Switch.groups = self.sprites,self.platforms,self.stationary,self.switches
        Bowser.groups = self.sprites,self.enemies
        FireBall.groups = self.sprites,self.fire
        GoombaDie.groups = self.sprites
        GreenKoopaDeath.groups = self.sprites
        Message.groups = self.sprites
        VenusDie.groups = self.sprites
        GreenVenusDie.groups = self.sprites
        RedKoopaDeath.groups = self.sprites

        # self.sprites = sprites w/ no interactions
        # self.character = the player
        # self.flags = flags @ end of level
        # self.death = keep track of death pictures
        # self.platforms = everything that you can stand on
        # self.enemies = all the enemies
        # self.mushrooms = powerups etc
        # self.coins = coins...
        # self.questions = question blocks
        # self.stationary = sprites which do not move
        # self.traps = the plants that eat you
        # self.movingplatforms = self explanatory
        # self.cannons = cannons 
        # self.bases = floors for the plants 
        # self.coinquestions = questions that spit coins 
        # self.upplat = questions that spit 1up
        # self.brickquestions = questions that spit brickbreater /megamushroom
        # self.breakable = sprites that can be destroyed
        # self.powerup = ... power ups
        # self.starquestions = invincibility questions
        # self.missles = bullet bills
        # self.fire = bowser fire
        # self.bridges = bowser bridge
        # self.switches = bowser switch
        # self.hazards = bowser spikes

        #########################################
        # SOUNDS
        #########################################
        self.coinsound = data.load_sound('coin.wav',1)
        self.power = data.load_sound('getshroom.wav',1)
        self.complete = data.load_sound('flag.wav',1)

        #########################################
        # MENUS
        #########################################
        self.menu = genmenu(['Resume', lambda: self.placeholder()],['Save Game', lambda: self.placeholder1()],['Quit Game',lambda: self.placeholder2(self.screen)])
        self.menu.changeFont('Raleway Thin.ttf',28)
        self.menu.position(320,200)
        self.menu.defaultColor((255,255,255))
        self.menu.choiceColor((0,255,0))
        self.menu2 = genmenu(['FILE OPEN', lambda: self.save1(self.toon,self.lvl,self.lives)],['FILE OPEN', lambda: self.save2(self.toon,self.lvl,self.lives)],['FILE OPEN',lambda: self.save3(self.toon,self.lvl,self.lives)])
        self.save_menu()
        self.menu2.changeFont('smb256.ttf',28)
        self.menu2.position(320,200)
        self.menu2.defaultColor((0,0,0))
        self.menu2.choiceColor((255,0,125))

        #########################################
        # FONTS
        #########################################
        self.font = pygame.font.Font(data.filepath('smb256.ttf'),20)
        self.font4 = pygame.font.Font(data.filepath('smb256.ttf'),36)
        self.font2 = pygame.font.Font(data.filepath('Raleway Thin.ttf'),14)
        self.font3 = pygame.font.Font(data.filepath('Raleway Thin.ttf'),24)

        #########################################
        # FLAGS / GAME VALUES
        #########################################
        self.start = 1
        self.saving = 0
        self.diefix = 0
        self.paused = 0
        self.toon = toon
        self.score = 000
        self.chill = 0
        self.record = ''
        self.flagged = 0
        self.lives = lives
        self.powertracker = 0
        self.cheat_enabled = 0

        #########################################
        # LEVEL CREATION
        #########################################
        self.lvl = level
        self.bgcolor = get_bg()
        self.level = Level(self.lvl)
        self.player = Player((000,00),toon)
        self.bg = self.bgcolor[self.lvl][0]
        data.play_music(self.bgcolor[self.lvl][1])
        self.camera = Camera(self.player,self.level.width())

        #########################################
        # LOAD SCORES
        #########################################
        if Savefile('scores.txt').readscore() == None:
            self.highscore = 0
        else:
            self.highscore = int(Savefile('scores.txt').readscore())
        
        #########################################
        # AESTHETIC CHANGES
        #########################################
        self.mworld = 1 + (self.lvl-1)/4
        self.stage = (self.lvl-1)%4+1
        if level != 9:
            pygame.display.set_caption('World %s-%s'%(self.mworld,self.stage))
        else:
            pygame.display.set_caption('Princess Peach\'s Castle')
        
        #########################################
        # INITIALIZE GAME
        #########################################
        self.main_loop()