Пример #1
0
    def normal_tick(self):
        # fire the guards
        shootchance = game.guard_fire * self.speedadjust
        randchance = random.random()
        self.powerupcount += randchance * self.speedadjust * (self.levelnum / 300.0)
        if self.player.active and randchance < shootchance:
            self.powerupcount += 0.1
            baddy = random.choice(self.guardobjs)
            baddy.fire()  # only requests a shot
        for baddy in self.guardobjs:
            shotspot, shotdir = baddy.shotinfo()
            if shotspot:
                s = objshot.Shot(shotspot, shotdir)
                self.shotobjs.append(s)
                snd.play("shoot", 1.0, shotspot[0])

        # add a powerup if ready
        if self.powerupcount >= game.powerupwait:
            self.powerupcount = 0.0
            p = objpowerup.newpowerup(self.levelnum)
            self.powerupobjs.append(p)
            snd.play("spring", 0.6)
            gamehelp.help("powerup", p.rect.topleft)

        if self.grabbedboxes >= 30:
            self.grabbedboxes = 0
            if game.comments >= 1:
                self.textobjs.append(objtext.Text(game.Complements[self.complement]))
            self.complement = (self.complement + 1) % len(game.Complements)
        elif self.grabbedboxes >= 20:
            self.numdeaths = 0

        self.tickleveltime(self.speedadjust)

        playerrect = self.player.rect.inflate(-1, -1)
        playercollide = playerrect.colliderect
        # collide player to boxes
        if self.touchingsecretspike:
            if not playercollide(self.touchingsecretspike.rect):
                # self.boxobjs.remove(self.touchingsecretspike)
                self.spikeobjs.append(objbox.Spike(self.touchingsecretspike.rect.topleft))
                self.boxobjs.remove(self.touchingsecretspike)
                self.touchingsecretspike = None
        for b in self.boxobjs:
            status = b.playercollide(playerrect)
            if status:
                self.grabbedboxes += 1
                self.powerupcount += 0.6
                if b in self.secretspikes:
                    self.touchingsecretspike = b
                    self.secretspikes.remove(b)
                    snd.play("klank2", 0.7, self.player.rect.centerx)
                elif status == 1:
                    self.powerupcount += 0.3
                    self.boxobjs.remove(b)
                    self.popobjs.append(b)
        # collide player to powerups
        for p in self.powerupobjs:
            if playercollide(p.rect):
                p.dead = 1
                effect = p.effect()
                if game.comments >= 2:
                    self.textobjs.append(objtext.Text('"' + effect.__doc__ + '"'))
                self.powereffects.append(effect)
                gamehelp.help(effect.__doc__, self.player.rect.center)
        playerrect = playerrect.inflate(-6, -6)
        playercollide = playerrect.colliderect
        asteroidrects = [o.colliderect for o in self.asteroidobjs]
        hitbullet = 0
        # collide player and asteroids to bullets
        for s in self.shotobjs:
            r = s.rect
            if playercollide(r):
                s.dead = 1
                if not self.player.shield:
                    self.changestate("playerdie")
                    hitbullet = 1
                else:
                    self.popobjs.append(objpopshot.PopShot(s.rect.center))
            for ar in asteroidrects:
                if ar.colliderect(r) and not s.dead:
                    s.dead = 1
                    self.popobjs.append(objpopshot.PopShot(s.rect.center))
                    break
        # collide player to spikes
        for s in self.spikeobjs:
            if s.armed and playercollide(s.rect):
                s.dead = 1
                self.changestate("playerdie")
                hitbullet = 1
        # collide player to asteroids
        if not hitbullet:
            for a, r in zip(self.asteroidobjs, asteroidrects):
                if playercollide(r):
                    self.changestate("playerdie")
                    a.dead = 1
                    self.popobjs.append(objpopshot.PopShot(r.center))

        if not self.boxobjs:
            self.changestate("levelend")

        # blow smoke (turbo)
        self.clocks += 1
        if self.player.turbo and (self.player.move[0] or self.player.move[1]) and gfx.surface.get_bytesize() > 1:
            self.smokeobjs.append(objsmoke.Smoke(self.player.rect.center))
            if game.clock.get_fps() > 35.0:
                self.smokeobjs.append(objsmoke.Smoke(self.player.rect.center))

        self.runobjects(self.objlists)
Пример #2
0
    def normal_tick(self):
        #fire the guards
        shootchance = game.guard_fire * self.speedadjust
        if self.player.active and random.random() < shootchance:
            self.powerupcount += 0.3
            baddy = random.choice(self.guardobjs)
            baddy.fire()  #only requests a shot
        for baddy in self.guardobjs:
            shotspot, shotdir = baddy.shotinfo()
            if shotspot:
                s = objshot.Shot(shotspot, shotdir)
                self.shotobjs.append(s)
                snd.play('shoot', 1.0, shotspot[0])

        #add a powerup if ready
        if self.powerupcount >= game.powerupwait:
            self.powerupcount = 0.0
            p = objpowerup.newpowerup(self.levelnum)
            self.powerupobjs.append(p)
            snd.play('spring', 0.6)
            gamehelp.help("powerup", p.rect.topleft)
        if self.grabbedboxes >= 50:
            self.grabbedboxes = 0
            if game.comments >= 1:
                self.textobjs.append(
                    objtext.Text(game.Complements[self.complement]))
            self.complement = int(
                (self.complement + 1) % len(game.Complements))
        elif self.grabbedboxes >= 20:
            self.numdeaths = 0

        self.tickleveltime(self.speedadjust)

        playerrect = self.player.rect.inflate(-1, -1)
        playercollide = playerrect.colliderect
        #collide player to boxes
        if self.touchingsecretspike:
            if not playercollide(self.touchingsecretspike.rect):
                #self.boxobjs.remove(self.touchingsecretspike)
                self.spikeobjs.append(
                    objbox.Spike(self.touchingsecretspike.rect.topleft))
                self.boxobjs.remove(self.touchingsecretspike)
                self.touchingsecretspike = None
        for b in self.boxobjs:
            status = b.playercollide(playerrect)
            if status:
                self.grabbedboxes += 1
                self.powerupcount += 0.6
                if b in self.secretspikes:
                    self.touchingsecretspike = b
                    self.secretspikes.remove(b)
                    snd.play('klank2', 0.7, self.player.rect.centerx)
                elif status == 1:
                    self.powerupcount += 0.3
                    self.boxobjs.remove(b)
                    self.popobjs.append(b)
        #collide player to powerups
        for p in self.powerupobjs:
            if playercollide(p.rect):
                p.dead = 1
                effect = p.effect()
                if game.comments >= 2:
                    self.textobjs.append(
                        objtext.Text('"' + effect.__doc__ + '"'))
                self.powereffects.append(effect)
                gamehelp.help(effect.__doc__, self.player.rect.center)
        playerrect = playerrect.inflate(-6, -6)
        playercollide = playerrect.colliderect
        asteroidrects = [o.colliderect for o in self.asteroidobjs]
        hitbullet = 0
        #collide player and asteroids to bullets
        for s in self.shotobjs:
            r = s.rect
            if playercollide(r):
                s.dead = 1
                if not self.player.shield:
                    self.changestate('playerdie')
                    hitbullet = 1
                else:
                    self.popobjs.append(objpopshot.PopShot(s.rect.center))
            for ar in asteroidrects:
                if ar.colliderect(r) and not s.dead:
                    s.dead = 1
                    self.popobjs.append(objpopshot.PopShot(s.rect.center))
                    break
        #collide player to spikes
        for s in self.spikeobjs:
            if s.armed and playercollide(s.rect):
                s.dead = 1
                self.changestate('playerdie')
                hitbullet = 1
        #collide player to asteroids
        if not hitbullet:
            for a, r in zip(self.asteroidobjs, asteroidrects):
                if playercollide(r):
                    self.changestate('playerdie')
                    a.dead = 1
                    self.popobjs.append(objpopshot.PopShot(r.center))

        if not self.boxobjs:
            self.changestate('levelend')

        #blow smoke (turbo)
        self.clocks += 1
        if self.player.turbo and (self.player.move[0] or self.player.move[1]
                                  ) and gfx.surface.get_bytesize() > 1:
            self.smokeobjs.append(objsmoke.Smoke(self.player.rect.center))
            if game.clock.get_fps() > 35.0:
                self.smokeobjs.append(objsmoke.Smoke(self.player.rect.center))

        self.runobjects(self.objlists)
Пример #3
0
    def normal_start(self):
        self.clocks = 0
        if self.levelnum == 0:
            gamehelp.help("player", (250, 100))
        elif self.levelnum == 1:
            gamehelp.help("guardians", (20, 700))
        elif self.levelnum == 2:
            gamehelp.help("skip", (700, 400))
        elif self.levelnum == 3:
            gamehelp.help("multibox", (220, 220))
        if self.levelnum >= 10:
            gamehelp.help("spikes", self.player.pos)
        if self.levelnum >= 30:
            gamehelp.help("secretspikes", self.player.pos)

        if len(self.asteroidobjs):
            gamehelp.help("asteroids", self.asteroidobjs[0].rect.center)
Пример #4
0
    def normal_start(self):
        self.clocks = 0
        if self.levelnum == 0:
            gamehelp.help("player", (250, 100))
        elif self.levelnum == 1:
            gamehelp.help("guardians", (20, 700))
        elif self.levelnum == 2:
            gamehelp.help("skip", (700, 400))
        elif self.levelnum == 3:
            gamehelp.help("multibox", (220, 220))
        if self.levelnum >= 10:
            gamehelp.help("spikes", self.player.pos)
        if self.levelnum >= 30:
            gamehelp.help("secretspikes", self.player.pos)

        if len(self.asteroidobjs):
            gamehelp.help("asteroids", self.asteroidobjs[0].rect.center)