Пример #1
0
 def __init__(self,x,y):
     Sprite.__init__(self);
     self._load_images();
     self.paso = 0;
     self.retraso = 5;
     self.image,self.rect = cargar_imagen('boom1.png', -1)
     self.rect.center =(x,y)
Пример #2
0
    def init(self,image_map,tile_x=0,tile_y=0,color_key=None):
        """MapEntity(Surface, tile_x, tile_y, direction)
       
           Surface should be obtained from util.load_image

           tile_x & tile_y specify what image map to use if you join
           multiple images into one map (Characters, Entities, etc)
           legal values are positive integers representing zero based index

           direction is what direction the entity should face,
           can also be set later with MapEntity.face(direction)
           legal values are map.NORTH, map.EAST, map.SOUTH, & map.WEST"""

        image = util.load_image(CHARACTERS_DIR, image_map, True, color_key)
        Sprite.__init__(self)
        self.image_args = (image_map, True, color_key)
        self.pos = (0,0)
        self.map = None
        self.image = image
        self.image_base_x = tile_x * 3 * TILE_SIZE
        self.image_base_y = tile_y * 4 * TILE_SIZE
        self.frame = 0
        self.image_tile = Rect( self.image_base_x, self.image_base_y,
                                TILE_SIZE, TILE_SIZE )
        self.rect = Rect(0,0,TILE_SIZE,TILE_SIZE)
        self.face(NORTH)
        self.next_frame()
        self.velocity = (0,0)
        self.speed = 4
        self.moving = False # For tile based motion
        self.always_animate = False
        self.animation_count = 1
        self.animation_speed = 6
        self.entered_tile = False
        self.can_trigger_actions = 0
Пример #3
0
    def __init(self):
        Sprite.__init__(self)

        self.current_state = None
        self.rect = None
        self.image = None
        self.mask = None
Пример #4
0
 def __init__(self, screen, anchor, hydrophytes, flies, ai):
     Sprite.__init__(self)
     self.screen = screen
     self.anchor = anchor
     self.anchor.jumped_on()
     self.hydrophytes = hydrophytes
     self.flies = flies
     self.ai = ai
     imm = Frog.imgs_ai if ai else Frog.imgs
     self.ai_prey = random.choice(self.flies)
     self.ai_tanchor = anchor
     self.ai_target = self.ai_prey
     self.images = [pygame.image.load(ur).convert_alpha() for ur in imm]
     self.image = self.images[0]
     self.image_w, self.image_h = self.image.get_size()
     self.angle = 0
     self.velocity = point2vec(0, 0)
     self.base_position = anchor.get_position_v()
     self.rel_position = point2vec(0, 0)
     self.state = Frog.SITTING
     self.jumping_time = 0
     self.already_jumping_time = 0
     self.already_eating = 0
     self.eating_time = 0.25
     self.eaten_flies = 0
     self.ai_resting_time = 1
     self.ai_already_resting_time = 0
Пример #5
0
 def __init__(self, x, y, area, ball, ai=False):
     Sprite.__init__(self)
     self.direction = 0
     self.image, self.rect = _load_image('games/pong/bat.png', x, y)
     self.area = area
     self.ball = ball
     self.ai   = ai
Пример #6
0
        def __init__ (self, type, res):
            Sprite.__init__(self)
            self.res = res
            self.size = self.res[1]/50
            self.type = type
            self.collected = False
            self.countdown = 1
            linethickness = rounder(self.res[0]/160)

            if type == 'bigracket':
                self.countdown = 60 * 25
                self.imagecolor = 'blue'
            elif type == 'slowball':
                self.countdown = 60 * 10
                self.imagecolor = 'yellow'
            elif type == '1up':
                self.imagecolor = 'green'

            self.image = pygame.Surface((self.size, self.size))
            pygame.draw.circle(self.image, pygame.Color(self.imagecolor), ((self.size/2), (self.size/2)), (self.size/2))
            self.rect = self.image.get_rect()
            width = rounder(self.res[0] * 0.2375 + linethickness)
            height = rounder(self.res[0] * 0.7625 - linethickness)
            distance = rounder(self.res[0]/16 + linethickness)
            self.rect.center = randint(width, height), distance
Пример #7
0
 def __init__(self, velocity, image, *groups):
     Sprite.__init__(self, *groups)
     self.velocity = velocity
     self.image = image
     self.rect = self.image.get_rect()
     self.position_vec = [0., 0.]
     self.velocity_vec = [0., 0.]
Пример #8
0
 def __init__(self, bird):
     Sprite.__init__(self)
     media.createbomb.play()
     self.bird = bird
     self.bomb = media.bomb.convert()
     self.bomb2 = media.bomb2.convert()
     self.boom = media.boom.convert()
     self.rect = pygame.rect.Rect(
         self.bird.rect.x, bird.rect.y + 16 * gl.RESIZE_FACTOR, 16 * gl.RESIZE_FACTOR, 16 * gl.RESIZE_FACTOR
     )
     self.image = self.bomb
     self.move = movement.Movement(
         self,
         accelx=1000 * gl.RESIZE_FACTOR,
         accely=1000 * gl.RESIZE_FACTOR,
         maxspeedx=200 * gl.RESIZE_FACTOR,
         maxspeedy=200 * gl.RESIZE_FACTOR,
         gravity=1000 * gl.RESIZE_FACTOR,
         decrease_speed_ratio=2,
     )
     self.move.add(self.bird.move.sprites())
     self.timeout = 3400
     self.explode_event = None
     self.delete_bomb = None
     self.exploded = False
     self.bombstate = 4
     self.attached = True
Пример #9
0
    def __init__(self, img1,x1,y1, img2=None,x2=None,y2=None):
        Sprite.__init__(self)
        self.prevDist = None
        self.img1 = None
        self.img2 = None

        #corrector for gaps - there are still gaps though -_-
        self.gapCorrector = 5
        #corrector for loading levels
        self.loadCorrector = 900

        self.totalx = 0
        self.prevx = None
        self.dx = 0

        if img1:
            self.img1 = StaticAnimation(img1)
            self.rect1 = self.img1.get_rect()
            self.rect1.topleft = (x1,y1)
            #copy of the first image for when img1 is done
            self.x1copy = False
            self.rect1copy = self.img1.get_rect()
            self.rect1copy.topleft = (x1,y1)
        if img2:
            self.img2 = StaticAnimation(img2)
            self.rect2 = self.img2.get_rect()
            self.rect2.topleft = (x2,y2)
            #copy of the second image for when img2 is done
            self.x2copy = False
            self.rect2copy = self.img2.get_rect()
            self.rect2.topleft = (x2,y2)
Пример #10
0
    def __init__(self, konum,screen):
        Sprite.__init__(self)
        self.durus = [pygame.image.load("jugador1/1.PNG")]
        self.yrs = [pygame.image.load("jugador1/2.PNG"), pygame.image.load("jugador1/3.PNG"),pygame.image.load("jugador1/4.PNG"),pygame.image.load("jugador1/5.PNG")]
        self.gc = [pygame.image.load("jugador1/6.PNG")]
        self.atak1=pygame.image.load("jugador1/atak/atak.PNG")
        self.aniatak1 = [pygame.image.load("jugador1/atak/1.PNG"),pygame.image.load("jugador1/atak/2.PNG"),pygame.image.load("jugador1/atak/3.PNG"),pygame.image.load("jugador1/atak/4.PNG")]
        self.aniatak2 = [pygame.image.load("jugador1/atak2/1.PNG"),pygame.image.load("jugador1/atak2/2.PNG")]

        self.image = self.durus[0]
        self.image.set_colorkey((255,255,255))
        
        self.rect =  self.image.get_rect()
        self.surface = screen
        self.prf = pygame.image.load("jugador1/prf/1.bmp")
        self.prf.set_colorkey((255,255,255))
        self.sari = (0,255,0)
        self.can = 150
        self.blit = screen.blit
        self.rect.x, self.rect.y = konum
        self.say = 0
        self.atak2= False
        self.atak1=False
        self.ynr = False
        self.olum = False
Пример #11
0
 def __init__ (self):
     Sprite.__init__(self)
     self.image=pygame.image.load(join('games','fall','ball.png')).convert_alpha()
     self.rect=self.image.get_rect()
     self.velocity=(0,0)
     self.rect.x=400
     self.rect.y=500
Пример #12
0
 def __init__(self, mapElement, imageCache):
     Sprite.__init__(self)
     self.mapElement = mapElement
     self.image = imageCache.getCachedSurface(self.mapElement.meta['image'])
     self.rect = self.image.get_rect()
     pixelLocation = self.mapElement.meta['screenLocation']
     self.rect.move_ip(*pixelLocation)
Пример #13
0
 def __init__(self,vel):
     Sprite.__init__(self)
     self.screen = window
     self.pos = [0,0]
     self.vel = vel
     self.show(pygame.color.THECOLORS["red"])
     self.update()
Пример #14
0
 def __init__(self, entity, image, gameboard, duration):
     Sprite.__init__(self)
     self.entity = entity
     self.gameboard = gameboard
     self.image = image
     self.start_time = pygame.time.get_ticks()
     self.duration = duration
Пример #15
0
 def __init__(self, position, radius=5):
     Sprite.__init__(self)
     self.position = position
     self.duration = 10
     self.expandto = 18
     self.radius = radius
     self.add(explosions)
Пример #16
0
    def __init__(self, screen, field, game,
                  image, init_pos, init_direction):
        """
            screen: obrazovka na ktoru sa bude vykraslovat
            
            field: rect v ktorom sa odohrava hra
            
            game: objekt hry
            
            image: ibrazok pre loptu
            
            init_direction = smer lopty na zaciatku
        """
        Sprite.__init__(self)
        
        self.screen = screen
        self.field = field
        self.game = game
        self.image = image
        self.pos = vec2d(init_pos)
        self.direction = vec2d(init_direction).normalized()

        self.speed = 0.35
        self.rect = self.image.get_rect()
        self.rect.center = self.pos
Пример #17
0
    def __init__(self, parent):
        Sprite.__init__(self)
        self.parent = parent
        self.name = parent.name
        if parent.name == "baby":
            self.size = 40,40
        self.color = parent.color
        self.image = Surface(self.size)
        self.rect = self.image.get_rect()
        self.rect.centerx = self.parent.rect.centerx
        self.rect.centery = self.parent.rect.centery
        self.dir = dir
        
    

        try:
            self.image = load_image(self.name+'bot')
            print "found family sprite"
        except:
            self.image.fill(self.color)
            print "failed to load family image"
        
        
        self.image = pygame.transform.scale(self.image, self.size)
        self.image.set_colorkey((255,255,255))
Пример #18
0
 def shieldcheck(self):
     if self.duration == 1:
         coll = pygame.sprite.spritecollide(self, ShieldGroup.shields, False, collide_meteor_shield)
         for shield in coll:
             if shield.kind == "cigar":
                 Sprite.kill(self)
                 pygame.draw.line(pygame.display.get_surface(), (255,0,0), self.rect.center, shield.rect.center, 3)
Пример #19
0
 def __init__(self, screen, field, game, image, side):
     """
         screen: obrazovka na ktoru sa bude vykraslovat
         
         field: rect v ktorom sa odohrava hra
         
         game: objekt hry
         
         image: ibrazok pre palku
         
         side: (left / right) urcuje na ktorej strane je palka
     """
     Sprite.__init__(self)
     
     self.screen = screen
     self.game = game
     self.field = field
     self.side = side
     self.speed = 5
     self.movement = 0
     
     self.image = image
     self.rect = image.get_rect()
     self.lives = 3
     
     if side == "left":
         self.pos = [self.field.left + 10, self.field.centery]
     else:
         self.pos = [(self.field.width - 10 - self.rect.width),
                     self.field.centery]
         
     self.rect = self.rect.move(self.pos)
Пример #20
0
 def __init__(self, y):
     Sprite.__init__(self)
     imgpath = os.path.join("games", "catching", "8bitcoin_trans.png")
     self.image, self.rect = _load_image(imgpath, 0, 0)
     self.rect.bottom = y
     self.rect.left = randint(0, locals.WIDTH - COIN_WIDTH)
     self.velocity = 1
Пример #21
0
 def __init__(self, x, y, paddle_color, parent=None, owner=None):
     """
     Initialize it with spawn position
     :param x: x coordinate of the play-field
     :param y: y coordinate of the play-field
     :param paddle_color:
     :param parent: ?
     :param owner: ?
     :return:
     """
     Sprite.__init__(self)
     self.vx = 0
     self.vy = 0
     self.speed = 10
     self.paddle_color = paddle_color
     self.image = Assets.paddles[paddle_color]  # pygame.image.load("gfx/paddle.png")
     self.mask = mask.from_surface(self.image)
     self.rect = self.image.get_rect()
     self.rect.x = x
     self.rect.y = y
     self.attachment_points = [(8, 0), (self.rect.width-8, 0)]
     self.attachments = []
     # self.attachments = [LaserGunAttachment(self)]
     self.parent = parent
     self.owner = owner
Пример #22
0
 def __init__(self, body, color, rect):
     Sprite.__init__(self)
     self.body = body
     self.color = color
     self.image = None
     self.rect = rect
     self.update(body, head_radius)
Пример #23
0
    def __init__(self, color="red"):

        if color == "red":
            self.color_key = 4
        elif color == "blue":
            self.color_key = 2
        else:
            self.color_key = 7


        Sprite.__init__(self)

        self.char_sprites = spritesheet("src/graphics/sheets/demons.png")


        self.image_down  = self.char_sprites.get_img(self.color_key, 4)
        self.image_left  = self.char_sprites.get_img(self.color_key, 5)
        self.image_right = self.char_sprites.get_img(self.color_key, 6)
        self.image_up    = self.char_sprites.get_img(self.color_key, 7)

        self.image = self.image_up

        self.pos = vec2d((SCREEN_WIDTH//2, SCREEN_HEIGHT//2))

        self.image_w, self.image_h = self.image.get_size()
Пример #24
0
 def __init__(self,enemy2):
     Sprite.__init__(self)
     self.rect = Rect(enemy2.rect.midbottom,(self.width, self.height))
     self.image = Surface(self.rect.size)
     self.image.fill((0,0,0))
     self.image.set_colorkey((0,0,0))
     pygame.draw.ellipse(self.image,yellow,self.image.get_rect())
Пример #25
0
 def __init__(self, theword, thefont):
     Sprite.__init__(self)
     self.myFont = thefont
     self.selected = False
     self.image = self.myFont.render(theword, True, white)
     self.theword = theword
     self.rect = self.image.get_rect()
Пример #26
0
	def __init__(self, color):
		Sprite.__init__(self)
		self.color = color
		self.rect = pygame.Rect( 0,0,Visitor.size[0],Visitor.size[1] )
		self.realPos = MyRect( self.rect )
		self.image = Surface( self.rect.size )
		self.image.fill( self.color )
		self.speed = 0.5
		self.shouldLeaveThePark = False

		self.desiredRides = []
		self.timeEnteredRecentLine = None
		self.attractionBoredomTimeout = 300
		self.lineupPadding = simulation.humanWidth*2
		self.lineup = None
		self.car = None
		self.carSeat = None
		self.ejectLocation = None
		self.moveDirection = None

		self.currentDestination = None
		self.currentDestPoint = None
		self.wanderMode = True
		self.nextDecisionCounter = 0
		self.correctionCounter = 0
Пример #27
0
 def __init__(self):
     Sprite.__init__(self)
     self.vx = 0
     self.vy = 0
     self.anim = PlayerAnimation(self, "mario", 60)
     self.image = self.anim.get_current_frame()
     self.rect = self.image.get_rect()
Пример #28
0
    def __init__(self, loc):
        Sprite.__init__(self)

        self.anim = CoinAnimation(240)
        self.image = self.anim.get_current_frame()
        self.rect = self.image.get_rect()
        self.rect.center = loc
Пример #29
0
 def __init__(self, bounds, level, facing):
     Sprite.__init__(self)
     self.image = self.proj
     self.facing = facing
     self.rect = self.image.get_rect()
     self.bounds = bounds
     self.level = level
Пример #30
0
 def __init__(self, x, y):
     Sprite.__init__(self)
     imgpath = join('games', 'ssb', 'zelda', 'fireball.png')
     self.image, self.rect = _load_image(imgpath, x, y)
     self.velocity = 10
     self.damage = 5
     self.max_knockback = 80
Пример #31
0
    def __init__(self):
        # call constructor from parent class
        Sprite.__init__(self)
        # visualization
        self.width = 50
        self.height = 50

        # define sprite
        self.image = pygame.image.load('images/shovel.png')
        self.image = pygame.transform.scale(self.image,
                                            (self.width, self.height))
        self.rect = self.image.get_rect()
        # place shovel on screen
        self.update(pygame.mouse.get_pos())
 def __init__(self):
     Sprite.__init__(self)
     self.puntos = 0
     self.vida = 100
     self.estado = "bajando"
     self.imagenes = [
         util.cargar_imagen('imagenes/Tanque.png'),
         util.cargar_imagen('imagenes/tanque destruido.png'),
         util.cargar_imagen('imagenes/Tanque.png'),
         util.cargar_imagen('imagenes/Tanque.png')
     ]
     self.image = self.imagenes[0]
     self.rect = self.image.get_rect()
     self.rect.move_ip(200, 500)
    def __init__(self, *groups, image_surface, pos_x=0, pos_y=0, theta=0):

        # initialize sprite class instance
        Sprite.__init__(self, *groups)

        # set positional and orientational attributes
        self.x = vec(pos_x, pos_y)

        # set image and rect attributes
        self.image = image_surface
        self.image.set_colorkey(WHITE)

        # initialize position attributes by first call to update()
        self.update(move=NONE)
Пример #34
0
 def __init__(self, x, y):
     Sprite.__init__(self)
     self.vel_x = 0
     self.vel_y = 0
     self.camera = 0
     self.image = Surface((40, 40))
     self.image.fill(Color('Red'))
     self.rect = Rect(x, y, 40, 40)
     self.death_pos = (0, 0)
     self.on_ground = False
     self.direction = 'right'
     self.state = 'regular'
     self.platform_check = False
     self.frame = 0
Пример #35
0
 def __init__(self, game, plat):
     # allows layering in LayeredUpdates sprite group
     self._layer = POW_LAYER
     # add a groups property where we can pass all instances of this object into game groups
     self.groups = game.all_sprites, game.powerups
     Sprite.__init__(self, self.groups)
     self.game = game
     self.plat = plat
     self.type = random.choice(['boost'])
     self.image = self.game.spritesheet.get_image(820, 1805, 71, 70)
     self.image.set_colorkey(BLACK)
     self.rect = self.image.get_rect()
     self.rect.centerx = self.plat.rect.centerx
     self.rect.bottom = self.plat.rect.top - 5
Пример #36
0
    def __init__(self, start_point, size, color, speed, min_speed, max_speed,
                 direction):
        Sprite.__init__(self)

        self.image = Surface(size)
        self.image.fill(color)
        self.rect = self.image.get_rect()
        self.speed = speed
        self.min_speed = min_speed
        self.max_speed = max_speed
        self.position = Vector2(start_point)
        self.direction = Vector2(direction)

        self.rect.centerx, self.rect.centery = self.position.x, self.position.y
Пример #37
0
    def __init__(self, x, y, velX=0, velY=0, xmult=0, ymult=0):
        Sprite.__init__(self)
        #optional terrain velocities
        self.velX = velX
        self.velY = velY
        #optional terrain velocity multipliers
        self.xmult = xmult
        self.ymult = ymult
        #If this isn't set we assume the base class has already loaded its image
        if self.base_img_path:
            self.anim = StaticAnimation(self.base_img_path)

        self.rect = self.anim.get_rect()
        self.rect.topleft = (x, y)
Пример #38
0
    def __init__(self, screen, init_position, isdraggable=False):

        #Arrangeable.__init__(self)
        Sprite.__init__(self)

        Dragable.__init__(self)
        self.set_draggable(isdraggable)

        self.commands = []
        self.running = False
        self.screen = screen
        self.set_position(init_position)
        self.update_callbacks = []
        self.isdraggable = isdraggable
Пример #39
0
    def __init__(self, screen, settings):
        Sprite.__init__(self)
        self.screen = screen
        self.image = pygame.image.load('foodImg.png').convert_alpha()
        self.image_w, self.image_h = self.image.get_size()
        self.speed = uniform(0.75, 1.25) * settings.food_speed

        self.x_position = randint(self.image_w / 2, self.screen.get_width() - self.image_w / 2)
        max_offset = min(settings.batch_size * self.image_h, self.screen.get_height())

        # Begin image at the top of the screen
        self.y_position = self.screen.get_height() - self.screen.get_height() - self.image_h / 2 + randint(0,
                                                                                                           self.screen.get_height())
        self.update_rect()
Пример #40
0
    def __init__(self, screen, archer):

        Sprite.__init__(self)
        self.screen = screen
        self.image_tail = pygame.image.load('arrow_tail.png').convert_alpha()
        self.image_head = pygame.image.load('arrow_head.png').convert_alpha()
        self.image_w, self.image_h = self.image_head.get_size()

        self.x_position = archer.image_w
        self.y_position = archer.y_position

        self.arrow_speed = 4

        self.update_rect()
Пример #41
0
    def __init__(self, tipo):

        Sprite.__init__(self)

        self.tipo = tipo

        path = ""
        if self.tipo == "agua":
            path = os.path.join(BASE_PATH, "Imagenes", "jarra.png")
        elif self.tipo == "alimento":
            path = os.path.join(BASE_PATH, "Imagenes", "pan.png")

        self.image = pygame.image.load(path)
        self.rect = self.image.get_bounding_rect()
Пример #42
0
 def __init__(self, game, plat):
     #This allows layering in the LayeredUpdates sprite group
     self._layer = POW_LAYER
     #This adds the group property so all instances of this object can be put into the game groups
     self.groups = game.all_sprites, game.powerups
     Sprite.__init__(self, self.groups)
     self.game = game
     self.plat = plat
     self.type = random.choice(['boost'])
     self.image = self.game.spritesheet.get_image(812, 453, 81, 99)
     self.image.set_colorkey(BLACK)
     self.rect = self.image.get_rect()
     self.rect.centerx = self.plat.rect.centerx
     self.rect.bottom = self.plat.rect.top - 5
Пример #43
0
 def __init__(self, text, x, y, size):
     Sprite.__init__(self)
     fonter = font.Font(os.path.join(FONT_DIR, "Cantarell-Regular.ttf"),
                        size).render(text, True, (0,0,0))
     frect = fonter.get_bounding_rect()
     frect.x = -frect.x
     frect.y = -frect.y
     font_sf = Surface((frect.width, frect.height), SRCALPHA, 32)
     font_sf.blit(fonter, frect)
     self.image = font_sf
     self.rect = font_sf.get_rect()        
     self.rect.x = x
     self.rect.y = y
     self.mask = mask.from_surface(self.image)
Пример #44
0
   def __init__(self, 
                position = (0,0),
                direction = 0,
                speed = 0,
                **keywords):
      Sprite.__init__(self)

      self.health = float("inf")
      self.max_health = self.health
      self.position = position
      self.image = None
      self.rect = None
      self.speed = speed
      self.direction = direction
Пример #45
0
	def __init__(self, tile_x = None, tile_y = None):
		Sprite.__init__(self)

		self.info = "POWERUP"

		#Take the keywords off
		self.tile_x = tile_x
		self.tile_y = tile_y

		self._active = False
		self.rect = pygame.Rect(0, 0, SIZE, SIZE)

		self._update_image()
		self.activate()
Пример #46
0
 def __init__(self, app, rect):
     Sprite.__init__(self)
     self.title = "altitude"
     self.app = app
     self.width = rect.width
     self.top = pygame.transform.scale(pygame.image.load(
         os.path.abspath(os.path.join(self.app.path, "KinectPlanes", "images",
         "alt_top.png"))), (self.width, self.width))
     self.bottom = pygame.transform.scale(pygame.image.load(
         os.path.abspath(os.path.join(self.app.path, "KinectPlanes", "images",
         "alt_bottom.png"))), (self.width, self.width))
     self.image = pygame.Surface((self.width, self.width), pygame.SRCALPHA)
     self.get_image(0)
     self.rect = rect
Пример #47
0
 def __init__(self, game, x, y, w, h):
     Sprite.__init__(self)
     #defining some self attributes for pewpew
     self.game = game
     self.image = pg.Surface((w, h))
     #color
     self.image.fill(LIGHTBLUE)
     #shape
     self.rect = self.image.get_rect()
     self.rect.x = x
     self.rect.y = y
     self.birth = time.perf_counter_ns()
     #how long it stays on screen (1 sec)
     self.lifespan = 1000000000
Пример #48
0
    def __init__(self, x: int, y: int, spritesheet: Surface):
        """
        Creates a berry object.
        @param x: x position of the berry in *world coordinates*
        @param y: y position of the berry in *world coordinates*
        @param spritesheet: a surface containing all costumes for the berry
        """
        Sprite.__init__(self)
        self.position = Vector2(x, y)

        spritesheet.convert()
        spritesheet.set_colorkey(Color(128, 51, 0))
        self.image = spritesheet
        self.rect = self.image.get_rect(center=self.position)
Пример #49
0
 def __init__(self, x, y):
     Sprite.__init__(self)
     self.cuadros = [
         util.cargar_imagen('bomba1.png'),
         util.cargar_imagen('bomba2.png'),
     ]
     self.rect = self.cuadros[0].get_rect()
     self.rect.center = (x, y)
     self.rect_colision = self.rect.inflate(-30, -30)
     self.paso = 0
     self.delay = -1
     self.image = self.cuadros[0]
     self.speed = [2, 2]
     self.control = 0
Пример #50
0
 def __init__(self, length=1, artist='', title=''):
     Sprite.__init__(self)
     self.track_start = time.time()
     self.track_end = time.time() + length
     self.track_length = length
     self.track_progress = 0
     self.image = pygame.Surface((settings.RESOLUTION[0], settings.NOW_PLAYING_HEIGHT))
     self.rect = self.image.get_rect()
     self.metadata = pygame.font.Font(
         settings.PROGRESS_FONT,
         settings.PROGRESS_FONT_SIZE
         ).render('%s - %s' % (artist, title), True, pygame.Color('white'))
     self.rect.bottom = settings.RESOLUTION[1]
     self.update()
Пример #51
0
    def create_grid(self, layer_id, group):
        layer_level = self.mapa_atual["layers"][layer_id]
        index_item = -1
        for celula in layer_level["grid"]:
            index_item += 1
            if celula == '0':
                continue

            y = index_item // layer_level["gridCellsY"]
            x = index_item % layer_level["gridCellsX"]
            celula_bloco = Sprite(group)
            celula_bloco.image = scale(
                self.tilemap_level.clip_sprite(0, 0, 16, 16), (32, 32))
            celula_bloco.rect = Rect(x * 32, y * 32, 32, 32)
Пример #52
0
    def init_animation(self):
        Sprite.__init__(self)

        self.sprite_sheet = pygame.image.load(self.sprite_image).convert()
        self.current_frame = 0
        self.image = Surface((self.sprite_width, self.sprite_height))

        rect = (self.sprite_width * self.current_frame, 0, self.sprite_width,
                self.sprite_height)
        self.image.blit(self.sprite_sheet, (0, 0), rect)
        self.image.set_colorkey(Color(255, 0, 255))
        self.rect = self.image.get_rect()
        self.elapsed = pygame.time.get_ticks()
        self.threshold = 1000 / self.fps
Пример #53
0
 def __init__(self, x, y, direction):
     Sprite.__init__(self, game.sprites)
     MovingSprite.__init__(self, x, y, self.low_speed, direction)
     BoxedInSprite.__init__(self, game.screen_rect.inflate(-20, -20))
     neighborhood.observe(self)
     self._normal_image = self.make_image(self.color)
     self._bright_image = self.make_image(self.running_color)
     self._accel = (self.high_speed - self.low_speed) / self.accel_sluggish
     self._decel = self._accel * 0.27
     self.max_turning_speed = 90 / self.turn_sluggish
     self._turn_min = -self.max_turning_speed
     self._turn_max = self.max_turning_speed
     self._nearest_animal = None
     self._nearest_animal_distance = None
Пример #54
0
    def __init__(self, screen, x, y, color):
        '''

        :param display: 渲染器
        :param x: 坐标X
        :param y: 坐标Y
        :param color 蛇身颜色
        '''
        Sprite.__init__(self)
        self.x = x
        self.y = y
        self.color = color
        self.screen = screen  # 渲染器
        self.rect = pygame.Rect((self.x, self.y, SW, SH))  # 创建Rect对象
Пример #55
0
 def __init__(self):
     Sprite.__init__(self)
     self.image = sett.IMAGES['mystery']
     self.image = pygame.transform.scale(self.image, (75, 35))
     self.rect = self.image.get_rect(topleft=(-80, 45))
     self.row = 5
     self.moveTime = 25000
     self.direction = 1
     self.timer = pygame.time.get_ticks()
     self.mysteryEntered = pygame.mixer.Sound(sett.SOUND_PATH +
                                              'mysteryentered.wav')
     self.mysteryEntered.set_volume(0.3)
     self.playSound = True
     self.screen = sett.SCREEN
Пример #56
0
 def __init__(self):
     Sprite.__init__(self)
     self.image = pygame.Surface((50, 50))
     self.image.fill(GREEN)
     '''sets image path to correct location joining image folder to file name then converting to a more efficient format'''
     # self.image = pygame.image.load(os.path.join(img_folder, "Tie.png")).convert()
     '''sets transparent color key to black'''
     # self.image.set_colorkey(BLACK)
     self.rect = self.image.get_rect()
     self.rect.center = (WIDTH / 2, HEIGHT / 2)
     # self.screen_rect = screen.get_rect()
     self.vx = 5
     self.vy = 5
     self.cofric = 0.5
Пример #57
0
 def __init__(self, game, plat):
     self._layer = SPIKES_LAYER
     self.groups = game.all_sprites, game.spikes
     Sprite.__init__(self, self.groups)
     self.game = game
     self.plat = plat
     self.type = random.choice(['boost'])
     self.image = self.game.spritesheet.get_image(885, 752, 51, 87)
     self.image.set_colorkey(BLACK)
     self.rect = self.image.get_rect()
     self.rect.centerx= self.plat.rect.centerx
     self.rect.bottom = self.plat.rect.top - 5
     self.rect = self.image.get_rect()
     self.rect_top = self.rect.top
Пример #58
0
    def __init__(self, assets):
        # Construtor da classe mãe (Sprite).
        Sprite.__init__(self)

        self.assets = assets
        self.flip = 1
        self.state = "standing"
        self.rect = self.image.get_rect()

        self.speedx = 0
        self.speedy = 0
        self.jumps = 0

        self.last_frame = 0
Пример #59
0
 def __init__(self, game, plat):
     # allows layering in LayeredUpdates sprite group
     self._layer = MOB_LAYER
     # add a groups property where we can pass all instances of this object into game groups
     self.groups = game.all_sprites, game.spikes
     Sprite.__init__(self, self.groups)
     self.game = game
     self.plat = plat
     self.type = random.choice(['spike'])
     self.image = self.game.spritesheet.get_image(232, 1390, 95, 53)
     self.image.set_colorkey(BLACK)
     self.rect = self.image.get_rect()
     self.rect.centerx = self.plat.rect.centerx
     self.rect.bottom = self.plat.rect.top
Пример #60
0
    def __init__(self, screen, img_filename, init_position):

        Sprite.__init__(self)
        self.collision = 0
        self.screen = screen
        self.base_image = pygame.image.load(img_filename).convert_alpha()
        self.size = (self.base_image.get_width(), self.base_image.get_height())
        self.base_image = pygame.transform.scale(self.base_image, self.size)
        self.image = self.base_image

        # base image holds the original image, positioned to
        # angle 0.

        self.pos = vec2d(init_position)