Ejemplo n.º 1
0
    def update(self):
        global g_bullet,full_list,bad_list
        if self. timer > 0:
            self.timer -= 1
        if self.target != None:
            if self.target.alive():
                new_rect = self.rect
                if (self.target.rect.centery - 3) > new_rect.centery:
                    new_rect.y += 3
                elif (self.target.rect.centery + 3) < new_rect.centery:
                    new_rect.y -= 3
                else:
                    new_rect.centery = self.target.rect.centery

                if new_rect.top > 0 and new_rect.bottom < 300:
                    self.rect = new_rect

                if self.timer == 0:
                    if self.target.rect.centery == self.rect.centery:
                        bullet = MagBall.bullet(self.rect.centerx,self.rect.centery)
                        bullet.add(g_bullet,full_list)
                        self.timer = 30
            else:
                self.target = None
        else:
            for b in bad_list:
                if b.rect.x > 200 and b.rect.right < 800:
                    self.target = b
                    break
Ejemplo n.º 2
0
    
                if event.key == pygame.K_e:
                    time_run = False
                    
                    
            if event.type == pygame.KEYUP:
                if event.key == pygame.K_SPACE:
                    jump_bar1.stop_move(player)
                if event.key == pygame.K_e:
                    time_run = True
                    
            if event.type == pygame.MOUSEBUTTONUP:
                if event.button == 3:
                    bullet_bar1.reload_bullet()
                if bullet_bar1.shoot():
                    bullet = MagBall.bullet(player.rect.centerx +40,player.rect.centery)
                    bullet.add(g_bullet,full_list)
        if done:
            break

    
        mX = (pygame.mouse.get_pos())[0]
        mY = (pygame.mouse.get_pos())[1]
    
        
    
        frames = 60
        #logic
        #coll_mouse_list = atom_list.get_sprites_at((mX,mY))
        if usc != None:
            usc.update()