def evolve(self, keys, newkeys, buttons, newbuttons, mouse_position):
        self.mx,self.my = mouse_position
        if 1 in buttons:
            self.buttonon = True
        else:
            self.buttonon = False
            self.onrect = False

        clock = pygame.time.Clock()
        self.milliseconds = clock.tick(dynamicConfig.fps)  # milliseconds passed since last frame
        self.seconds = self.milliseconds / 1000.0

        self.time -= self.seconds*10
        self.time2 -= self.seconds*2

        if self.time2 <= 0:
            self.blonde.x = random.randint(50,630)

            self.blonde.y = random.randint (20, 200)
            self.time2 = 1

        if self.time <= 0:
            dynamicConfig.whatGame = dynamicConfig.randGame()
            dynamicConfig.health -= 1
            pygame.mouse.set_visible(True)
            CON.runGame()

        if self.blonde.health <=0:
            dynamicConfig.whatGame = dynamicConfig.randGame()
            dynamicConfig.score += 50
            pygame.mouse.set_visible(True)
            dynamicConfig.completedGames += 1
            CON.runGame()
        return
示例#2
0
    def evolve(self, keys, newkeys, buttons, newbuttons, mouse_position):
        if pygame.K_a in keys:
            self.player.moveLeft()
        if pygame.K_d in keys:
            self.player.moveRight()
        if self.player.health <= 0:
            dynamicConfig.health -= 1
            dynamicConfig.whatGame = dynamicConfig.randGame()
            CON.runGame()



        clock = pygame.time.Clock()
        self.milliseconds = clock.tick(dynamicConfig.fps)  # milliseconds passed since last frame
        self.seconds = self.milliseconds / 1000.0



        self.player.tick(self.height, self.fieldwidth)

        if self.milliseconds % 4 == 0 or self.milliseconds % 3 == 0:

            self.addDrop()

        self.time -= self.seconds*10

        if self.time <= 0:
            dynamicConfig.whatGame = dynamicConfig.randGame()
            dynamicConfig.completedGames += 1
            dynamicConfig.score += 50* self.player.health
            self.time = 0.1
            CON.runGame()


        for drop in self.drops:
            drop.tick(self.height-50)

        for drop in self.drops:
            if not drop.alive:
                continue
            x,y,h,w = self.player.getDimensions()
            drop.hitObject(x,y,h,w)
            if drop.hit == True:
                drop.setAlive(False)
                self.player.health -= 1

        live_drops = []


        for drop in self.drops:
            if drop.alive:
                live_drops.append(drop)

        self.drops = live_drops


        return
示例#3
0
    def draw(self,surface):
        rect = pygame.Rect(0,0,self.width,self.height)
        surface.fill((55,55,55),rect )
        label = self.font.render("Games Completed: "+str(dynamicConfig.completedGames), 1, (255, 255, 0))
        surface.blit(label, (self.width/2-200,self.height/3))
        label = self.font.render("Score: "+str(dynamicConfig.score), 1, (255, 255, 0))
        surface.blit(label, (self.width/2-100,self.height/2))

        rect= pygame.Rect(self.width/2-50,self.height/2+100,80,60)
        x,y,w,h = rect
        if self.hover(x,y,w,h)==True:
            surface.fill((100,100,100),rect )
        else:
            surface.fill((155,155,155),rect )
        if self.button(x, y, w, h):
            dynamicConfig.whatGame = dynamicConfig.randGame()
            CON.reset()
            CON.runGame()

        return
示例#4
0
    def draw(self, surface):
        background = pygame.image.load("starsbackground.png").convert()
        surface.blit(background, (0, 0))
        myfont = self.font
        lable = myfont.render("Code Camp Stories", 1, (255, 255, 0))
        surface.blit(lable, (370, 155))
        button = pygame.image.load("Pressedplaybutton.png").convert()
        button2 = pygame.image.load("Playbutton.png").convert()

        rect = pygame.Rect(450, 350, 100, 50)
        surface.fill((255, 255, 255), rect)
        mx, my = pygame.mouse.get_pos()
        x, y, w, h = rect
        if self.hover(mx, my, x, y, w, h):
            surface.blit(button, (x, y))
        else:
            surface.blit(button2, (x, y))

        if self.button(mx, my, x, y, w, h) == True:
            dynamicConfig.whatGame = dynamicConfig.randGame()
            CON.runGame()

        return