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)
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
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()
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()
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())
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
def __init__(self, position, radius=5): Sprite.__init__(self) self.position = position self.duration = 10 self.expandto = 18 self.radius = radius self.add(explosions)
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()
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)
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
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.]
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()
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))
def __init__(self, x, y): Sprite.__init__(self) imgpath = join('games', 'ssb', 'falco', 'laser.png') self.image, self.rect = _load_image(imgpath, x, y) self.velocity = 40 self.damage = 5 self.max_knockback = 100
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
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
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)
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)
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
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
def __init(self): Sprite.__init__(self) self.current_state = None self.rect = None self.image = None self.mask = None
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
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
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
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
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)
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
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
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
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
def __init__(self, frames, fps=20): Sprite.__init__(self) self.frames = frames self.current = 0 self.image = frames[0] self.rect = self.image.get_rect() self.playing = False self.reverse = False self._next_update = 0 #next time to update, in ms self._inv_period = fps / 1000 #1./ period of animation in ms (not frequency?) self._start_time = 0 # placeholder when animation is started self._paused_time = 0 #time inside app self._pause_start = 0 self._frames_len = len(self.frames)
def __init__(self, bullet_id, position, angle): Sprite.__init__(self) # draw bullet self.position = position self.direction = angle self.speed = 25 self.image = pygame.Surface([4, 20]) self.originImage = self.image self.rect = self.image.get_rect() self.rect.center = self.position pygame.draw.line(self.image, pygame.Color("white"), (1, 1), (1, 19), 2) # rotate image self.image = pygame.transform.rotate(self.originImage, self.direction) self.rect = self.image.get_rect(center=self.rect.center)
def __init__(self, follow, health, bulletgroup): Sprite.__init__(self) self.health = health self.bulletgroup = bulletgroup self.width = 60 self.height = 80 self.image = pg.Surface((self.width, self.height)) self.image.fill(GREEN) self.rect = self.image.get_rect() self.rect.center = (self.width / 2, self.height / 2) self.x = 0 self.y = 0 self.follow = follow self.speed = 2 self.weapon = AI_Weapon(self)
def __init__(self): Sprite.__init__(self) # self.image = pg.Surface((50,40)) self.image = pg.transform.scale(player_img, (50, 40)) self.image.set_colorkey(GREEN) # self.image = player_img # self.image.fill(GREEN) self.rect = self.image.get_rect() self.rect.centerx = WIDTH / 2 self.rect.bottom = HEIGHT - 10 self.speedx = 0 self.speedy = 10 self.power = 1 self.shield = 100 self.lives = 10
def __init__(self, string, offset, fontsize=None, color=(255, 255, 255), *args): if fontsize is None: fontsize = uiLabelSizeHint Sprite.__init__(self, *args) self.font = Font(uiLabelFontName, fontsize) self.string = string self.color = color self.offset = offset
def __init__(self, assets): # Construtor da classe mãe (Sprite). Sprite.__init__(self) self.assets = assets self.state = "inteira" self.rect = self.image.get_rect() self.rect.top = PICTURE_HEIGHT / 2 self.rect.x = random.randint(0, PICTURE_WIDTH - self.rect.width) # self self.speedx = random.randint(FRUIT_MIN_SPEEDX, FRUIT_MAX_SPEEDX) self.speedy = random.randint(FRUIT_MIN_SPEEDY, FRUIT_MAX_SPEEDY) self.last_frame = 0
def __init__(self): Sprite.__init__(self) self.puntos = 0 self.vida = 100 self.estado = "bajando" self.imagenes = [ util.cargar_imagen('imagenes/1.png'), util.cargar_imagen('imagenes/2.png'), util.cargar_imagen('imagenes/3.png'), util.cargar_imagen('imagenes/4.png'), util.cargar_imagen('imagenes/5.png') ] self.image = self.imagenes[0] self.rect = self.image.get_rect() self.rect.move_ip(0, 228)
def __init__(self, screen, x_pos, y_pos, settings, msg): Sprite.__init__(self) self.screen = screen self.settings = settings # Set dimensions and properties of button self.width, self.height = settings.button_width, settings.button_height self.x_position, self.y_position = x_pos, y_pos self.rect = pygame.Rect(x_pos, y_pos, self.width, self.height) self.font = pygame.font.SysFont(settings.button_font, settings.button_font_size) self.msg = msg # Button message only needs to be prepped once, not on every blit self.prep_msg()
def __init__(self, game): Sprite.__init__(self) x = random.randrange(WIDTH, WIDTH + 100) y = HEIGHT - 125 self.game = game self.image = pg.Surface((40, 40)) self.image.fill(RED) self.rect = self.image.get_rect() self.rect.centerx = x # self.vx = random.randrange(-4, -1) self.vx = random.randrange(-3, 3) self.pos = vec(x, y) self.vel = vec(0, 0) self.acc = vec(0, 0) self.rect.y = y
def __init__(self, surface: Optional[pygame.Surface] = pygame.Surface( (0, 0), flags=pygame.SRCALPHA), rotate: Optional[int] = 0, groups: Optional[Union[List[Group], Tuple[Group, ...]]] = tuple(), **kwargs): Sprite.__init__(self, *groups) self.__sounds = list() self.former_moves = dict() self.image = surface self.draw_sprite = True self.valid_size = True self.rotate(rotate) self.move(**kwargs)
def __init__(self): Sprite.__init__(self) Heater.__init__(self) self.temperature = 0 self.isActive = False self.hasMouseFocus = False self.isClicking = False self.isBuyingFuel = True self.amountUsedFuel = 0 self.usedFuelCapacity = 5 self.timeSinceStarted = 0 self.offImg = load_png('nuke_off.png') self.onImgs = [ load_png('nuke_on01.png'), load_png('nuke_on02.png'), load_png('nuke_on03.png'), load_png('nuke_on04.png'), load_png('nuke_on05.png'), ] self.onImg = load_png('nuke_on.png') self.focusImg = load_png('nuke_focus.png') self.fullImg = load_png('nuke_full.png') self.fuelImgs = [ load_png('nuke_fuel01.png'), load_png('nuke_fuel02.png'), load_png('nuke_fuel03.png'), load_png('nuke_fuel04.png'), load_png('nuke_fuel05.png'), ] self.fuelImg = load_png('nuke_fuel.png') self.fuelFocusImgs = [ load_png('nuke_fuel_focus01.png'), load_png('nuke_fuel_focus02.png'), load_png('nuke_fuel_focus03.png'), load_png('nuke_fuel_focus04.png'), load_png('nuke_fuel_focus05.png'), ] self.fuelFocusImg = load_png('nuke_fuel_focus.png') self.image = self.offImg self.rect = self.image.get_rect() controller = mvcState.GetController() controller.mouseListeners.append(self) controller.gameEventListeners.append(self) controller.GameEvent('HeaterBirth', self)
def __init__(self, solids, game): Sprite.__init__(self) self.solids = solids self.game = game self.width = 55 #35 self.height = 80 #45 # self.image = pg.Surface((self.width, self.height)) self.image = pg.transform.scale( self.game.spritesheet.get_image(725, 318, 240, 313), (60, 80)) self.rect = self.image.get_rect() self.rect.center = (self.width / 2, self.height / 2) self.rect.x = 7150 self.rect.y = 4400 self.speed = 5 self.falling = False self.weapon = Weapon(self) self.invulnerable = False self.walking = False self.y_direction = 'd' self.x_direction = 'r' self.dodging = False self.health = 9 self.last_time_hit = 0 self.forward_right_walk_cycle = [ pg.transform.scale( self.game.spritesheet.get_image(312, 5, 240, 313), (60, 80)), pg.transform.scale( self.game.spritesheet.get_image(552, 5, 240, 313), (60, 80)) ] self.forward_left_walk_cycle = [] for sprite in self.forward_right_walk_cycle: self.forward_left_walk_cycle.append( pg.transform.flip(sprite, True, False)) self.back_right_walk_cycle = [ pg.transform.scale( self.game.spritesheet.get_image(258, 954, 240, 313), (60, 80)), pg.transform.scale( self.game.spritesheet.get_image(511, 954, 240, 313), (60, 80)) ] self.back_left_walk_cycle = [] for sprite in self.back_right_walk_cycle: self.back_left_walk_cycle.append( pg.transform.flip(sprite, True, False)) self.current_frame = 0 self.last_frame = 0
def __init__(self, game, x, y): self.groups = game.all_sprites, game.walls Sprite.__init__(self, self.groups) self.game = game self.x = x self.y = y self.image = pygame.Surface((TILESIZE,TILESIZE)) self.image.fill(GREEN) self.rect = self.image.get_rect() self.rect.x = x * TILESIZE self.rect.y = y * TILESIZE
def __init__(self, ai_game): """Initialize the alien and set its starting position""" Sprite.__init__(self) self.screen = ai_game.screen self.settings = ai_game.settings #Load the alien image and set its rect attribute self.image = pygame.image.load('images/alien.bmp') self.rect = self.image.get_rect() #Start each new alien near the top left of the screen self.rect.x = self.rect.width self.rect.y = self.rect.height #Store the alien's exact horizontal position self.x = float(self.rect.x)
def __init__(self, screen, img_filename, init_position, init_direction, speed): Sprite.__init__(self) self.screen = screen self.speed = speed self.base_image = pygame.image.load('dalek.png') self.image = self.base_image self.pos = vec2d(init_position) self.direction = vec2d(init_direction).normalized() self.Rect = self.image.get_rect()
def __init__(self): Sprite.__init__(self) self.pollRate = 30 self.pollCounter = 0 self.notifyCounter = 0 self.visitor = None self.reportedPositions = [] self.enteredLineTime = None self.exitedLineTime = None self.lineup = None self.justExitedLineup = False self.justReturned = False self.rect = Rect(0, 0, *Visitor.size) self.image = Surface(Visitor.size) self.image.fill((150, 255, 150))
def __init__(self, game_set, screen, ship): """Creates an object for the bullet in the current position of the ship""" Sprite.__init__(self) self.screen = screen #Creates a rectangle for the bullet in (0, 0) and, following that, defines the correct position self.rect = pygame.Rect(0, 0, game_set.bullet_width, game_set.bullet_height) self.rect.centerx = ship.rect.centerx self.rect.top = ship.rect.top #Stores the position of the bullet with a decimal value self.y = float(self.rect.y) self.color = game_set.bullet_color self.speed = game_set.bullet_speed
def __init__(self, x, y, element): Sprite.__init__(self) self.image = load('images/map/wall.png') if element == '#': WALLS.append(self) elif element == ' ': self.image = load('images/map/food.png') FOODS.append(self) elif element == 'E': self.image = load('images/map/energizer.png') ENERGIZERS.append(self) elif element == 't': TIME_TRAPS.append(self) self.rect = self.image.get_rect() self.rect.x = x self.rect.y = y
def __init__(self,coord,vel): Sprite.__init__(self) print "aqui llegue." print vel print coord self.imagenes = [util.cargar_imagen('imagenes/rombox.png'), util.cargar_imagen('imagenes/rombo.png'), util.cargar_imagen('imagenes/rombo1.png'), util.cargar_imagen('imagenes/rombo2.png'), util.cargar_imagen('imagenes/rombo3.png'), util.cargar_imagen('imagenes/rombo4.png'), util.cargar_imagen('imagenes/rombo5.png')] self.i = vel self.image = self.imagenes[self.i] self.rect = self.image.get_rect() self.rect.move_ip(coord[0], coord[1])
def __init__(self): Sprite.__init__(self) self.puntos = 0 self.portal = 0 self.vida = 100 self.imagenes = [ util.cargar_imagen('imagenes/avion_izq.png'), util.cargar_imagen('imagenes/avion_der.png'), util.cargar_imagen('imagenes/avion_arr.png'), util.cargar_imagen('imagenes/avion_aba.png') ] self.image = self.imagenes[1] self.rect = self.image.get_rect() self.y = 20 self.x = 270 self.rect.move_ip(self.x, self.y)
def __init__(self, pos: Vector2, wall: bool, weight): Sprite.__init__(self) self.rect = Rect(pos.x, pos.y, 40, 40) self.pos = pos self.floor = 0 self.image = None self.weight = weight self.wall = wall self.payload = 0 self.neighbors = [] self.parent = None self.g = -1 self.f = -1 # User actions associated with this position self.userActions: List(UserAction) = []
def __init__(self): Sprite.__init__(self) #Image size self.image = pg.Surface((50, 40)) #Color self.image.fill(GREEN) #Places image self.rect = self.image.get_rect() self.rect.centerx = WIDTH / 2 self.rect.bottom = HEIGHT - 10 self.speedx = 0 self.speedy = 0 #Player Health self.hitpoints = 100 #Ammo total self.ammo = 100
def __init__(self, screen, settings): Sprite.__init__(self) self.screen = screen self.image = pygame.image.load('images\\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()
def __init__(self): """ Constructor que inicializa los siguientes valores: - La imagen a desplegar. - Posición, la cual es representada a través de un rectangulo invisible. - Velocidad por defecto de la pelota en el eje Y y Y """ Sprite.__init__(self) self.image = cargar_imagen("images/ball.png", True) self.rect = self.image.get_rect() self.rect.centerx = ANCHO / 2 self.rect.centery = ALTO / 2 self.sound = Sound('audios/rebote.wav') self.speed = [0.4, 0.4]
def __init__(self, game, image, speed=5): ''' 初始化函数 :param screen: 主窗体对象 ''' gameMap = game.get_map() self.__game = game self.gameMap = gameMap #self.screen = gameMap.get_screen() self.__bullets = [] ImageItem.__init__(self, image) x = gameMap.get_width() / 2 - self.get_width() / 2 y = gameMap.get_height() - self.get_height() Location.__init__(self, x, y) self.__speed = speed # 移动速度 Sprite.__init__(self)
def __init__(self, start_pos: Tuple[int, int], image: Surface): """ The constructor @param start_pos: the x and y start position @param image: the image """ Sprite.__init__(self) self._target_y_pos = None self.image = image self.rect = self.image.get_rect() self.rect.x = start_pos[0] self.rect.y = start_pos[1] self.velocity = 0 self.acceleration = 1 self.can_flap = True self.can_move = True
def __init__(self, coord, tipo): Sprite.__init__(self) self.imagenes = [ util.cargar_imagen('imagenes/algoritmia_icono.png'), util.cargar_imagen('imagenes/c++_icono.png'), util.cargar_imagen('imagenes/java_icono.png'), util.cargar_imagen('imagenes/algoritmia_icono.png'), util.cargar_imagen('imagenes/copa.jpg'), util.cargar_imagen('imagenes/start.png') ] self.image = self.imagenes[0] self.rect = self.image.get_rect() self.rect.move_ip(coord[0], coord[1]) self.tipo = tipo self.rect.x = coord[0] self.rect.y = coord[1]
def __init__(self, screen, m, x, y, Vx, Vy,img_filename, speed,h): Sprite.__init__(self) self.m = m self.h = h self.grad = 0 self.speed = speed self.x, self.y = x, y self.Vx, self.Vy = Vx, Vy self.animations = 0 self.player = False self.Del = False self.base_image = pygame.image.load(img_filename) self.image = self.base_image self.screen = screen self.image_w, self.image_h = self.image.get_size() self.rect = self.image.get_rect(center=(self.x, self.y))
def __init__(self, start_px, start_py, image_name, *groups): Sprite.__init__(self, *groups) self.px = start_px self.py = start_py self.yVel = 0 self.jumping = False self.attacking = False self.actual_side = "RIGHT" self._attack_state = {"right": 0, "left": 0} self._move_states = {"right": 0, "left": 0} self.rect = Rect(self.px, self.py, 0, 0) self._base_image_path = "src/sprites/" self.image_name = image_name self.image = self._scale_2x(pygame.image.load(self._base_image_path + image_name + "_right_0.png")) self.convert_image() pygame.draw.rect(self.image, BLACK, self)
def __init__(self, archer): Sprite.__init__(self) self.x = archer.x - 15 self.y = archer.y self.speed = -10 self.rect = pygame.Rect(0, 0, 23, 14) self.rect.centerx = self.x self.rect.top = self.y self.arrows = [] self.arrows.append(arrow_image) self.arrows.append(arrow_image) self.arrows.append(arrow_image) self.arrows.append(arrow_image) self.img = self.arrows[0] self.cur_arrow = 0 self.power = 5